forked from client9/misspell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
case_test.go
42 lines (38 loc) · 817 Bytes
/
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
package misspell
import (
"reflect"
"testing"
)
func TestCaseStyle(t *testing.T) {
cases := []struct {
word string
want WordCase
}{
{"lower", CaseLower},
{"what's", CaseLower},
{"UPPER", CaseUpper},
{"Title", CaseTitle},
{"CamelCase", CaseUnknown},
{"camelCase", CaseUnknown},
}
for pos, tt := range cases {
got := CaseStyle(tt.word)
if tt.want != got {
t.Errorf("Case %d %q: want %v got %v", pos, tt.word, tt.want, got)
}
}
}
func TestCaseVariations(t *testing.T) {
cases := []struct {
word string
want []string
}{
{"that's", []string{"that's", "That's", "THAT'S"}},
}
for pos, tt := range cases {
got := CaseVariations(tt.word, CaseStyle(tt.word))
if !reflect.DeepEqual(tt.want, got) {
t.Errorf("Case %d %q: want %v got %v", pos, tt.word, tt.want, got)
}
}
}