diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/testCellBuffer.cxx | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/unit/testCellBuffer.cxx b/test/unit/testCellBuffer.cxx index 690611d2f..b44f47735 100644 --- a/test/unit/testCellBuffer.cxx +++ b/test/unit/testCellBuffer.cxx @@ -72,6 +72,58 @@ TEST_CASE("CellBuffer") { REQUIRE(!cb.CanRedo()); } + SECTION("LineEnds") { + // Check that various line ends produce correct result from LineEnd. + cb.SetLineEndTypes(LineEndType::Unicode); + bool startSequence = false; + { + // Unix \n + const char sText2[] = "Two\nLines"; + const Sci::Position sLength2 = static_cast<Sci::Position>(strlen(sText2)); + cb.InsertString(0, sText2, strlen(sText2), startSequence); + REQUIRE(3 == cb.LineEnd(0)); + REQUIRE(sLength2 == cb.LineEnd(1)); + cb.DeleteChars(0, sLength2, startSequence); + } + { + // Windows \r\n + const char sText2[] = "Two\r\nLines"; + const Sci::Position sLength2 = static_cast<Sci::Position>(strlen(sText2)); + cb.InsertString(0, sText2, sLength2, startSequence); + REQUIRE(3 == cb.LineEnd(0)); + REQUIRE(sLength2 == cb.LineEnd(1)); + cb.DeleteChars(0, sLength2, startSequence); + } + { + // Old macOS \r + const char sText2[] = "Two\rLines"; + const Sci::Position sLength2 = static_cast<Sci::Position>(strlen(sText2)); + cb.InsertString(0, sText2, strlen(sText2), startSequence); + REQUIRE(3 == cb.LineEnd(0)); + REQUIRE(sLength2 == cb.LineEnd(1)); + cb.DeleteChars(0, sLength2, startSequence); + } + { + // Unicode NEL is U+0085 \xc2\x85 + const char sText2[] = "Two\xc2\x85Lines"; + const Sci::Position sLength2 = static_cast<Sci::Position>(strlen(sText2)); + cb.InsertString(0, sText2, sLength2, startSequence); + REQUIRE(3 == cb.LineEnd(0)); + REQUIRE(sLength2 == cb.LineEnd(1)); + cb.DeleteChars(0, sLength2, startSequence); + } + { + // Unicode LS line separator is U+2028 \xe2\x80\xa8 + const char sText2[] = "Two\xe2\x80\xa8Lines"; + const Sci::Position sLength2 = static_cast<Sci::Position>(strlen(sText2)); + cb.InsertString(0, sText2, sLength2, startSequence); + REQUIRE(3 == cb.LineEnd(0)); + REQUIRE(sLength2 == cb.LineEnd(1)); + cb.DeleteChars(0, sLength2, startSequence); + } + cb.SetLineEndTypes(LineEndType::Default); + } + SECTION("UndoOff") { REQUIRE(cb.IsCollectingUndo()); cb.SetUndoCollection(false); |