-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring_case_test.go
88 lines (85 loc) · 2.23 KB
/
string_case_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
package tracer
import (
"fmt"
"testing"
)
func Test_Tracer_toStringCase(t *testing.T) {
testCases := []struct {
InputString string
ExpectedString string
}{
// Case 000 camel case to string case with lower start
{
InputString: "fooBar",
ExpectedString: "foo bar",
},
// Case 001 camel case to string case with lower start and longer input
{
InputString: "fooBarBazupKick",
ExpectedString: "foo bar bazup kick",
},
// Case 002 camel case to string case with upper start
{
InputString: "FooBar",
ExpectedString: "foo bar",
},
// Case 003 camel case to string case with upper start and longer input
{
InputString: "FooBarBazupKick",
ExpectedString: "foo bar bazup kick",
},
// Case 004 real private error kind
{
InputString: "authenticationError",
ExpectedString: "authentication error",
},
// Case 005 real public error kind
{
InputString: "AuthenticationError",
ExpectedString: "authentication error",
},
// Case 006 camel case with abbreviation at the start
{
InputString: "APINotAvailableError",
ExpectedString: "api not available error",
},
// Case 007 camel case with abbreviation in the middle
{
InputString: "invalidHTTPStatusError",
ExpectedString: "invalid http status error",
},
// Case 008 camel case with abbreviation at the end
{
InputString: "fooBarBAZ",
ExpectedString: "foo bar baz",
},
// Case 009 with version numbers at the start
{
InputString: "v2RouteNotReachable",
ExpectedString: "v2 route not reachable",
},
// Case 010 with version numbers in the middle
{
InputString: "oldV2RouteNotReachable",
ExpectedString: "old v2 route not reachable",
},
// Case 011 with version numbers in the middle
{
InputString: "oldV2RouteNotReachable",
ExpectedString: "old v2 route not reachable",
},
// Case 012 with version numbers at the end does not work
{
InputString: "statusCode200",
ExpectedString: "status code200",
},
}
for i, tc := range testCases {
t.Run(fmt.Sprintf("%03d", i), func(t *testing.T) {
output := toStringCase(tc.InputString)
if output != tc.ExpectedString {
t.Fatalf("expected %#v got %#v", tc.ExpectedString, output)
}
})
}
}