aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2024-11-30 13:13:49 +1100
committerZufu Liu <unknown>2024-11-30 13:13:49 +1100
commit7d69a0041a965406464f61b6ebb5da18a10d7c83 (patch)
treecb7fc806e189e71b028b99aa65eabffa8dda975a
parent1beb1d8b049d1bc998c513221ba758b633074d58 (diff)
downloadscintilla-mirror-7d69a0041a965406464f61b6ebb5da18a10d7c83.tar.gz
Feature [feature-requests:#1533]. Tests for BraceMatch.
-rw-r--r--test/unit/testDocument.cxx49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/unit/testDocument.cxx b/test/unit/testDocument.cxx
index a80e83a3f..c4985f330 100644
--- a/test/unit/testDocument.cxx
+++ b/test/unit/testDocument.cxx
@@ -729,6 +729,55 @@ TEST_CASE("Document") {
REQUIRE(substituted == "\ta\n");
}
+ SECTION("BraceMatch") {
+ DocPlus doc("{}(()())[]", CpUtf8);
+ constexpr Sci::Position maxReStyle = 0; // unused parameter
+ Sci::Position pos = doc.document.BraceMatch(0, maxReStyle, 0, false);
+ REQUIRE(pos == 1);
+ pos = doc.document.BraceMatch(1, maxReStyle, 0, false);
+ REQUIRE(pos == 0);
+ pos = doc.document.BraceMatch(8, maxReStyle, 0, false);
+ REQUIRE(pos == 9);
+ pos = doc.document.BraceMatch(9, maxReStyle, 0, false);
+ REQUIRE(pos == 8);
+ pos = doc.document.BraceMatch(2, maxReStyle, 0, false);
+ REQUIRE(pos == 7);
+ pos = doc.document.BraceMatch(7, maxReStyle, 0, false);
+ REQUIRE(pos == 2);
+
+ // BraceMatchNext()
+ pos = doc.document.BraceMatch(2, maxReStyle, 3, true);
+ REQUIRE(pos == 7);
+ pos = doc.document.BraceMatch(2, maxReStyle, 4, true);
+ REQUIRE(pos == 4);
+ pos = doc.document.BraceMatch(2, maxReStyle, 5, true);
+ REQUIRE(pos == 7);
+ pos = doc.document.BraceMatch(2, maxReStyle, 6, true);
+ REQUIRE(pos == 6);
+ pos = doc.document.BraceMatch(2, maxReStyle, 7, true);
+ REQUIRE(pos == 7);
+
+ pos = doc.document.BraceMatch(7, maxReStyle, 6, true);
+ REQUIRE(pos == 2);
+ pos = doc.document.BraceMatch(7, maxReStyle, 5, true);
+ REQUIRE(pos == 5);
+ pos = doc.document.BraceMatch(7, maxReStyle, 4, true);
+ REQUIRE(pos == 2);
+ pos = doc.document.BraceMatch(7, maxReStyle, 3, true);
+ REQUIRE(pos == 3);
+ pos = doc.document.BraceMatch(7, maxReStyle, 2, true);
+ REQUIRE(pos == 2);
+ }
+
+ SECTION("BraceMatch DBCS") {
+ DocPlus doc("{\x81}\x81{}", 932); // { U+00B1 U+FF0B }
+ constexpr Sci::Position maxReStyle = 0; // unused parameter
+ Sci::Position pos = doc.document.BraceMatch(0, maxReStyle, 0, false);
+ REQUIRE(pos == 5);
+ pos = doc.document.BraceMatch(5, maxReStyle, 0, false);
+ REQUIRE(pos == 0);
+ }
+
}
TEST_CASE("DocumentUndo") {