Add API Framework Revel Source Files
[iec.git] / src / foundation / api / revel / libs_test.go
1 // Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
2 // Revel Framework source code and usage is governed by a MIT style
3 // license that can be found in the LICENSE file.
4
5 package revel
6
7 import "testing"
8
9 func TestToBooleanForFalse(t *testing.T) {
10         if ToBool(nil) ||
11                 ToBool([]string{}) ||
12                 ToBool(map[string]string{}) ||
13                 ToBool(0) ||
14                 ToBool(0.0) ||
15                 ToBool("") ||
16                 ToBool("false") ||
17                 ToBool("0") ||
18                 ToBool("0.0") ||
19                 ToBool("off") ||
20                 ToBool("f") {
21                 t.Error("Expected 'false' got 'true'")
22         }
23 }
24
25 func TestToBooleanForTrue(t *testing.T) {
26         if !ToBool([]string{"true"}) ||
27                 !ToBool(map[string]string{"true": "value"}) ||
28                 !ToBool(1) ||
29                 !ToBool(0.1) ||
30                 !ToBool("not empty") ||
31                 !ToBool("true") ||
32                 !ToBool("1") ||
33                 !ToBool("1.0") ||
34                 !ToBool("on") ||
35                 !ToBool("t") {
36                 t.Error("Expected 'true' got 'false'")
37         }
38 }