-
Notifications
You must be signed in to change notification settings - Fork 2
/
string_test.go
78 lines (72 loc) · 1.19 KB
/
string_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
67
68
69
70
71
72
73
74
75
76
77
78
package easy
import (
"testing"
)
type custom struct {
input string
want string
}
var underscoreTests = []*custom{
{
input: "",
want: "",
},
{
input: "black_magician",
want: "black_magician",
},
{
input: "blackMagicianGirl",
want: "black_magician_girl",
},
{
input: "BlueEyesChaosMaxDragon",
want: "blue_eyes_chaos_max_dragon",
},
{
input: "appV1.1.0",
want: "app_v1.1.0",
},
{
input: "BlackMagician",
want: "black_magician",
},
}
func TestUnderscore(t *testing.T) {
for _, test := range underscoreTests {
got := Underscore(test.input)
if got != test.want {
t.Errorf("Underscore(%s) = %s, want %s", test.input, got, test.want)
}
}
}
var camelTests = []*custom{
{
input: "",
want: "",
},
{
input: "black_magician",
want: "blackMagician",
},
{
input: "black_magician_girl",
want: "blackMagicianGirl",
},
{
input: "blue_eyes_chaos_max_dragon",
want: "blueEyesChaosMaxDragon",
},
{
input: "app_v1.1.0",
want: "appV1.1.0",
},
}
func TestCamel(t *testing.T) {
for _, test := range camelTests {
got := Camel(test.input)
if got != test.want {
t.Errorf("Camel(%s) = %s, want %s", test.input, got, test.want)
}
}
}