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

Function TestDSCalledTwice

duration_slice_test.go:170–188  ·  duration_slice_test.go::TestDSCalledTwice
(t *testing.T)

Source from the content-addressed store, hash-verified

168}
169
170func TestDSCalledTwice(t *testing.T) {
171 var ds []time.Duration
172 f := setUpDSFlagSet(&ds)
173
174 in := []string{"1ns,2ns", "3ns"}
175 expected := []time.Duration{1, 2, 3}
176 argfmt := "--ds=%s"
177 arg1 := fmt.Sprintf(argfmt, in[0])
178 arg2 := fmt.Sprintf(argfmt, in[1])
179 err := f.Parse([]string{arg1, arg2})
180 if err != nil {
181 t.Fatal("expected no error; got", err)
182 }
183 for i, v := range ds {
184 if expected[i] != v {
185 t.Fatalf("expected ds[%d] to be %d but got: %d", i, expected[i], v)
186 }
187 }
188}

Callers

nothing calls this directly

Calls 2

setUpDSFlagSetFunction · 0.85
ParseMethod · 0.65

Tested by

no test coverage detected