summaryrefslogtreecommitdiff
path: root/distance_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'distance_test.go')
-rw-r--r--distance_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/distance_test.go b/distance_test.go
new file mode 100644
index 0000000..50810fa
--- /dev/null
+++ b/distance_test.go
@@ -0,0 +1,28 @@
+package lavenshtein
+
+import "testing"
+
+func TestDistance(t *testing.T) {
+ testCases := []struct {
+ a, b string
+ dist int
+ }{
+ {"", "", 0},
+ {"aa", "aa", 0},
+ {"aa", "ab", 1},
+ {"aa", "ba", 1},
+ {"aa", "bb", 2},
+ {"aa", "", 2},
+ {"", "bb", 2},
+ {"test", "Test", 1},
+ {"тест", "Тест", 1},
+ }
+ for _, tc := range testCases {
+ t.Run(tc.a+" "+tc.b, func(t *testing.T) {
+ dist := Distance(tc.a, tc.b)
+ if dist != tc.dist {
+ t.Errorf("got %v, want %v", dist, tc.dist)
+ }
+ })
+ }
+}