Int64Flag.ValueFromContext() as convenient accessor

This commit is contained in:
Tilo Prütz
2022-04-22 16:45:10 +02:00
parent bf18c00347
commit 18b44dfb29
2 changed files with 13 additions and 0 deletions

View File

@@ -709,6 +709,14 @@ func TestInt64FlagWithEnvVarHelpOutput(t *testing.T) {
}
}
func TestInt64FlagValueFromContext(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Int64("myflag", 42, "doc")
ctx := NewContext(nil, set, nil)
f := &Int64Flag{Name: "myflag"}
expect(t, f.ValueFromContext(ctx), int64(42))
}
var uintFlagTests = []struct {
name string
expected string