MCPcopy
hub / github.com/spf13/pflag / TestMultipleNormalizeFlagNameInvocations

Function TestMultipleNormalizeFlagNameInvocations

flag_test.go:1232–1242  ·  view source on GitHub ↗

Name normalization function should be called only once on flag addition

(t *testing.T)

Source from the content-addressed store, hash-verified

1230
1231// Name normalization function should be called only once on flag addition
1232func TestMultipleNormalizeFlagNameInvocations(t *testing.T) {
1233 normalizeFlagNameInvocations = 0
1234
1235 f := NewFlagSet("normalized", ContinueOnError)
1236 f.SetNormalizeFunc(wordSepNormalizeFunc)
1237 f.Bool("with_under_flag", false, "bool value")
1238
1239 if normalizeFlagNameInvocations != 1 {
1240 t.Fatal("Expected normalizeFlagNameInvocations to be 1; got ", normalizeFlagNameInvocations)
1241 }
1242}
1243
1244func TestHiddenFlagInUsage(t *testing.T) {
1245 f := NewFlagSet("bob", ContinueOnError)

Callers

nothing calls this directly

Calls 3

SetNormalizeFuncMethod · 0.95
BoolMethod · 0.95
NewFlagSetFunction · 0.85

Tested by

no test coverage detected