Skip to content

Commit a0ca3dd

Browse files
committed
tests: all dicts sorted
1 parent 2a80c07 commit a0ca3dd

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

cmd/misspell/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func main() {
124124
case "UK", "GB":
125125
r.AddRuleList(misspell.DictBritish)
126126
case "NZ", "AU", "CA":
127-
log.Fatalf("Help wanted. https://github.com/client9/misspell/issues/6")
127+
log.Fatalf("Help wanted.")
128128
default:
129129
log.Fatalf("Unknown locale: %q", *locale)
130130
}

words_test.go

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,44 @@ func (a sortByLen) Less(i, j int) bool {
2121
return len(a[i]) > len(a[j])
2222
}
2323

24-
func Test_wordSort(t *testing.T) {
25-
if len(DictMain)%2 == 1 {
26-
t.Errorf("Dictionary is a not a multiple of 2")
24+
func Test_word_sort(t *testing.T) {
25+
testCases := []struct {
26+
desc string
27+
dict []string
28+
}{
29+
{
30+
desc: "main",
31+
dict: DictMain,
32+
},
33+
{
34+
desc: "US",
35+
dict: DictAmerican,
36+
},
37+
{
38+
desc: "UK",
39+
dict: DictBritish,
40+
},
2741
}
2842

29-
words := make([]string, 0, len(DictMain)/2)
30-
for i := 0; i < len(DictMain); i += 2 {
31-
words = append(words, DictMain[i])
32-
}
43+
for _, test := range testCases {
44+
t.Run(test.desc, func(t *testing.T) {
45+
t.Parallel()
3346

34-
if !sort.IsSorted(sortByLen(words)) {
35-
t.Errorf("Words not sorted by len, by alpha!")
36-
t.Errorf("Words.go is autogenerated -- do not edit.")
37-
t.Errorf("File issue instead.")
47+
if len(test.dict)%2 == 1 {
48+
t.Errorf("Dictionary is a not a multiple of 2")
49+
}
50+
51+
words := make([]string, 0, len(test.dict)/2)
52+
for i := 0; i < len(test.dict); i += 2 {
53+
words = append(words, test.dict[i])
54+
}
55+
56+
if !sort.IsSorted(sortByLen(words)) {
57+
t.Errorf("Words not sorted by len, by alpha!")
58+
t.Errorf("Words.go is autogenerated -- do not edit.")
59+
t.Errorf("File issue instead.")
60+
}
61+
})
3862
}
3963
}
4064

0 commit comments

Comments
 (0)