From 0d75d5544f21ecf2dca49af04b3467ccea4ab8db Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 4 Oct 2023 14:48:19 +1100 Subject: Preparatory changes for fix in next commit. Does not change Scintilla behaviour. Add tests for contiguous deletions in forward and backward directions. Use symbolic edition values. Rename InsertionSpan to ChangeSpan and insertions to changes as holds both insertions and deletions. Add ChangeStack::Check. Add comments. --- test/unit/testCellBuffer.cxx | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'test/unit/testCellBuffer.cxx') diff --git a/test/unit/testCellBuffer.cxx b/test/unit/testCellBuffer.cxx index cb69e7756..f7795c9e7 100644 --- a/test/unit/testCellBuffer.cxx +++ b/test/unit/testCellBuffer.cxx @@ -633,6 +633,55 @@ TEST_CASE("ChangeHistory") { } REQUIRE(il.DeletionCount(0, 10) == 0); REQUIRE(il.Length() == 10); + + } + + SECTION("Delete Contiguous Backward") { + // Deletes that touch + constexpr size_t length = 20; + constexpr size_t rounds = 8; + il.Insert(0, length, false, true); + REQUIRE(il.Length() == length); + il.SetSavePoint(); + for (size_t i = 0; i < rounds; i++) { + il.DeleteRangeSavingHistory(9-i, 1, false, false); + } + + constexpr size_t lengthAfterDeletions = length - rounds; + REQUIRE(il.Length() == lengthAfterDeletions); + REQUIRE(il.DeletionCount(0, lengthAfterDeletions) == rounds); + + for (size_t j = 0; j < rounds; j++) { + il.UndoDeleteStep(2+j, 1, false); + } + + // Restored to original + REQUIRE(il.DeletionCount(0, length) == 0); + REQUIRE(il.Length() == length); + } + + SECTION("Delete Contiguous Forward") { + // Deletes that touch + constexpr size_t length = 20; + constexpr size_t rounds = 8; + il.Insert(0, length, false, true); + REQUIRE(il.Length() == length); + il.SetSavePoint(); + for (size_t i = 0; i < rounds; i++) { + il.DeleteRangeSavingHistory(2,1, false, false); + } + + constexpr size_t lengthAfterDeletions = length - rounds; + REQUIRE(il.Length() == lengthAfterDeletions); + REQUIRE(il.DeletionCount(0, lengthAfterDeletions) == rounds); + + for (size_t j = 0; j < rounds; j++) { + il.UndoDeleteStep(2, 1, false); + } + + // Restored to original + REQUIRE(il.Length() == length); + REQUIRE(il.DeletionCount(0, length) == 0); } } -- cgit v1.2.3