diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-07-18 12:14:52 +0200 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-07-18 12:14:52 +0200 |
| commit | 50fec8674970fa1c4e9c9590756a155aded7edb5 (patch) | |
| tree | 9ef977029df928e8d3f01e1aa121aca8975d78fb /src/unit_tests.cc | |
| parent | 793c2ed9cfe2629c417a7fbb218712ff4f03ec9e (diff) | |
Change diff Implementation to use end indices instead of length
Having absolute begin and relative lenght was a bit strange to
work with. Rename middle_snake to snake.
Diffstat (limited to 'src/unit_tests.cc')
| -rw-r--r-- | src/unit_tests.cc | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/unit_tests.cc b/src/unit_tests.cc index 68518b51..c2fe1fa6 100644 --- a/src/unit_tests.cc +++ b/src/unit_tests.cc @@ -30,16 +30,28 @@ UnitTest test_diff{[]() } { - StringView s1 = "a?"; - StringView s2 = "!"; - - auto diff = find_diff(s1.begin(), (int)s1.length(), s2.begin(), (int)s2.length()); - + auto diff = find_diff("a?", 2, "!", 1); kak_assert(diff.size() == 3 and eq(diff[0], {Diff::Remove, 1, 0}) and eq(diff[1], {Diff::Add, 1, 0}) and eq(diff[2], {Diff::Remove, 1, 0})); } + + { + auto diff = find_diff("abcd", 4, "c", 1); + kak_assert(diff.size() == 3 and + eq(diff[0], {Diff::Remove, 2, 0}) and + eq(diff[1], {Diff::Keep, 1, 0}) and + eq(diff[2], {Diff::Remove, 1, 0})); + } + + { + auto diff = find_diff("abcd", 4, "cdef", 4); + kak_assert(diff.size() == 3 and + eq(diff[0], {Diff::Remove, 2, 0}) and + eq(diff[1], {Diff::Keep, 2, 0}) and + eq(diff[2], {Diff::Add, 2, 2})); + } }}; UnitTest* UnitTest::list = nullptr; |
