0
0
mirror of https://github.com/thegeeklab/wp-plugin-go.git synced 2024-11-22 00:20:38 +00:00
wp-plugin-go/types/stringslice_test.go
Robert Kaussow 535fbe4771
feat: add custom cli types for string maps (#18)
BREAKING CHANGE: The existing type `StringSliceFlag` was moved to the new `types` package.
2023-08-19 15:25:53 +02:00

29 lines
543 B
Go

package types
import (
"reflect"
"testing"
)
func TestSplitWithEscaping(t *testing.T) {
tests := []struct {
Input string
Output []string
}{
{"", []string{}},
{"a,b", []string{"a", "b"}},
{",,,", []string{"", "", "", ""}},
{",a\\,", []string{"", "a,"}},
{"a,b\\,c\\\\d,e", []string{"a", "b,c\\\\d", "e"}},
}
for _, test := range tests {
strings := splitWithEscaping(test.Input, ",", "\\")
got, want := strings, test.Output
if !reflect.DeepEqual(got, want) {
t.Errorf("Got tag %v, want %v", got, want)
}
}
}