diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2022-12-03 10:37:56 +0000 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2022-12-03 10:37:56 +0000 |
| commit | 66757999fb5aa554d1277a21ba59a5f2e6ca0271 (patch) | |
| tree | 0400dc36b48418cc193115dcc8e92a6b66807b34 /flag_test.go | |
| parent | 2336eb2530e1f6df6817f309e0ea2a4102056967 (diff) | |
Have FlagTSlice{,Var} take an optional separator
This separator, when passed, allows for multiple values to be passed at
a time.
Diffstat (limited to 'flag_test.go')
| -rw-r--r-- | flag_test.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/flag_test.go b/flag_test.go index 1492e7a..ccbfadb 100644 --- a/flag_test.go +++ b/flag_test.go @@ -36,10 +36,10 @@ func TestFlagTSlice(s *testing.T) { t := core.T{T: s} fs := flag.NewFlagSet("", flag.PanicOnError) - fl := core.FlagTSlice(fs, "test", []int{42}, "", strconv.Atoi) + fl := core.FlagTSlice(fs, "test", []int{42}, "", strconv.Atoi, ",") t.AssertEqual([]int{42}, *fl) - t.AssertErrorIs(nil, fs.Parse([]string{"-test=1", "-test=2", "-test=42"})) - t.AssertEqual([]int{1, 2, 42}, *fl) + t.AssertErrorIs(nil, fs.Parse([]string{"-test=1", "-test=2", "-test=42,84"})) + t.AssertEqual([]int{1, 2, 42, 84}, *fl) } func TestFlagTSliceVar(s *testing.T) { @@ -47,8 +47,8 @@ func TestFlagTSliceVar(s *testing.T) { fs := flag.NewFlagSet("", flag.PanicOnError) var fl []int - core.FlagTSliceVar(fs, &fl, "test", []int{42}, "", strconv.Atoi) + core.FlagTSliceVar(fs, &fl, "test", []int{42}, "", strconv.Atoi, ",") t.AssertEqual([]int{42}, fl) - t.AssertErrorIs(nil, fs.Parse([]string{"-test=1", "-test=2", "-test=42"})) - t.AssertEqual([]int{1, 2, 42}, fl) + t.AssertErrorIs(nil, fs.Parse([]string{"-test=1", "-test=2", "-test=42,84"})) + t.AssertEqual([]int{1, 2, 42, 84}, fl) } |
