diff options
author | Zufu Liu <unknown> | 2023-11-02 08:51:15 +1100 |
---|---|---|
committer | Zufu Liu <unknown> | 2023-11-02 08:51:15 +1100 |
commit | e702dacda85f0976d1006d9634dc38b53fad1336 (patch) | |
tree | 76b1f6005d0a645f702fc2c750f3d7626bea3da0 /test | |
parent | 4c06fe443f2dd9d6235c9cf95d38f7054cfd82b2 (diff) | |
download | scintilla-mirror-e702dacda85f0976d1006d9634dc38b53fad1336.tar.gz |
Feature [feature-requests:#1500] Remove match text retrieval from MatchOnLines
as it is redone in SubstituteByPosition.
Replace RESearch::pat and RESearch::GrabMatches with retrieving matches as
needed in SubstituteByPosition.
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/testRESearch.cxx | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/test/unit/testRESearch.cxx b/test/unit/testRESearch.cxx index 5c5d54c71..781d776a4 100644 --- a/test/unit/testRESearch.cxx +++ b/test/unit/testRESearch.cxx @@ -41,6 +41,9 @@ public: char CharAt(Sci::Position index) const override { return s.at(index); } + std::string GetCharRange(Sci::Position position, Sci::Position lengthRetrieve) const { + return s.substr(position, lengthRetrieve); + } }; // Test RESearch. @@ -48,18 +51,18 @@ public: TEST_CASE("RESearch") { CharClassify cc; - const char sTextSpace[] = "Scintilla "; - const char pattern[] = "[a-z]+"; + constexpr std::string_view sTextSpace = "Scintilla "; + constexpr std::string_view pattern = "[a-z]+"; SECTION("Compile") { std::unique_ptr<RESearch> re = std::make_unique<RESearch>(&cc); - const char *msg = re->Compile(pattern, strlen(pattern), true, false); + const char *msg = re->Compile(pattern.data(), pattern.length(), true, false); REQUIRE(nullptr == msg); } SECTION("Execute") { std::unique_ptr<RESearch> re = std::make_unique<RESearch>(&cc); - re->Compile(pattern, strlen(pattern), true, false); + re->Compile(pattern.data(), pattern.length(), true, false); StringCI sci(sTextSpace); const int x = re->Execute(sci, 0, sci.Length()); REQUIRE(x == 1); @@ -69,11 +72,11 @@ TEST_CASE("RESearch") { SECTION("Grab") { std::unique_ptr<RESearch> re = std::make_unique<RESearch>(&cc); - re->Compile(pattern, strlen(pattern), true, false); + re->Compile(pattern.data(), pattern.length(), true, false); StringCI sci(sTextSpace); re->Execute(sci, 0, sci.Length()); - re->GrabMatches(sci); - REQUIRE(re->pat[0] == "cintilla"); + std::string pat = sci.GetCharRange(re->bopat[0], re->eopat[0] - re->bopat[0]); + REQUIRE(pat == "cintilla"); } } |