diff options
| author | childe <[email protected]> | 2018-04-03 19:55:18 +0800 |
|---|---|---|
| committer | Eric Paris <[email protected]> | 2018-04-03 07:55:18 -0400 |
| commit | 1ce0cc6db4029d97571db82f85092fccedb572ce (patch) | |
| tree | 8c833fbe5daaefd3898388d4a979a696d151302d /golangflag_test.go | |
| parent | 1cd4a0c365d95803411bec89fb7b76bade17053b (diff) | |
make x.Parsed() return true after AddGoFlagSet(x) and pflag.Parse() (#162)
* make GoFlagSets.Parsed() true after pflag.Parse
some third part lib such as glog use go flag package, and its some
actions depends on if goflag.Parsed().
* add test case for goflag.CommandLine.Parsed()
* add comment to goflag.CommandLine.Parsed test case
Diffstat (limited to 'golangflag_test.go')
| -rw-r--r-- | golangflag_test.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/golangflag_test.go b/golangflag_test.go index 77e2d7d..5bd831b 100644 --- a/golangflag_test.go +++ b/golangflag_test.go @@ -36,4 +36,12 @@ func TestGoflags(t *testing.T) { if getBool != true { t.Fatalf("expected getBool=true but got getBool=%v", getBool) } + if !f.Parsed() { + t.Fatal("f.Parsed() return false after f.Parse() called") + } + + // in fact it is useless. because `go test` called flag.Parse() + if !goflag.CommandLine.Parsed() { + t.Fatal("goflag.CommandLine.Parsed() return false after f.Parse() called") + } } |
