X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ffoundation%2Fapi%2Frevel%2Flibs_test.go;fp=src%2Ffoundation%2Fapi%2Frevel%2Flibs_test.go;h=d8f8355201f26e182136437bd93a3a497b1122a3;hb=1d1ee6961c93781e1187d8c7faa868da6b2f01f4;hp=0000000000000000000000000000000000000000;hpb=56dd5e0f2164b37b40ac1daa188ccc618b4cbd19;p=iec.git diff --git a/src/foundation/api/revel/libs_test.go b/src/foundation/api/revel/libs_test.go new file mode 100644 index 0000000..d8f8355 --- /dev/null +++ b/src/foundation/api/revel/libs_test.go @@ -0,0 +1,38 @@ +// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved. +// Revel Framework source code and usage is governed by a MIT style +// license that can be found in the LICENSE file. + +package revel + +import "testing" + +func TestToBooleanForFalse(t *testing.T) { + if ToBool(nil) || + ToBool([]string{}) || + ToBool(map[string]string{}) || + ToBool(0) || + ToBool(0.0) || + ToBool("") || + ToBool("false") || + ToBool("0") || + ToBool("0.0") || + ToBool("off") || + ToBool("f") { + t.Error("Expected 'false' got 'true'") + } +} + +func TestToBooleanForTrue(t *testing.T) { + if !ToBool([]string{"true"}) || + !ToBool(map[string]string{"true": "value"}) || + !ToBool(1) || + !ToBool(0.1) || + !ToBool("not empty") || + !ToBool("true") || + !ToBool("1") || + !ToBool("1.0") || + !ToBool("on") || + !ToBool("t") { + t.Error("Expected 'true' got 'false'") + } +}