-
Notifications
You must be signed in to change notification settings - Fork 73
/
definition_name_test.go
94 lines (85 loc) · 2.69 KB
/
definition_name_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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package restfulspec
import (
"testing"
)
func TestGoLowerCamelCasedNameHandler_DefaultDefinitionName(t *testing.T) {
testCases := []struct {
name string
input string
excepted string
}{
{"go normal case", "GoRestfulDefinition", "goRestfulDefinition"},
{"go ID case", "IDForA", "idForA"},
{"go HTTP case", "HTTPName", "httpName"},
{"go HTTPS case", "HTTPSName", "httpsName"},
{"go HTTP with Started name case", "HTTPStatus", "httpStatus"},
{"simpleWord", "I", "i"},
{"simpleLowerWord", "i", "i"},
}
for _, testCase := range testCases {
output := GoLowerCamelCasedNameHandler(testCase.input)
if output != testCase.excepted {
t.Errorf("testing %s failed, expected %s, get %s", testCase.name, testCase.excepted, output)
}
}
}
func TestLowerCamelCasedNameHandler_DefaultDefinitionName(t *testing.T) {
testCases := []struct {
name string
input string
excepted string
}{
{"go normal case", "GoRestfulDefinition", "goRestfulDefinition"},
{"go ID case", "IDForA", "iDForA"},
{"go HTTP case", "HTTPName", "hTTPName"},
{"go HTTPS case", "HTTPSName", "hTTPSName"},
{"go HTTP with Started name case", "HTTPStatus", "hTTPStatus"},
{"simpleWord", "I", "i"},
{"simpleLowerWord", "i", "i"},
}
for _, testCase := range testCases {
output := LowerCamelCasedNameHandler(testCase.input)
if output != testCase.excepted {
t.Errorf("testing %s failed, expected %s, get %s", testCase.name, testCase.excepted, output)
}
}
}
func TestDefaultNameHandler_DefaultDefinitionName(t *testing.T) {
testCases := []struct {
name string
input string
excepted string
}{
{"go normal case", "GoRestfulDefinition", "GoRestfulDefinition"},
{"go ID case", "IDForA", "IDForA"},
{"go HTTP case", "HTTPName", "HTTPName"},
{"go HTTPS case", "HTTPSName", "HTTPSName"},
{"go HTTP with Started name case", "HTTPStatus", "HTTPStatus"},
{"simpleWord", "I", "I"},
{"simpleLowerWord", "i", "i"},
}
for _, testCase := range testCases {
output := DefaultNameHandler(testCase.input)
if output != testCase.excepted {
t.Errorf("testing %s failed, expected %s, get %s", testCase.name, testCase.excepted, output)
}
}
}
func TestLowerSnakeCasedNameHandler_DefaultDefinitionName(t *testing.T) {
testCases := []struct {
name string
input string
excepted string
}{
{"go normal case", "GoRestfulDefinition", "go_restful_definition"},
{"go ID case", "IDForA", "i_d_for_a"},
{"simpleWord", "I", "i"},
{"simpleLowerWord", "i", "i"},
}
for _, testCase := range testCases {
output := LowerSnakeCasedNameHandler(testCase.input)
if output != testCase.excepted {
t.Errorf("testing %s failed, expected %s, get %s", testCase.name, testCase.excepted, output)
}
}
}