goProject/.svn/pristine/ec/ec2292a314f67cb894878b7b487f342851d79a87.svn-base
2025-01-06 16:21:36 +08:00

64 lines
1.1 KiB
Plaintext

package typeUtil
import (
"testing"
)
func TestBoolToInt(t *testing.T) {
// Test with true value
value := true
expected := 1
got := BoolToInt(value)
if expected != got {
t.Errorf("Expected %d, but got %d", expected, got)
return
}
// Test with false value
value = false
expected = 0
got = BoolToInt(value)
if expected != got {
t.Errorf("Expected %d, but got %d", expected, got)
return
}
}
func TestIntToBool(t *testing.T) {
// Test with 0 value
value := 0
expected := false
got := IntToBool(value)
if expected != got {
t.Errorf("Expected %t, but got %t", expected, got)
return
}
// Test with negative value
value = -1
expected = false
got = IntToBool(value)
if expected != got {
t.Errorf("Expected %t, but got %t", expected, got)
return
}
// Test with positive value
value = 1
expected = true
got = IntToBool(value)
if expected != got {
t.Errorf("Expected %t, but got %t", expected, got)
return
}
// Test with bigger positive value
value = 100
expected = true
got = IntToBool(value)
if expected != got {
t.Errorf("Expected %t, but got %t", expected, got)
return
}
}