diff options
author | Zufu Liu <unknown> | 2025-07-03 08:23:26 +1000 |
---|---|---|
committer | Zufu Liu <unknown> | 2025-07-03 08:23:26 +1000 |
commit | cde12528a7e587833926354b88ad1974aedaf103 (patch) | |
tree | a6b75dc168997106346dafdd8a424d44949c29f1 /test/unit/testSelection.cxx | |
parent | 181b13c2eed7499d192d0b85c7269dc7ab71336b (diff) | |
download | scintilla-mirror-cde12528a7e587833926354b88ad1974aedaf103.tar.gz |
Feature [feature-requests:#1563]. Move main range in selection serialized form.master
Avoid processing characters multiple times by relying on from_chars munching
digit characters instead of searching for delimiters.
Diffstat (limited to 'test/unit/testSelection.cxx')
-rw-r--r-- | test/unit/testSelection.cxx | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/test/unit/testSelection.cxx b/test/unit/testSelection.cxx index 609feaf00..ab0065624 100644 --- a/test/unit/testSelection.cxx +++ b/test/unit/testSelection.cxx @@ -115,18 +115,21 @@ TEST_CASE("SelectionPosition") { const std::string invalidString(invalid.ToString()); REQUIRE(invalidString == "-1"); - const SelectionPosition invalidReturned(invalidString); + std::string_view sv = invalidString; + const SelectionPosition invalidReturned(sv); REQUIRE(invalidReturned == invalid); const std::string zeroString(zero.ToString()); REQUIRE(zeroString == "0"); - const SelectionPosition zeroReturned(zeroString); + sv = zeroString; + const SelectionPosition zeroReturned(sv); REQUIRE(zeroReturned == zero); const SelectionPosition virtue(2, 3); const std::string virtueString(virtue.ToString()); REQUIRE(virtueString == "2v3"); - const SelectionPosition virtueReturned(virtueString); + sv = virtueString; + const SelectionPosition virtueReturned(sv); REQUIRE(virtueReturned == virtue); } @@ -156,9 +159,10 @@ TEST_CASE("SelectionRange") { // Range from 1 to 2 with 3 virtual spaces const SelectionRange range123(SelectionPosition(2, 3), SelectionPosition(1)); const std::string range123String(range123.ToString()); - // Opposite order to constructor: from anchor to caret + // Opposite order to constructor: from anchor to caret REQUIRE(range123String == "1-2v3"); - const SelectionRange range123Returned(range123String); + std::string_view sv = range123String; + const SelectionRange range123Returned(sv); REQUIRE(range123Returned == range123); } @@ -200,7 +204,7 @@ TEST_CASE("Selection") { SECTION("Selection") { Selection sel; - + REQUIRE(sel.selType == Selection::SelTypes::stream); REQUIRE(!sel.IsRectangular()); REQUIRE(sel.Count() == 1); @@ -220,9 +224,9 @@ TEST_CASE("Selection") { Selection selection; selection.SetSelection(range532); const std::string selectionString(selection.ToString()); - // Opposite order to constructor: from anchor to caret + // Opposite order to constructor: from anchor to caret REQUIRE(selectionString == "5v3-2"); - const SelectionRange selectionReturned(selectionString); + selection = Selection(selectionString); REQUIRE(selection.selType == Selection::SelTypes::stream); REQUIRE(!selection.IsRectangular()); @@ -246,8 +250,8 @@ TEST_CASE("Selection") { selection.AddSelection(range1); selection.SetMain(1); const std::string selectionString(selection.ToString()); - REQUIRE(selectionString == "5v3-2,1#1"); - const SelectionRange selectionReturned(selectionString); + REQUIRE(selectionString == "#1,5v3-2,1"); + selection = Selection(selectionString); REQUIRE(selection.selType == Selection::SelTypes::stream); REQUIRE(!selection.IsRectangular()); @@ -266,7 +270,7 @@ TEST_CASE("Selection") { // Range from 5 with 3 virtual spaces to 2 const SelectionRange range532(SelectionPosition(2), SelectionPosition(5, 3)); - + // Create a single-line rectangular selection Selection selection; selection.selType = Selection::SelTypes::rectangle; @@ -276,7 +280,7 @@ TEST_CASE("Selection") { const std::string selectionString(selection.ToString()); REQUIRE(selectionString == "R5v3-2"); - const Selection selectionReturned(selectionString); + selection = Selection(selectionString); REQUIRE(selection.selType == Selection::SelTypes::rectangle); REQUIRE(selection.IsRectangular()); |