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

Function TestNoInterspersed

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

Source from the content-addressed store, hash-verified

1047}
1048
1049func TestNoInterspersed(t *testing.T) {
1050 f := NewFlagSet("test", ContinueOnError)
1051 f.SetInterspersed(false)
1052 f.Bool("true", true, "always true")
1053 f.Bool("false", false, "always false")
1054 err := f.Parse([]string{"--true", "break", "--false"})
1055 if err != nil {
1056 t.Fatal("expected no error; got ", err)
1057 }
1058 args := f.Args()
1059 if len(args) != 2 || args[0] != "break" || args[1] != "--false" {
1060 t.Fatal("expected interspersed options/non-options to fail")
1061 }
1062}
1063
1064func TestTermination(t *testing.T) {
1065 f := NewFlagSet("termination", ContinueOnError)

Callers

nothing calls this directly

Calls 5

SetInterspersedMethod · 0.95
BoolMethod · 0.95
ParseMethod · 0.95
ArgsMethod · 0.95
NewFlagSetFunction · 0.85

Tested by

no test coverage detected