Skip to content

Commit

Permalink
add some test cases for #295
Browse files Browse the repository at this point in the history
  • Loading branch information
kkos committed May 24, 2024
1 parent 42f0c32 commit cd80713
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/test_syntax.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ static int test_look_behind()
x2("(?<=a|b)c", "abc", 2, 3);
x2("(?<=a|(.))\\1", "abcc", 3, 4);

// #295
n("(?<!RMA)X", "123RMAX");
x2("(?<=RMA)X", "123RMAX", 6, 7);
n("(?<!RMA)$", "123RMA");
x2("(?<=RMA)$", "123RMA", 6, 6);
n("(?<!RMA)\\Z", "123RMA");
x2("(?<=RMA)\\Z", "123RMA", 6, 6);
n("(?<!RMA)\\z", "123RMA");
x2("(?<=RMA)\\z", "123RMA", 6, 6);

// following is not match in Perl and Java
//x2("(?<=a|(.))\\1", "aa", 1, 2);

Expand Down
9 changes: 9 additions & 0 deletions test/test_utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,15 @@ extern int main(int argc, char* argv[])
n("(\\k<2>)|(?<=(\\k<1>))", "");
x2("(a|\\k<2>)|(?<=(\\k<1>))", "a", 0, 1);
x2("(a|\\k<2>)|(?<=b(\\k<1>))", "ba", 1, 2);
// #295
n("(?<!RMA)X", "123RMAX");
x2("(?<=RMA)X", "123RMAX", 6, 7);
n("(?<!RMA)$", "123RMA");
x2("(?<=RMA)$", "123RMA", 6, 6);
n("(?<!RMA)\\Z", "123RMA");
x2("(?<=RMA)\\Z", "123RMA", 6, 6);
n("(?<!RMA)\\z", "123RMA");
x2("(?<=RMA)\\z", "123RMA", 6, 6);

x2("((?(a)\\g<1>|b))", "aab", 0, 3);
x2("((?(a)\\g<1>))", "aab", 0, 2);
Expand Down

0 comments on commit cd80713

Please sign in to comment.