-
Notifications
You must be signed in to change notification settings - Fork 26
/
soundex_test.go
54 lines (51 loc) · 1.1 KB
/
soundex_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 matchr
import "testing"
// test cases from http://rosettacode.org/wiki/Soundex#F.23
var soundextests = []struct {
s1 string
soundex string
}{
{"Ashcraft", "A261"},
{"Ashhhcraft", "A261"},
{"Ashcroft", "A261"},
{"Burroughs", "B620"},
{"Burrows", "B620"},
{"Ekzampul", "E251"},
{"Example", "E251"},
{"Ellery", "E460"},
{"Euler", "E460"},
{"Ghosh", "G200"},
{"Gauss", "G200"},
{"Gutierrez", "G362"},
{"Heilbronn", "H416"},
{"Hilbert", "H416"},
{"Jackson", "J250"},
{"Kant", "K530"},
{"Knuth", "K530"},
{"Lee", "L000"},
{"Lukasiewicz", "L222"},
{"Lissajous", "L222"},
{"Ladd", "L300"},
{"Lloyd", "L300"},
{"Moses", "M220"},
{"O'Hara", "O600"},
{"Pfister", "P236"},
{"Rubin", "R150"},
{"Robert", "R163"},
{"Rupert", "R163"},
{"Soundex", "S532"},
{"Sownteks", "S532"},
{"Tymczak", "T522"},
{"VanDeusen", "V532"},
{"Washington", "W252"},
{"Wheaton", "W350"},
}
// Soundex
func TestSoundex(t *testing.T) {
for _, tt := range soundextests {
soundex := Soundex(tt.s1)
if soundex != tt.soundex {
t.Errorf("Soundex('%s') = %v, want %v", tt.s1, soundex, tt.soundex)
}
}
}