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

Function TestF64SAsSliceValue

float64_slice_test.go:147–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

145}
146
147func TestF64SAsSliceValue(t *testing.T) {
148 var f64s []float64
149 f := setUpF64SFlagSet(&f64s)
150
151 in := []string{"1.0", "2.0"}
152 argfmt := "--f64s=%s"
153 arg1 := fmt.Sprintf(argfmt, in[0])
154 arg2 := fmt.Sprintf(argfmt, in[1])
155 err := f.Parse([]string{arg1, arg2})
156 if err != nil {
157 t.Fatal("expected no error; got", err)
158 }
159
160 f.VisitAll(func(f *Flag) {
161 if val, ok := f.Value.(SliceValue); ok {
162 _ = val.Replace([]string{"3.1"})
163 }
164 })
165 if len(f64s) != 1 || f64s[0] != 3.1 {
166 t.Fatalf("Expected ss to be overwritten with '3.1', but got: %v", f64s)
167 }
168}
169
170func TestF64SCalledTwice(t *testing.T) {
171 var f64s []float64

Callers

nothing calls this directly

Calls 4

setUpF64SFlagSetFunction · 0.85
VisitAllMethod · 0.80
ParseMethod · 0.65
ReplaceMethod · 0.65

Tested by

no test coverage detected