-
Notifications
You must be signed in to change notification settings - Fork 0
/
wagner_fischer_test.go
45 lines (40 loc) · 1.02 KB
/
wagner_fischer_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
package levenshtein
import (
"fmt"
"testing"
)
func TestFullMatrixDistance(t *testing.T) {
for _, test := range tests {
if d := FullMatrixDistance(test.A, test.B); d != test.D {
t.Errorf("FullMatrixDistance(%s, %s) = %d, want %d", test.A, test.B, d, test.D)
}
}
}
func BenchmarkFullMatrixDistance(b *testing.B) {
for _, test := range tests {
b.Run(fmt.Sprintf("%s_vs_%s", test.A, test.B), func(b *testing.B) {
for i := 0; i < b.N; i++ {
FullMatrixDistance(test.A, test.B)
}
})
}
}
func TestTwoRowsDistance(t *testing.T) {
// for _, test := range tests {
// if d := TwoRowsDistance(test.A, test.B); d != test.D {
// t.Errorf("TwoRowsDistance(%s, %s) = %d, want %d", test.A, test.B, d, test.D)
// }
// }
if TwoRowsDistance("sitting", "kitten") != 3 {
t.Error("Bruh")
}
}
func BenchmarkTwoRowsDistance(b *testing.B) {
for _, test := range tests {
b.Run(fmt.Sprintf("%s_vs_%s", test.A, test.B), func(b *testing.B) {
for i := 0; i < b.N; i++ {
TwoRowsDistance(test.A, test.B)
}
})
}
}