-
Notifications
You must be signed in to change notification settings - Fork 3
/
hunspell_test.go
72 lines (43 loc) · 1.08 KB
/
hunspell_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package hunspell
import (
"testing"
)
func TestSuggest(t *testing.T) {
h := Hunspell("/usr/share/hunspell/en_US.aff", "/usr/share/hunspell/en_US.dic")
words := []string{
"aplez",
"yaho",
}
//
// TEST
for _, word := range words {
y := Spell(t, word, h)
if y {
t.Error(`"` + word + `" is now a valid word and should not be`)
}
s := h.Suggest(word)
for _, v := range s {
t.Log("suggestion: " + v)
}
}
}
func TestSpell(t *testing.T) {
h := Hunspell("/usr/share/hunspell/en_US.aff", "/usr/share/hunspell/en_US.dic")
y := Spell(t, "xerocole", h)
if y {
t.Error(`"xerocole is now a valid word and should not be in the dictionary"`)
}
t.Log(`Adding "xerocole" to Dictionary`)
b := h.Add("xerocole")
if !b {
t.Error(`Failed to Add "xerocole" to dictionary`)
}
y = Spell(t, "xerocole", h)
if !y {
t.Error(`"xerocole" is not a valid word after being added to dictionary`)
}
}
func Spell(t *testing.T, word string, h *Hunhandle) bool {
t.Log(`Testing "` + word + `"`)
return h.Spell(word)
}