aboutsummaryrefslogtreecommitdiff
path: root/bool_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'bool_test.go')
-rw-r--r--bool_test.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/bool_test.go b/bool_test.go
index a2e1c5d..febf667 100644
--- a/bool_test.go
+++ b/bool_test.go
@@ -59,7 +59,8 @@ func (v *triStateValue) Type() string {
func setUpFlagSet(tristate *triStateValue) *FlagSet {
f := NewFlagSet("test", ContinueOnError)
*tristate = triStateFalse
- f.VarP(tristate, "tristate", "t", "tristate value (true, maybe or false)")
+ flag := f.VarPF(tristate, "tristate", "t", "tristate value (true, maybe or false)")
+ flag.NoOptDefVal = "true"
return f
}
@@ -162,3 +163,18 @@ func TestInvalidValue(t *testing.T) {
t.Fatal("expected an error but did not get any, tristate has value", tristate)
}
}
+
+func TestBoolP(t *testing.T) {
+ b := BoolP("bool", "b", false, "bool value in CommandLine")
+ c := BoolP("c", "c", false, "other bool value")
+ args := []string{"--bool"}
+ if err := CommandLine.Parse(args); err != nil {
+ t.Error("expected no error, got ", err)
+ }
+ if *b != true {
+ t.Errorf("expected b=true got b=%s", b)
+ }
+ if *c != false {
+ t.Errorf("expect c=false got c=%s", c)
+ }
+}