-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathstrings_test.go
66 lines (62 loc) · 1.11 KB
/
strings_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package opts
import (
"reflect"
"testing"
)
func TestKVMap(t *testing.T) {
for _, testcase := range []struct {
input string
output map[string]string
}{
{
"a=b,c=d",
map[string]string{"a": "b", "c": "d"},
},
{
"foo,,bar,,",
map[string]string{"foo": "", "bar": ""},
},
{
"ping=,,pong==,,",
map[string]string{"ping": "", "pong": "="},
},
{
"nospace=,, leadingspace==, trailingspace ,",
map[string]string{"nospace": "", "leadingspace": "=", "trailingspace ": ""},
},
} {
kv := newKV(testcase.input)
m := kv.m
if !reflect.DeepEqual(m, testcase.output) {
t.Fatalf("input: %s\n expected: %s\n got: %s",
testcase.input,
testcase.output,
m,
)
}
}
}
func TestCamel2Dash(t *testing.T) {
for _, testcase := range []struct {
input string
output string
}{
{
"fooBar",
"foo-bar",
},
{
"WordACRONYMAnotherWord",
"word-acronym-another-word",
},
} {
got := camel2dash(testcase.input)
if testcase.output != got {
t.Fatalf("input: %s\n expected: %s\n got: %s",
testcase.input,
testcase.output,
got,
)
}
}
}