Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita0ca3dd

Browse files
committed
tests: all dicts sorted
1 parent2a80c07 commita0ca3dd

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
returnlen(a[i])>len(a[j])
2222
}
2323

24-
funcTest_wordSort(t*testing.T) {
25-
iflen(DictMain)%2==1 {
26-
t.Errorf("Dictionary is a not a multiple of 2")
24+
funcTest_word_sort(t*testing.T) {
25+
testCases:= []struct {
26+
descstring
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-
fori:=0;i<len(DictMain);i+=2 {
31-
words=append(words,DictMain[i])
32-
}
43+
for_,test:=rangetestCases {
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+
iflen(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+
fori:=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)

[8]ページ先頭

©2009-2025 Movatter.jp