Example #1
0
File: env_test.go Project: TV4/env
func TestBoolDefault(t *testing.T) {
	in, out := true, true

	os.Clearenv()

	if got := env.Bool("BOOL_DEFAULT", in); got != out {
		t.Errorf(`Bool("BOOL_DEFAULT", %v) = %v, want %v`, in, got, out)
	}
}
Example #2
0
File: env_test.go Project: TV4/env
func TestBool(t *testing.T) {
	tests := []struct {
		env string
		in  bool
		out bool
	}{
		{"t", false, true},
		{"1", false, true},
		{"", false, false},
		{"FALSE", true, false},
	}

	for _, tt := range tests {
		os.Setenv("BOOL", tt.env)

		if got := env.Bool("BOOL", tt.in); got != tt.out {
			t.Errorf(`Bool("BOOL", %v) = %v, want %v`, tt.in, got, tt.out)
		}
	}
}
Example #3
0
File: env_test.go Project: TV4/env
func ExampleBool() {
	os.Setenv("BOOL", "t")

	fmt.Println(env.Bool("BOOL", false))
	// Output: true
}