aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2023-10-04 14:48:19 +1100
committerNeil <nyamatongwe@gmail.com>2023-10-04 14:48:19 +1100
commit0d75d5544f21ecf2dca49af04b3467ccea4ab8db (patch)
tree1c98be77a4891db5b11dae10d677cfcfb6282e52 /test
parent0f6ccb7a07532cf132c621c347e89c571bf171a9 (diff)
downloadscintilla-mirror-0d75d5544f21ecf2dca49af04b3467ccea4ab8db.tar.gz
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.
Diffstat (limited to 'test')
-rw-r--r--test/unit/testCellBuffer.cxx49
1 files changed, 49 insertions, 0 deletions
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);
}
}