Skip to content

Commit cde56b1

Browse files
committed
testing: added DelimitedStringsOption parsing tests
1 parent 382fd11 commit cde56b1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: cli/parse_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func TestOptionParsing(t *testing.T) {
8484
cmds.StringOption("flag", "alias", "multiple long"),
8585
cmds.BoolOption("bool", "b", "a bool"),
8686
cmds.StringsOption("strings", "r", "strings array"),
87+
cmds.DelimitedStringsOption(",", "delimstrings", "d", "comma delimited string array"),
8788
},
8889
Subcommands: map[string]*cmds.Command{
8990
"test": &cmds.Command{},
@@ -154,6 +155,13 @@ func TestOptionParsing(t *testing.T) {
154155
test("-b --string foo test bar", kvs{"bool": true, "string": "foo"}, words{"bar"})
155156
test("-b=false --string bar", kvs{"bool": false, "string": "bar"}, words{})
156157
test("--strings a --strings b", kvs{"strings": []string{"a", "b"}}, words{})
158+
159+
test("--delimstrings a,b", kvs{"delimstrings": []string{"a", "b"}}, words{})
160+
test("--delimstrings=a,b", kvs{"delimstrings": []string{"a", "b"}}, words{})
161+
test("-d a,b", kvs{"delimstrings": []string{"a", "b"}}, words{})
162+
test("-d=a,b", kvs{"delimstrings": []string{"a", "b"}}, words{})
163+
test("-d=a,b -d c --delimstrings d", kvs{"delimstrings": []string{"a", "b", "c", "d"}}, words{})
164+
157165
testFail("foo test")
158166
test("defaults", kvs{"opt": "def"}, words{})
159167
test("defaults -o foo", kvs{"opt": "foo"}, words{})

0 commit comments

Comments
 (0)