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

Function TestF32SCalledTwice

float32_slice_test.go:182–200  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

180}
181
182func TestF32SCalledTwice(t *testing.T) {
183 var f32s []float32
184 f := setUpF32SFlagSet(&f32s)
185
186 in := []string{"1.0,2.0", "3.0"}
187 expected := []float32{1.0, 2.0, 3.0}
188 argfmt := "--f32s=%s"
189 arg1 := fmt.Sprintf(argfmt, in[0])
190 arg2 := fmt.Sprintf(argfmt, in[1])
191 err := f.Parse([]string{arg1, arg2})
192 if err != nil {
193 t.Fatal("expected no error; got", err)
194 }
195 for i, v := range f32s {
196 if expected[i] != v {
197 t.Fatalf("expected f32s[%d] to be %f but got: %f", i, expected[i], v)
198 }
199 }
200}

Callers

nothing calls this directly

Calls 2

setUpF32SFlagSetFunction · 0.85
ParseMethod · 0.65

Tested by

no test coverage detected