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

Function TestF32SAsSliceValue

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

Source from the content-addressed store, hash-verified

157}
158
159func TestF32SAsSliceValue(t *testing.T) {
160 var f32s []float32
161 f := setUpF32SFlagSet(&f32s)
162
163 in := []string{"1.0", "2.0"}
164 argfmt := "--f32s=%s"
165 arg1 := fmt.Sprintf(argfmt, in[0])
166 arg2 := fmt.Sprintf(argfmt, in[1])
167 err := f.Parse([]string{arg1, arg2})
168 if err != nil {
169 t.Fatal("expected no error; got", err)
170 }
171
172 f.VisitAll(func(f *Flag) {
173 if val, ok := f.Value.(SliceValue); ok {
174 _ = val.Replace([]string{"3.1"})
175 }
176 })
177 if len(f32s) != 1 || f32s[0] != 3.1 {
178 t.Fatalf("Expected ss to be overwritten with '3.1', but got: %v", f32s)
179 }
180}
181
182func TestF32SCalledTwice(t *testing.T) {
183 var f32s []float32

Callers

nothing calls this directly

Calls 4

setUpF32SFlagSetFunction · 0.85
VisitAllMethod · 0.80
ParseMethod · 0.65
ReplaceMethod · 0.65

Tested by

no test coverage detected