diff options
| author | therealmitchconnors <[email protected]> | 2019-09-05 11:27:43 -0700 |
|---|---|---|
| committer | therealmitchconnors <[email protected]> | 2019-09-05 11:27:43 -0700 |
| commit | b22fc706c39eab8ef626dad18f21609425cc8714 (patch) | |
| tree | 324d2c8c6d112bf4f9e44db15c760831cfb9347d /duration_slice_test.go | |
| parent | c6c0f0fd30b9b96d1c9a1cbf90799706bd501458 (diff) | |
Expand SliceValue support to all slice and array types.
Diffstat (limited to 'duration_slice_test.go')
| -rw-r--r-- | duration_slice_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/duration_slice_test.go b/duration_slice_test.go index 489b012..22bca93 100644 --- a/duration_slice_test.go +++ b/duration_slice_test.go @@ -144,6 +144,29 @@ func TestDSWithDefault(t *testing.T) { } } +func TestDSAsSliceValue(t *testing.T) { + var ds []time.Duration + f := setUpDSFlagSet(&ds) + + in := []string{"1ns", "2ns"} + argfmt := "--ds=%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{"3ns"}) + } + }) + if len(ds) != 1 || ds[0]!= time.Duration(3) { + t.Fatalf("Expected ss to be overwritten with '3ns', but got: %v", ds) + } +} + func TestDSCalledTwice(t *testing.T) { var ds []time.Duration f := setUpDSFlagSet(&ds) |
