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

Function TestInvalidValueError

errors_test.go:40–57  ·  errors_test.go::TestInvalidValueError
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestInvalidValueError(t *testing.T) {
41 expectedCause := errors.New("error")
42 err := &InvalidValueError{
43 flag: &Flag{},
44 value: "foo",
45 cause: expectedCause,
46 }
47
48 if err.GetFlag() == nil {
49 t.Error("Expected GetSpecifiedName to return its flag field, but got nil")
50 }
51 if err.GetValue() != "foo" {
52 t.Errorf("Expected GetValue to return %q, got %q", "foo", err.GetValue())
53 }
54 if err.Unwrap() != expectedCause {
55 t.Errorf("Expected Unwrwap to return %q, got %q", expectedCause, err.Unwrap())
56 }
57}
58
59func TestInvalidSyntaxError(t *testing.T) {
60 err := &InvalidSyntaxError{

Callers

nothing calls this directly

Calls 4

GetFlagMethod · 0.95
GetValueMethod · 0.95
UnwrapMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected