-
Notifications
You must be signed in to change notification settings - Fork 1
/
tomgos_test.go
70 lines (65 loc) · 1.23 KB
/
tomgos_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
package tomgos
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestKeyToCamelCase(t *testing.T) {
testcases := []struct {
name string
input string
expected string
}{
{
name: "simple key",
input: "key",
expected: "Key",
},
{
name: "simple key with dash (-)",
input: "this-key",
expected: "ThisKey",
},
{
name: "simple key with underscore (_)",
input: "this_key",
expected: "ThisKey",
},
{
name: "simple key with number (0-9)",
input: "this-is-007",
expected: "ThisIs007",
},
{
name: "simple key with uppercase (A-Z)",
input: "wHatEvEr",
expected: "Whatever",
},
{
name: "dash first key",
input: "-key",
expected: "Key",
},
{
name: "underscore first key",
input: "_key",
expected: "Key",
},
{
name: "number first key",
input: "9key",
expected: "9key",
},
{
name: "complex key combination",
input: "-this-is_kINda-r4Nd0m-KEY",
expected: "ThisIsKindaR4nd0mKey",
},
}
assert := assert.New(t)
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
output := keyToCamelCase(tc.input)
assert.Equal(tc.expected, output)
})
}
}