From 00326a63ed6b07acfe437ccae1253b593463c75b Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 9 Nov 2022 21:34:36 +0330 Subject: LibRegex: Don't treat ForkReplace* as new forks --- Tests/LibRegex/Regex.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Tests/LibRegex') diff --git a/Tests/LibRegex/Regex.cpp b/Tests/LibRegex/Regex.cpp index abcfa93513..15e972a24d 100644 --- a/Tests/LibRegex/Regex.cpp +++ b/Tests/LibRegex/Regex.cpp @@ -1067,6 +1067,12 @@ TEST_CASE(negative_lookahead) EXPECT_EQ(re.match(":1"sv).success, false); EXPECT_EQ(re.match(":foobar"sv).success, true); } + { + // Correctly count forks with nested groups and optimised loops + Regex re("^((?:[^\\n]|\\n(?! *\\n))+)(?:\\n *)+\\n"); + EXPECT_EQ(re.match("foo\n\n"sv).success, true); + EXPECT_EQ(re.match("foo\n"sv).success, false); + } } TEST_CASE(single_match_flag) -- cgit v1.2.3