-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspelling_test.go
54 lines (42 loc) · 1.11 KB
/
spelling_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
package spellingcorrector
import (
"os"
"path"
"testing"
)
func newSpelling(t *testing.T) *Spelling {
currentPath, err := os.Getwd()
if err != nil {
t.Error(err)
}
dictionaryFilePath := path.Join(currentPath, "dictionaries", "es.dic")
spelling, err := NewSpelling(dictionaryFilePath)
if err != nil {
t.Error(err)
}
return spelling
}
func TestShortWordCorrected(t *testing.T) {
spelling := newSpelling(t)
if spelling.Correction("espanol") != "español" {
t.Error("Expected returned string to be 'español'")
}
}
func TestShortWordNotCorrected(t *testing.T) {
spelling := newSpelling(t)
if spelling.Correction("jorge") != "jorge" {
t.Error("Expected returned string to be 'jorge'")
}
}
func TestCorrectedLongWord(t *testing.T) {
spelling := newSpelling(t)
if spelling.Correction("aritocraticamente") != "aristocráticamente" {
t.Error("Expected returned string to be 'aristocráticamente'")
}
}
func TestNotCorrectedLongWord(t *testing.T) {
spelling := newSpelling(t)
if spelling.Correction("calculadorase") != "calculadorase" {
t.Error("Expected returned string to be 'calculadorase'")
}
}