From 1a68cdaedf8e9d379dc742f8a9c6198c0cb99dc5 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sun, 22 Mar 2015 00:16:27 +0000 Subject: [PATCH] add ere backref regression test --- src/regression/regex-ere-backref.c | 34 ++++++++++++++++++++++++++++++++ src/regression/regex-escaped-high-byte.c | 1 + 2 files changed, 35 insertions(+) create mode 100644 src/regression/regex-ere-backref.c diff --git a/src/regression/regex-ere-backref.c b/src/regression/regex-ere-backref.c new file mode 100644 index 0000000..196b25c --- /dev/null +++ b/src/regression/regex-ere-backref.c @@ -0,0 +1,34 @@ +// commit 7c8c86f6308c7e0816b9638465a5917b12159e8f 2015-03-20 +// backref is not valid in ere +#include +#include "test.h" + +int main(void) +{ + char buf[200]; + char pat[] = "(a)\\1"; + regex_t r; + int n; + + n = regcomp(&r, pat, REG_EXTENDED); + if (n) { + regerror(n, &r, buf, sizeof buf); + t_error("regcomp(%s) returned %d (%s) wanted 0\n", pat, n, buf); + } + + n = regexec(&r, "aa", 0, 0, 0); + if (n != REG_NOMATCH) { + regerror(n, &r, buf, sizeof buf); + t_error("regexec(/%s/ ~ \"aa\") returned %d (%s), wanted REG_NOMATCH\n", + pat, n, buf); + } + + n = regexec(&r, "a1", 0, 0, 0); + if (n) { + regerror(n, &r, buf, sizeof buf); + t_error("regexec(/%s/ ~ \"a1\") returned %d (%s), wanted 0\n", + pat, n, buf); + } + + return t_status; +} diff --git a/src/regression/regex-escaped-high-byte.c b/src/regression/regex-escaped-high-byte.c index 892b4a3..7a29489 100644 --- a/src/regression/regex-escaped-high-byte.c +++ b/src/regression/regex-escaped-high-byte.c @@ -9,6 +9,7 @@ int main(void) regex_t r; int n; + // illegal sequence (not U+00FC) n = regcomp(&r, "\\\xfc", 0); if (n != REG_BADPAT) { regerror(n, &r, buf, sizeof buf); -- 2.11.4.GIT