File: libs_test.go

package info (click to toggle)
golang-github-revel-revel 1.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,240 kB
  • sloc: xml: 7; makefile: 7; javascript: 1
file content (38 lines) | stat: -rw-r--r-- 860 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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'")
	}
}