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

Function TestUsage

flag_test.go:109–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

107}
108
109func TestUsage(t *testing.T) {
110 called := false
111 ResetForTesting(func() { called = true })
112 err := GetCommandLine().Parse([]string{"--x"})
113 expectedErr := "unknown flag: --x"
114 if err == nil {
115 t.Error("parse did not fail for unknown flag")
116 }
117 if err.Error() != expectedErr {
118 t.Errorf("expected error %q, got %q", expectedErr, err.Error())
119 }
120 if called {
121 t.Error("did call Usage while using ContinueOnError")
122 }
123}
124
125func TestAddFlagSet(t *testing.T) {
126 oldSet := NewFlagSet("old", ContinueOnError)

Callers

nothing calls this directly

Calls 4

ResetForTestingFunction · 0.85
GetCommandLineFunction · 0.85
ParseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected