From c57ccf8bbe604d9b68f4ea8c8f2dd223664300d2 Mon Sep 17 00:00:00 2001 From: txgruppi Date: Wed, 19 Nov 2014 18:08:49 +0000 Subject: [PATCH] Updated to return bool false only for zero --- cast_test.go | 1 + caste.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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