aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2023-12-11 09:13:54 +1100
committerNeil <nyamatongwe@gmail.com>2023-12-11 09:13:54 +1100
commit1b83a38def5c210c39421593b0a73c23495bcd54 (patch)
tree3a2216ee5bef691af8dc5841999703a116264f85 /test
parentd48d0a0839d9585f92000e5893196bb3db212f01 (diff)
downloadscintilla-mirror-1b83a38def5c210c39421593b0a73c23495bcd54.tar.gz
Add std::regex tests for assertions in context which are common.
Two of these tests are currently returning incorrect results.
Diffstat (limited to 'test')
-rw-r--r--test/unit/testDocument.cxx42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/unit/testDocument.cxx b/test/unit/testDocument.cxx
index e3ab0b553..ca95bda66 100644
--- a/test/unit/testDocument.cxx
+++ b/test/unit/testDocument.cxx
@@ -614,6 +614,48 @@ TEST_CASE("Document") {
REQUIRE(match == Match(4));
#endif
}
+
+ SECTION("RegexContextualAssertion") {
+ // For std::regex, check the use of assertions next to text in forward direction
+ // These are more common than empty assertions
+ DocPlus doc("ab cd ef\r\ngh ij kl", CpUtf8);
+ const Sci::Position docLength = doc.document.Length();
+ Match match;
+
+ #ifndef NO_CXX11_REGEX
+
+ match = doc.FindString(0, docLength, "^[a-z]", reCxx11);
+ REQUIRE(match == Match(0, 1));
+ match = doc.FindString(1, docLength, "^[a-z]", reCxx11);
+ REQUIRE(match == Match(10, 1));
+
+ match = doc.FindString(0, docLength, "[a-z]$", reCxx11);
+ REQUIRE(match == Match(7, 1));
+ match = doc.FindString(10, docLength, "[a-z]$", reCxx11);
+ REQUIRE(match == Match(17, 1));
+
+ match = doc.FindString(0, docLength, "\\b[a-z]", reCxx11);
+ REQUIRE(match == Match(0, 1));
+ match = doc.FindString(1, docLength, "\\b[a-z]", reCxx11);
+ REQUIRE(match == Match(1, 1)); // Should be (3,1)
+ match = doc.FindString(0, docLength, "[a-z]\\b", reCxx11);
+ REQUIRE(match == Match(1, 1));
+ match = doc.FindString(2, docLength, "[a-z]\\b", reCxx11);
+ REQUIRE(match == Match(4, 1));
+
+ match = doc.FindString(0, docLength, "\\B[a-z]", reCxx11);
+ REQUIRE(match == Match(1, 1));
+ match = doc.FindString(1, docLength, "\\B[a-z]", reCxx11);
+ REQUIRE(match == Match(4, 1)); // Should be (1,1)
+ match = doc.FindString(0, docLength, "[a-z]\\B", reCxx11);
+ REQUIRE(match == Match(0, 1));
+ match = doc.FindString(2, docLength, "[a-z]\\B", reCxx11);
+ REQUIRE(match == Match(3, 1));
+
+ #endif
+ }
+
+
}
TEST_CASE("Words") {