-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstr_test.go
More file actions
75 lines (73 loc) · 1.29 KB
/
str_test.go
File metadata and controls
75 lines (73 loc) · 1.29 KB
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
package jsoncase
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestStrConvert(t *testing.T) {
testCases := []struct {
name string
testFunc func(string) string
input string
expected string
}{
{
name: "snake",
testFunc: toSnakeString,
input: "",
expected: "",
},
{
name: "camel",
testFunc: toCamelString,
input: "",
expected: "",
},
{
name: "pascal",
testFunc: toPascalString,
input: "",
expected: "",
},
{
name: "snake",
testFunc: toSnakeString,
input: "camelCase",
expected: "camel_case",
},
{
name: "snake",
testFunc: toSnakeString,
input: "CamelCase",
expected: "camel_case",
},
{
name: "camel",
testFunc: toCamelString,
input: "camel_case",
expected: "camelCase",
},
{
name: "camel",
testFunc: toCamelString,
input: "CamelCase",
expected: "camelCase",
},
{
name: "pascal",
testFunc: toPascalString,
input: "pascal_case",
expected: "PascalCase",
},
{
name: "pascal",
testFunc: toPascalString,
input: "pascalCase",
expected: "PascalCase",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.expected, tc.testFunc(tc.input))
})
}
}