Exemplo n.º 1
0
Arquivo: env_test.go Projeto: 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)
	}
}
Exemplo n.º 2
0
Arquivo: env_test.go Projeto: 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)
		}
	}
}
Exemplo n.º 3
0
Arquivo: env_test.go Projeto: TV4/env
func ExampleBool() {
	os.Setenv("BOOL", "t")

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