diff options
author | Neil <nyamatongwe@gmail.com> | 2024-01-29 21:33:25 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2024-01-29 21:33:25 +1100 |
commit | 72689db0d549c0cb850012546c71117ea74c2f2c (patch) | |
tree | 0db42ea99f461955c02d4a1754cfd8455112ea51 | |
parent | 7205b15e0c2cb4faf1ba41716a21187a0a2fc184 (diff) | |
download | scintilla-mirror-72689db0d549c0cb850012546c71117ea74c2f2c.tar.gz |
Add tests for an undo history with only container actions and 2 levels of undo
group nesting.
-rw-r--r-- | test/unit/testCellBuffer.cxx | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/test/unit/testCellBuffer.cxx b/test/unit/testCellBuffer.cxx index 8e9711843..5e5b0b138 100644 --- a/test/unit/testCellBuffer.cxx +++ b/test/unit/testCellBuffer.cxx @@ -351,6 +351,16 @@ TEST_CASE("UndoHistory") { } + SECTION("SimpleContainer") { + bool startSequence = false; + const char *val = uh.AppendAction(ActionType::container, 1000, nullptr, 0, startSequence, true); + REQUIRE(startSequence); + REQUIRE(!val); + val = uh.AppendAction(ActionType::container, 1001, nullptr, 0, startSequence, true); + REQUIRE(!startSequence); + REQUIRE(!val); + } + SECTION("CoalesceContainer") { bool startSequence = false; const char *val = uh.AppendAction(ActionType::insert, 0, "ab", 2, startSequence, true); @@ -360,14 +370,14 @@ TEST_CASE("UndoHistory") { REQUIRE(!startSequence); // container actions do not have text data, just the token store in position REQUIRE(!val); - val = uh.AppendAction(ActionType::container, 1001, nullptr, 0, startSequence, true); + uh.AppendAction(ActionType::container, 1001, nullptr, 0, startSequence, true); REQUIRE(!startSequence); // This is a coalescible change since the container actions are skipped to determine compatibility val = uh.AppendAction(ActionType::insert, 2, "cd", 2, startSequence, true); REQUIRE(memcmp(val, "cd", 2) == 0); REQUIRE(!startSequence); // Break the sequence with a non-coalescible container action - val = uh.AppendAction(ActionType::container, 1002, nullptr, 0, startSequence, false); + uh.AppendAction(ActionType::container, 1002, nullptr, 0, startSequence, false); REQUIRE(startSequence); { @@ -461,6 +471,32 @@ TEST_CASE("UndoHistory") { } + SECTION("DeepGroup") { + + uh.BeginUndoAction(); + uh.BeginUndoAction(); + + bool startSequence = false; + const char *val = uh.AppendAction(ActionType::insert, 0, "ab", 2, startSequence, true); + REQUIRE(memcmp(val, "ab", 2) == 0); + REQUIRE(startSequence); + val = uh.AppendAction(ActionType::container, 1000, nullptr, 0, startSequence, false); + REQUIRE(!val); + REQUIRE(!startSequence); + val = uh.AppendAction(ActionType::remove, 0, "ab", 2, startSequence, true); + REQUIRE(memcmp(val, "ab", 2) == 0); + REQUIRE(!startSequence); + val = uh.AppendAction(ActionType::insert, 0, "cde", 3, startSequence, true); + REQUIRE(memcmp(val, "cde", 3) == 0); + REQUIRE(!startSequence); + + uh.EndUndoAction(); + uh.EndUndoAction(); + + const int steps = uh.StartUndo(); + REQUIRE(steps == 4); + } + SECTION("Tentative") { REQUIRE(!uh.TentativeActive()); @@ -1404,4 +1440,4 @@ TEST_CASE("CellBufferLong") { } } } -#endif
\ No newline at end of file +#endif |