forked from paul-mannino/go-fuzzywuzzy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stringutility_test.go
52 lines (45 loc) · 1.08 KB
/
stringutility_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
package fuzzy
import (
"testing"
)
var asciiOnlyData = [][]interface{}{
{"one", "one"},
{"Țwo", "wo"},
{"three three!", "three three!"},
{"ǩƱ©", ""},
{"123ABC", "123ABC"},
}
var cleanseData = [][]interface{}{
{" OnE ", "one", "one"},
{"Țw o", "țw o", "w o"},
{"ǩƱ©", "ǩʊ ", ""},
{"ABC123", "abc123", "abc123"},
}
func TestASCIIOnly(t *testing.T) {
for _, testCase := range asciiOnlyData {
actual := ASCIIOnly(testCase[0].(string))
expected := testCase[1]
if actual != expected {
t.Errorf("Ascii-only %v: Expected %v, got %v.",
testCase[0], expected, actual)
}
}
}
func TestCleanse(t *testing.T) {
for _, testCase := range cleanseData {
actual := Cleanse(testCase[0].(string), false)
expected := testCase[1]
if actual != expected {
t.Errorf("Cleanse %v: Expected %v, got %v.",
testCase[0], expected, actual)
}
}
for _, testCase := range cleanseData {
actual := Cleanse(testCase[0].(string), true)
expected := testCase[2]
if actual != expected {
t.Errorf("Cleanse %v: Expected %v, got %v.",
testCase[0], expected, actual)
}
}
}