-
Notifications
You must be signed in to change notification settings - Fork 5
/
metaphone3_utils_test.go
63 lines (53 loc) · 1.84 KB
/
metaphone3_utils_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
package metaphone3
import "testing"
func TestStringAt_Basic(t *testing.T) {
if want, got := true, testStringAt("TESTING", 0, 1, "B", "E"); want != got {
t.Fatalf("StringAt error, wanted %v got %v", want, got)
}
}
func TestStringAt_Calver(t *testing.T) {
if want, got := true, testStringAt("CALVER", 2, -2, "POLKA", "PALKO", "HALVA", "HALVO", "SALVER", "CALVER"); want != got {
t.Fatalf("StringAt error, wanted %v got %v", want, got)
}
}
func TestStringStart_Basic(t *testing.T) {
if want, got := true, testStringStart("TESTING", 1, "B", "E", "TEST"); want != got {
t.Fatalf("StringStart error, wanted %v got %v", want, got)
}
}
func TestStringAtEnd_Basic(t *testing.T) {
if want, got := true, testStringAtEnd("TESTING", 1, 2, "B", "E", "TING"); want != got {
t.Fatalf("StringStart error, wanted %v got %v", want, got)
}
if want, got := true, testStringAtEnd("JOSE", 0, 1, "OSE"); want != got {
t.Fatalf("StringStart error, wanted %v got %v", want, got)
}
}
func TestRootOrInflections_Basic(t *testing.T) {
if want, got := true, rootOrInflections([]rune("CHRISTENING"), "CHRISTEN"); want != got {
t.Fatalf("rootOrInflections error, Wanted %v, got %v", want, got)
}
}
func TestRootOrInflections_Ache(t *testing.T) {
if want, got := true, rootOrInflections([]rune("ACHY"), "ACHE"); want != got {
t.Fatalf("rootOrInflections error, Wanted %v, got %v", want, got)
}
}
func testStringAt(in string, curIdx, offset int, vals ...string) bool {
e := &Encoder{}
e.in = []rune(in)
e.idx = curIdx
return e.stringAt(offset, vals...)
}
func testStringStart(in string, curIdx int, vals ...string) bool {
e := &Encoder{}
e.in = []rune(in)
e.idx = curIdx
return e.stringStart(vals...)
}
func testStringAtEnd(in string, curIdx, offset int, vals ...string) bool {
e := &Encoder{}
e.in = []rune(in)
e.idx = curIdx
return e.stringAtEnd(offset, vals...)
}