aboutsummaryrefslogtreecommitdiff
path: root/int32_slice_test.go
diff options
context:
space:
mode:
authortherealmitchconnors <[email protected]>2019-09-05 11:27:43 -0700
committertherealmitchconnors <[email protected]>2019-09-05 11:27:43 -0700
commitb22fc706c39eab8ef626dad18f21609425cc8714 (patch)
tree324d2c8c6d112bf4f9e44db15c760831cfb9347d /int32_slice_test.go
parentc6c0f0fd30b9b96d1c9a1cbf90799706bd501458 (diff)
Expand SliceValue support to all slice and array types.
Diffstat (limited to 'int32_slice_test.go')
-rw-r--r--int32_slice_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/int32_slice_test.go b/int32_slice_test.go
index 69aaf9b..d2b49e4 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)