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

Function TestS2SCalledTwice

string_to_string_test.go:139–162  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

137}
138
139func TestS2SCalledTwice(t *testing.T) {
140 var s2s map[string]string
141 f := setUpS2SFlagSet(&s2s)
142
143 in := []string{"a=1,b=2", "b=3", `"e=5,6"`, `f=7,8`}
144 expected := map[string]string{"a": "1", "b": "3", "e": "5,6", "f": "7,8"}
145 argfmt := "--s2s=%s"
146 arg0 := fmt.Sprintf(argfmt, in[0])
147 arg1 := fmt.Sprintf(argfmt, in[1])
148 arg2 := fmt.Sprintf(argfmt, in[2])
149 arg3 := fmt.Sprintf(argfmt, in[3])
150 err := f.Parse([]string{arg0, arg1, arg2, arg3})
151 if err != nil {
152 t.Fatal("expected no error; got", err)
153 }
154 if len(s2s) != len(expected) {
155 t.Fatalf("expected %d flags; got %d flags", len(expected), len(s2s))
156 }
157 for i, v := range s2s {
158 if expected[i] != v {
159 t.Fatalf("expected s2s[%s] to be %s but got: %s", i, expected[i], v)
160 }
161 }
162}

Callers

nothing calls this directly

Calls 2

setUpS2SFlagSetFunction · 0.85
ParseMethod · 0.65

Tested by

no test coverage detected