diff options
author | Neil <nyamatongwe@gmail.com> | 2021-07-16 09:40:45 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2021-07-16 09:40:45 +1000 |
commit | 05f4d202fa25a9b6beb23e097cc15c16c2e51f96 (patch) | |
tree | 49d74f8669543cc173d205c564864dc2d6751b25 /test/unit/testDocument.cxx | |
parent | 7acc601f5818a46837baff31ccc231d1cc4b1ffe (diff) | |
download | scintilla-mirror-05f4d202fa25a9b6beb23e097cc15c16c2e51f96.tar.gz |
Feature [feature-requests:#1381] Fix position returned when in 2nd segment.
Diffstat (limited to 'test/unit/testDocument.cxx')
-rw-r--r-- | test/unit/testDocument.cxx | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/unit/testDocument.cxx b/test/unit/testDocument.cxx index a48ab3fcb..97db6d9a2 100644 --- a/test/unit/testDocument.cxx +++ b/test/unit/testDocument.cxx @@ -119,6 +119,12 @@ struct DocPlus { assert(*length == static_cast<Sci::Position>(needle.length())); return document.FindText(document.Length(), 0, needle.c_str(), options, length); } + void MoveGap(Sci::Position gapNew) { + // Move gap to gapNew by inserting + document.InsertString(gapNew, "!", 1); + // Remove insertion + document.DeleteChars(gapNew, 1); + } }; void TimeTrace(std::string_view sv, const Catch::Timer &tikka) { @@ -161,6 +167,19 @@ TEST_CASE("Document") { REQUIRE(location == -1); } + SECTION("SearchInBothSegments") { + DocPlus doc("ab-ab", 0); // a b - a b + std::string finding = "ab"; + for (int gapPos = 0; gapPos <= 5; gapPos++) { + doc.MoveGap(gapPos); + Sci::Position lengthFinding = finding.length(); + Sci::Position location = doc.document.FindText(0, doc.document.Length(), finding.c_str(), FindOption::MatchCase, &lengthFinding); + REQUIRE(location == 0); + location = doc.document.FindText(2, doc.document.Length(), finding.c_str(), FindOption::MatchCase, &lengthFinding); + REQUIRE(location == 3); + } + } + SECTION("InsensitiveSearchInLatin") { DocPlus doc("abcde", 0); // a b c d e std::string finding = "B"; |