-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsmithwaterman_test.go
More file actions
41 lines (38 loc) · 876 Bytes
/
smithwaterman_test.go
File metadata and controls
41 lines (38 loc) · 876 Bytes
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
package disfun
import "testing"
var swtests = []struct {
s1 string
s2 string
dist float64
}{
// insertion
{"car", "cars", 3.0},
// substitution
{"library", "librari", 6.0},
// deletion
{"library", "librar", 6.0},
// transposition
{"library", "librayr", 5.5},
// one empty, left
{"", "library", 7.0},
// one empty, right
{"library", "", 7.0},
// two empties
{"", "", 0.0},
// unicode stuff!
{"Schüßler", "Schübler", 6.0},
{"Ant Zucaro", "Anthony Zucaro", 8.0},
{"Schüßler", "Schüßler", 8.0},
{"Schßüler", "Schüßler", 6.0},
{"Schüßler", "Schüler", 6.5},
{"Schüßler", "Schüßlers", 8.0},
}
// Smith-Waterman
func TestSmithWaterman(t *testing.T) {
for _, tt := range swtests {
dist := SmithWaterman(tt.s1, tt.s2)
if dist != tt.dist {
t.Errorf("SmithWaterman('%s', '%s') = %v, want %v", tt.s1, tt.s2, dist, tt.dist)
}
}
}