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

Function TestI64SAsSliceValue

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

Source from the content-addressed store, hash-verified

145}
146
147func TestI64SAsSliceValue(t *testing.T) {
148 var i64s []int64
149 f := setUpI64SFlagSet(&i64s)
150
151 in := []string{"1", "2"}
152 argfmt := "--is=%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"})
163 }
164 })
165 if len(i64s) != 1 || i64s[0] != 3 {
166 t.Fatalf("Expected ss to be overwritten with '3.1', but got: %v", i64s)
167 }
168}
169
170func TestI64SCalledTwice(t *testing.T) {
171 var is []int64

Callers

nothing calls this directly

Calls 4

setUpI64SFlagSetFunction · 0.85
VisitAllMethod · 0.80
ParseMethod · 0.65
ReplaceMethod · 0.65

Tested by

no test coverage detected