diff options
| author | Mitch Connors <[email protected]> | 2019-09-17 09:43:30 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-09-17 09:43:30 -0700 |
| commit | 7b22f689a41a1727c42eb02aaa1492d26402c592 (patch) | |
| tree | ca8ae6c13649d5a76f09cd8c7a4ca5011c870c85 /int32_slice_test.go | |
| parent | 972238283c0625cf3e881de7699ba8f2524c340a (diff) | |
| parent | 8e39cc44d9bd06ee2d9ef3109c93809072d5e551 (diff) | |
Merge pull request #216 from therealmitchconnors/elegant
Implement SliceValue for better list semantics
Diffstat (limited to 'int32_slice_test.go')
| -rw-r--r-- | int32_slice_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/int32_slice_test.go b/int32_slice_test.go index 69aaf9b..809c563 100644 --- a/int32_slice_test.go +++ b/int32_slice_test.go @@ -150,6 +150,29 @@ func TestI32SWithDefault(t *testing.T) { } } +func TestI32SAsSliceValue(t *testing.T) { + var i32s []int32 + f := setUpI32SFlagSet(&i32s) + + in := []string{"1", "2"} + argfmt := "--is=%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{"3"}) + } + }) + if len(i32s) != 1 || i32s[0] != 3 { + t.Fatalf("Expected ss to be overwritten with '3.1', but got: %v", i32s) + } +} + func TestI32SCalledTwice(t *testing.T) { var is []int32 f := setUpI32SFlagSet(&is) |
