Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Mar 6, 2022
1 parent f1e2c68 commit badc8e7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions flagx_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package flagx

import (
"flag"
"reflect"
"testing"
"time"
)

func TestFlagSet(t *testing.T) {
fset := NewFlagSet("testing")
_ = fset.Duration("timeout", "t", 10*time.Second, "just a timeout")

names := map[string]struct{}{}
fs := fset.AsStdlibFlagSet()
fs.VisitAll(func(f *flag.Flag) {
names[f.Name] = struct{}{}
})

want := map[string]struct{}{
"timeout": {}, "t": {},
}
if !reflect.DeepEqual(names, want) {
t.Fatalf("got %v want %v", names, want)
}
}

0 comments on commit badc8e7

Please sign in to comment.