MCPcopy Create free account
hub / github.com/docopt/docopt.go / TestShortOptionsErrorHandling

Function TestShortOptionsErrorHandling

docopt_test.go:1096–1113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1094}
1095
1096func TestShortOptionsErrorHandling(t *testing.T) {
1097 _, err := Parse("Usage: prog -x\nOptions: -x this\n -x that", []string{}, true, "", false, false)
1098 if _, ok := err.(*LanguageError); !ok {
1099 t.Error(fmt.Sprintf("(%s) %s", reflect.TypeOf(err), err))
1100 }
1101 _, err = Parse("Usage: prog", []string{"-x"}, true, "", false, false)
1102 if _, ok := err.(*UserError); !ok {
1103 t.Error(err)
1104 }
1105 _, err = Parse("Usage: prog -o\nOptions: -o ARG", []string{}, true, "", false, false)
1106 if _, ok := err.(*LanguageError); !ok {
1107 t.Error(err)
1108 }
1109 _, err = Parse("Usage: prog -o ARG\nOptions: -o ARG", []string{"-o"}, true, "", false, false)
1110 if _, ok := err.(*UserError); !ok {
1111 t.Error(err)
1112 }
1113}
1114
1115func TestMatchingParen(t *testing.T) {
1116 _, err := Parse("Usage: prog [a [b]", []string{}, true, "", false, false)

Callers

nothing calls this directly

Calls 2

ParseFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected