(t *testing.T)
| 26 | } |
| 27 | |
| 28 | func TestBoolFuncP(t *testing.T) { |
| 29 | var count int |
| 30 | fn := func(_ string) error { |
| 31 | count++ |
| 32 | return nil |
| 33 | } |
| 34 | |
| 35 | fset := NewFlagSet("test", ContinueOnError) |
| 36 | fset.BoolFuncP("bfunc", "b", "Callback function", fn) |
| 37 | |
| 38 | err := fset.Parse([]string{"--bfunc", "--bfunc=0", "--bfunc=false", "-b", "-b=0"}) |
| 39 | if err != nil { |
| 40 | t.Fatal("expected no error; got", err) |
| 41 | } |
| 42 | |
| 43 | if count != 5 { |
| 44 | t.Fatalf("expected 5 calls to the callback, got %d calls", count) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func TestBoolFuncUsage(t *testing.T) { |
| 49 | t.Run("regular func flag", func(t *testing.T) { |
nothing calls this directly
no test coverage detected