Cleanup parsing of annotations with lists
This commit is contained in:
parent
25d37b6645
commit
ad04fbe8b5
2 changed files with 76 additions and 35 deletions
|
|
@ -358,3 +358,39 @@ func TestLuaSharedDictsParsing(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitAndTrimSpace(t *testing.T) {
|
||||
testsCases := []struct {
|
||||
name string
|
||||
input string
|
||||
expect []string
|
||||
}{
|
||||
{
|
||||
name: "empty string",
|
||||
input: "",
|
||||
expect: []string{},
|
||||
},
|
||||
{
|
||||
name: "two elements",
|
||||
input: "el1,el2",
|
||||
expect: []string{"el1", "el2"},
|
||||
},
|
||||
{
|
||||
name: "two elements with spaces",
|
||||
input: " el1, el2",
|
||||
expect: []string{"el1", "el2"},
|
||||
},
|
||||
{
|
||||
name: "empty elements with spaces",
|
||||
input: " el1, el2,el3,,",
|
||||
expect: []string{"el1", "el2", "el3"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testsCases {
|
||||
data := splitAndTrimSpace(tc.input, ",")
|
||||
if !reflect.DeepEqual(data, tc.expect) {
|
||||
t.Errorf("Testing %v. Expected \"%v\" but \"%v\" was returned", tc.name, tc.expect, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue