Skip to content

Commit

Permalink
test(text): add more testcases for levenshteinDistance (denoland#5528)
Browse files Browse the repository at this point in the history
* test(text): add more testcases for `levenshteinDistance`

* clean

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
  • Loading branch information
0f-0b and iuioiua authored Jul 23, 2024
1 parent 044fc27 commit 2e542ff
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions text/levenshtein_distance_test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "@std/assert";
import { levenshteinDistance } from "./mod.ts";
import { assertEquals } from "@std/assert/equals";
import { levenshteinDistance } from "./levenshtein_distance.ts";

Deno.test("levenshteinDistance() handles basic cases", function () {
assertEquals(
levenshteinDistance("aa", "bb"),
2,
);
Deno.test("levenshteinDistance() handles basic cases", () => {
assertEquals(levenshteinDistance("levenshtein", "levenshtein"), 0);
assertEquals(levenshteinDistance("sitting", "kitten"), 3);
assertEquals(levenshteinDistance("gumbo", "gambol"), 2);
assertEquals(levenshteinDistance("saturday", "sunday"), 3);
assertEquals(levenshteinDistance("aarrgh", "aargh"), 1);
assertEquals(levenshteinDistance("aargh", "aarrgh"), 1);
});

Deno.test("levenshteinDistance() handles empty strings", () => {
assertEquals(levenshteinDistance("", "a"), 1);
assertEquals(levenshteinDistance("a", ""), 1);
assertEquals(levenshteinDistance("", ""), 0);
});

Deno.test("levenshteinDistance() handles same strings", function () {
Deno.test("levenshteinDistance() handles long strings", () => {
assertEquals(
levenshteinDistance("aa", "aa"),
0,
levenshteinDistance(
"the quick brown fox jumps over the lazy dog",
"the lazy dog is jumped over by the quick brown fox",
),
30,
);
});

0 comments on commit 2e542ff

Please sign in to comment.