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

Function TestValueRequiredError

errors_test.go:22–38  ·  errors_test.go::TestValueRequiredError
(t *testing.T)

Source from the content-addressed store, hash-verified

20}
21
22func TestValueRequiredError(t *testing.T) {
23 err := &ValueRequiredError{
24 flag: &Flag{},
25 specifiedName: "foo",
26 specifiedShorthands: "bar",
27 }
28
29 if err.GetFlag() == nil {
30 t.Error("Expected GetSpecifiedName to return its flag field, but got nil")
31 }
32 if err.GetSpecifiedName() != "foo" {
33 t.Errorf("Expected GetSpecifiedName to return %q, got %q", "foo", err.GetSpecifiedName())
34 }
35 if err.GetSpecifiedShortnames() != "bar" {
36 t.Errorf("Expected GetSpecifiedShortnames to return %q, got %q", "bar", err.GetSpecifiedShortnames())
37 }
38}
39
40func TestInvalidValueError(t *testing.T) {
41 expectedCause := errors.New("error")

Callers

nothing calls this directly

Calls 4

GetFlagMethod · 0.95
GetSpecifiedNameMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected