From f8d43222b539aed116772c21a626e153c44ad0a5 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 06:04:46 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Add=20unit=20tests=20for=20diff?= =?UTF-8?q?=5Fmatch=5Fpatch.diff=5FcommonPrefix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement comprehensive unit tests for the `diff_commonPrefix` method in `DiffMatchPatch.cs`. Scenarios covered: - Empty strings - No common prefix - Complete match (identical strings) - Partial common prefix - One string is a prefix of another - Case sensitivity - Unicode support The tests are implemented in a new file `tests/DiffMatchPatchTests.cs` using xUnit. Co-authored-by: thezaza101 <27200279+thezaza101@users.noreply.github.com> --- tests/DiffMatchPatchTests.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/DiffMatchPatchTests.cs diff --git a/tests/DiffMatchPatchTests.cs b/tests/DiffMatchPatchTests.cs new file mode 100644 index 0000000..3a3ca81 --- /dev/null +++ b/tests/DiffMatchPatchTests.cs @@ -0,0 +1,27 @@ +using System; +using Xunit; +using textdiffcore.TextDiffEngine.GoogleMyers; + +namespace tests +{ + public class DiffMatchPatchTests + { + [Theory] + [InlineData("", "", 0)] + [InlineData("abc", "", 0)] + [InlineData("", "abc", 0)] + [InlineData("abc", "abc", 3)] + [InlineData("abc", "abd", 2)] + [InlineData("abcdef", "abc", 3)] + [InlineData("abc", "abcdef", 3)] + [InlineData("ABC", "abc", 0)] + [InlineData("a\u0300", "a\u0300", 2)] + [InlineData("a\u0300", "a", 1)] + [InlineData("hello world", "hello friend", 6)] + public void TestDiffCommonPrefix(string text1, string text2, int expected) + { + var dmp = new diff_match_patch(); + Assert.Equal(expected, dmp.diff_commonPrefix(text1, text2)); + } + } +}