Elffuss BraidHub

kikocis/continue public

main · 1.0 KiBRawPermalink
1import { longestCommonSubsequence as lcs } from "./lcs";
2
3describe("longestCommonSubsequence", () => {
4 test("should return the longest common subsequence for non-empty strings", () => {
5 expect(lcs("abcde", "ace")).toBe("ace");
6 expect(lcs("abc", "abc")).toBe("abc");
7 expect(lcs("abc", "def")).toBe("");
8 });
9
10 test("should handle cases where one or both strings are empty", () => {
11 expect(lcs("", "abc")).toBe("");
12 expect(lcs("abc", "")).toBe("");
13 expect(lcs("", "")).toBe("");
14 });
15
16 test("should handle cases with no common subsequence", () => {
17 expect(lcs("abc", "def")).toBe("");
18 expect(lcs("xyz", "abc")).toBe("");
19 });
20
21 test("should handle cases with special characters", () => {
22 expect(lcs("a!@#b$c", "!@#$")).toBe("!@#$");
23 expect(lcs("a!@#b$c", "xyz")).toBe("");
24 });
25
26 test("should handle long strings efficiently", () => {
27 const str1 = "a".repeat(1000) + "b".repeat(1000);
28 const str2 = "a".repeat(1000) + "c".repeat(1000);
29 expect(lcs(str1, str2)).toBe("a".repeat(1000));
30 });
31});