-
Notifications
You must be signed in to change notification settings - Fork 16
/
formatChecks_test.go
87 lines (80 loc) · 2.19 KB
/
formatChecks_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
package linter
import (
"testing"
)
func Test_isCamelCase(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
want bool
}{
{"snake case", args{"hello_world"}, false},
{"screaming snake case", args{"HELLO_WORLD"}, false},
{"dromedary case", args{"helloWorld"}, false},
{"lower case", args{"helloworld"}, false},
{"screeming", args{"HELLOWORLD"}, false},
{"Pascal case", args{"HelloWorld"}, true},
{"dromedary case with first a signel leading alpha", args{"h264"}, false},
{"Pascal case with a single leading alpha", args{"H264"}, true},
{"Pascal case with some numbers after a leading alpha", args{"H264Encoded"}, true},
{"screeming with some numbers after a leading alpha", args{"H264ENCODED"}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := isCamelCase(tt.args.s); got != tt.want {
t.Errorf("isCamelCase() = %v, want %v", got, tt.want)
}
})
}
}
func Test_isLowerUnderscore(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
want bool
}{
{"snake case", args{"hello_world"}, true},
{"screaming snake case", args{"HELLO_WORLD"}, false},
{"dromedary case", args{"helloWorld"}, false},
{"lower case", args{"helloworld"}, true},
{"screaming", args{"HELLOWORLD"}, false},
{"Pascal case ", args{"HelloWorld"}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := isLowerUnderscore(tt.args.s); got != tt.want {
t.Errorf("isLowerUnderscore(() = %v, want %v", got, tt.want)
}
})
}
}
func Test_isUpperUnderscore(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
want bool
}{
{"snake case", args{"hello_world"}, false},
{"screaming snake case", args{"HELLO_WORLD"}, true},
{"dromedary case", args{"helloWorld"}, false},
{"lower case", args{"helloworld"}, false},
{"screaming", args{"HELLOWORLD"}, true},
{"Pascal case ", args{"HelloWorld"}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := isUpperUnderscore(tt.args.s); got != tt.want {
t.Errorf("sUpperUnderscore(() = %v, want %v", got, tt.want)
}
})
}
}