forked from client9/misspell
-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
case_test.go
53 lines (46 loc) · 1.02 KB
/
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
package misspell
import (
"reflect"
"testing"
)
func TestCaseStyle(t *testing.T) {
testCases := []struct {
word string
want WordCase
}{
{word: "lower", want: CaseLower},
{word: "what's", want: CaseLower},
{word: "UPPER", want: CaseUpper},
{word: "Title", want: CaseTitle},
{word: "CamelCase", want: CaseUnknown},
{word: "camelCase", want: CaseUnknown},
}
for _, test := range testCases {
test := test
t.Run(test.word, func(t *testing.T) {
t.Parallel()
got := CaseStyle(test.word)
if test.want != got {
t.Errorf("want %v got %v", test.want, got)
}
})
}
}
func TestCaseVariations(t *testing.T) {
testCases := []struct {
word string
want []string
}{
{word: "that's", want: []string{"that's", "That's", "THAT'S"}},
}
for _, test := range testCases {
test := test
t.Run(test.word, func(t *testing.T) {
t.Parallel()
got := CaseVariations(test.word, CaseStyle(test.word))
if !reflect.DeepEqual(test.want, got) {
t.Errorf("want %v got %v", test.want, got)
}
})
}
}