forked from Khan/genqlient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_test.go
65 lines (56 loc) · 1.45 KB
/
util_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
package generate
import "testing"
type test struct {
name string
in string
out string
}
func testStringFunc(t *testing.T, f func(string) string, tests []test) {
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
got := f(test.in)
if got != test.out {
t.Errorf("got %#v want %#v", got, test.out)
}
})
}
}
func TestLowerFirst(t *testing.T) {
tests := []test{
{"Empty", "", ""},
{"SingleLower", "l", "l"},
{"SingleUpper", "L", "l"},
{"SingleUnicodeLower", "ļ", "ļ"},
{"SingleUnicodeUpper", "Ļ", "ļ"},
{"LongerLower", "lasdf", "lasdf"},
{"LongerUpper", "Lasdf", "lasdf"},
{"LongerUnicodeLower", "ļasdf", "ļasdf"},
{"LongerUnicodeUpper", "Ļasdf", "ļasdf"},
}
testStringFunc(t, lowerFirst, tests)
}
func TestUpperFirst(t *testing.T) {
tests := []test{
{"Empty", "", ""},
{"SingleLower", "l", "L"},
{"SingleUpper", "L", "L"},
{"SingleUnicodeLower", "ļ", "Ļ"},
{"SingleUnicodeUpper", "Ļ", "Ļ"},
{"LongerLower", "lasdf", "Lasdf"},
{"LongerUpper", "Lasdf", "Lasdf"},
{"LongerUnicodeLower", "ļasdf", "Ļasdf"},
{"LongerUnicodeUpper", "Ļasdf", "Ļasdf"},
}
testStringFunc(t, upperFirst, tests)
}
func TestGoConstName(t *testing.T) {
tests := []test{
{"Empty", "", ""},
{"AllCaps", "ASDF", "Asdf"},
{"AllCapsWithUnderscore", "ASDF_GH", "AsdfGh"},
{"JustUnderscore", "_", "_"},
{"LeadingUnderscore", "_ASDF_GH", "AsdfGh"},
}
testStringFunc(t, goConstName, tests)
}