@@ -21,20 +21,44 @@ func (a sortByLen) Less(i, j int) bool {
21
21
return len (a [i ]) > len (a [j ])
22
22
}
23
23
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
+ },
27
41
}
28
42
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 ()
33
46
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
+ })
38
62
}
39
63
}
40
64
0 commit comments