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

Function TestS2I64CalledTwice

string_to_int64_test.go:138–156  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

136}
137
138func TestS2I64CalledTwice(t *testing.T) {
139 var s2i map[string]int64
140 f := setUpS2I64FlagSet(&s2i)
141
142 in := []string{"a=1,b=2", "b=3"}
143 expected := map[string]int64{"a": 1, "b": 3}
144 argfmt := "--s2i=%s"
145 arg1 := fmt.Sprintf(argfmt, in[0])
146 arg2 := fmt.Sprintf(argfmt, in[1])
147 err := f.Parse([]string{arg1, arg2})
148 if err != nil {
149 t.Fatal("expected no error; got", err)
150 }
151 for i, v := range s2i {
152 if expected[i] != v {
153 t.Fatalf("expected s2i[%s] to be %d but got: %d", i, expected[i], v)
154 }
155 }
156}

Callers

nothing calls this directly

Calls 2

setUpS2I64FlagSetFunction · 0.85
ParseMethod · 0.65

Tested by

no test coverage detected