mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-30 05:01:44 +00:00
add SplitAndTrim func (#183)
Refs https://github.com/tendermint/tendermint/issues/1380
This commit is contained in:
@ -30,3 +30,22 @@ func TestIsHex(t *testing.T) {
|
||||
assert.True(t, IsHex(v), "%q is hex", v)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitAndTrim(t *testing.T) {
|
||||
testCases := []struct {
|
||||
s string
|
||||
sep string
|
||||
cutset string
|
||||
expected []string
|
||||
}{
|
||||
{"a,b,c", ",", " ", []string{"a", "b", "c"}},
|
||||
{" a , b , c ", ",", " ", []string{"a", "b", "c"}},
|
||||
{" a, b, c ", ",", " ", []string{"a", "b", "c"}},
|
||||
{" , ", ",", " ", []string{"", ""}},
|
||||
{" ", ",", " ", []string{""}},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
assert.Equal(t, tc.expected, SplitAndTrim(tc.s, tc.sep, tc.cutset), "%s", tc.s)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user