Util: Support parsing and splitting strings enclosed in quotes in util.SplitString (#85735)

* Support parsing string enclosed in quotation marks in util.SplitString

* Support mixed formats of string list
This commit is contained in:
Misi
2024-04-09 10:35:57 +02:00
committed by GitHub
parent b200156a01
commit 4c12d77b98
3 changed files with 21 additions and 4 deletions

View File

@ -56,7 +56,14 @@ func TestSplitString(t *testing.T) {
`["foo", "bar baz"]`: {"foo", "bar baz"},
`["foo", "bar \"baz\""]`: {"foo", "bar \"baz\""},
` ["foo", "bar baz"]`: {"foo", "bar baz"},
`[]`: {},
`"foo", "bar", "baz"`: {"foo", "bar", "baz"},
`"foo" "bar" "baz"`: {"foo", "bar", "baz"},
` "foo" "bar" "baz" `: {"foo", "bar", "baz"},
`"foo", "bar baz"`: {"foo", "bar baz"},
`"foo", bar "baz"`: {"foo", "bar", "baz"},
`"first string", "second string", "third string"`: {"first string", "second string", "third string"},
`"first string" "second string" "third string" "fourth string"`: {"first string", "second string", "third string", "fourth string"},
`[]`: {},
}
for input, expected := range tests {
assert.EqualValues(t, expected, SplitString(input))