summaryrefslogtreecommitdiff
path: root/test/test_syntax.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_syntax.c')
-rw-r--r--test/test_syntax.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/test_syntax.c b/test/test_syntax.c
index b501ccd..b07fe67 100644
--- a/test/test_syntax.c
+++ b/test/test_syntax.c
@@ -259,6 +259,30 @@ static int test_python_single_multi()
return 0;
}
+static int test_BRE_anchors()
+{
+ x2("a\\^b", "a^b", 0, 3);
+ x2("a^b", "a^b", 0, 3);
+ x2("a\\$b", "a$b", 0, 3);
+ x2("a$b", "a$b", 0, 3);
+
+ x2("^ab", "ab", 0, 2);
+ x2("(^ab)", "(^ab)", 0, 5);
+ x2("\\(^ab\\)", "ab", 0, 2);
+ x2("\\\\(^ab\\\\)", "\\(^ab\\)", 0, 7);
+ n("\\\\\\(^ab\\\\\\)", "\\ab\\");
+ x2("^\\\\\\(ab\\\\\\)", "\\ab\\", 0, 4);
+
+ x2("ab$", "ab", 0, 2);
+ x2("(ab$)", "(ab$)", 0, 5);
+ x2("\\(ab$\\)", "ab", 0, 2);
+ x2("\\\\(ab$\\\\)", "\\(ab$\\)", 0, 7);
+ n("\\\\\\(ab$\\\\\\)", "\\ab\\");
+ x2("\\\\\\(ab\\\\\\)$", "\\ab\\", 0, 4);
+
+ return 0;
+}
+
extern int main(int argc, char* argv[])
{
OnigEncoding use_encs[1];
@@ -309,6 +333,26 @@ extern int main(int argc, char* argv[])
x2("\\U00000041", "A", 0, 1);
e("\\U0041", "A", ONIGERR_INVALID_CODE_POINT_VALUE);
+ Syntax = ONIG_SYNTAX_POSIX_BASIC;
+ test_BRE_anchors();
+
+ Syntax = ONIG_SYNTAX_GREP;
+ test_BRE_anchors();
+ x2("zz\\|^ab", "ab", 0, 2);
+ x2("ab$\\|zz", "ab", 0, 2);
+
+ Syntax = ONIG_SYNTAX_PERL_NG;
+
+ x2("(?i)test", "test", 0, 4);
+ x2("(?-i)test", "test", 0, 4);
+ x2("(?i)test", "TEST", 0, 4);
+ n("(?-i)test", "teSt");
+ x2("(?i)te(?-i)st", "TEst", 0, 4);
+ n("(?i)te(?-i)st", "TesT");
+
+ x2("(abc)(?-1)", "abcabc", 0, 6);
+ x2("(?+1)(abc)", "abcabc", 0, 6);
+ x2("(abc)(?1)", "abcabc", 0, 6);
fprintf(stdout,
"\nRESULT SUCC: %4d, FAIL: %d, ERROR: %d (by Oniguruma %s)\n",