diff --git a/cast_test.go b/cast_test.go index 76effc9..a7ab1a8 100644 --- a/cast_test.go +++ b/cast_test.go @@ -63,4 +63,5 @@ func TestToBool(t *testing.T) { assert.Equal(t, ToBool("T"), true) assert.Equal(t, ToBool(1), true) assert.Equal(t, ToBool(true), true) + assert.Equal(t, ToBool(-1), true) } diff --git a/caste.go b/caste.go index c8ccb4c..9f5916a 100644 --- a/caste.go +++ b/caste.go @@ -41,7 +41,7 @@ func ToBoolE(i interface{}) (bool, error) { case nil: return false, nil case int: - if i.(int) > 0 { + if i.(int) != 0 { return true, nil } return false, nil