From c6c0f0fd30b9b96d1c9a1cbf90799706bd501458 Mon Sep 17 00:00:00 2001 From: therealmitchconnors Date: Fri, 16 Aug 2019 12:07:51 -0700 Subject: Add first SliceValue implementations --- string_slice_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'string_slice_test.go') diff --git a/string_slice_test.go b/string_slice_test.go index c41f3bd..9a7e246 100644 --- a/string_slice_test.go +++ b/string_slice_test.go @@ -251,3 +251,26 @@ func TestSSWithSquareBrackets(t *testing.T) { } } } + +func TestSSAsSliceValue(t *testing.T) { + var ss []string + f := setUpSSFlagSet(&ss) + + in := []string{"one", "two"} + argfmt := "--ss=%s" + arg1 := fmt.Sprintf(argfmt, in[0]) + arg2 := fmt.Sprintf(argfmt, in[1]) + err := f.Parse([]string{arg1, arg2}) + if err != nil { + t.Fatal("expected no error; got", err) + } + + f.VisitAll(func(f *Flag) { + if val, ok := f.Value.(SliceValue); ok { + _ = val.Replace([]string{"three"}) + } + }) + if len(ss) != 1 || ss[0]!= "three" { + t.Fatalf("Expected ss to be overwritten with 'three', but got: %s", ss) + } +} \ No newline at end of file -- cgit v1.2.3