From 92b2c406982f08d024be4b47c01124b0378b165c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Fri, 24 May 2024 14:01:50 +0200 Subject: [PATCH] Standalone test for upstream #101. --- tests/Makefile.am | 5 +++++ tests/bore.c | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/bore.c diff --git a/tests/Makefile.am b/tests/Makefile.am index d73acac..de8a385 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -68,3 +68,8 @@ TESTS = test-str-source retest if TRE_MULTIBYTE TESTS += wretest endif TRE_MULTIBYTE + +check_PROGRAMS += bore +bore_SOURCES = bore.c +bore_CPPFLAGS = $(retest_CPPFLAGS) +bore_LDADD = $(retest_LDADD) diff --git a/tests/bore.c b/tests/bore.c new file mode 100644 index 0000000..d6bb851 --- /dev/null +++ b/tests/bore.c @@ -0,0 +1,26 @@ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +int main(void) +{ + regex_t reg; + + if (regcomp(®, "^|$", REG_EXTENDED | REG_NOSUB) != 0) + return 2; + /* should not match becuase BOL and EOL are disabled */ + if (regexec(®, "", 0, NULL, REG_NOTBOL | REG_NOTEOL) != REG_NOMATCH) + return 1; + /* should match because BOL is disabled but EOL is not */ + if (regexec(®, "", 0, NULL, REG_NOTBOL) != 0) + return 1; + /* should match because EOL is disabled but BOL is not */ + if (regexec(®, "", 0, NULL, REG_NOTEOL) != 0) + return 1; + regfree(®); + return 0; +} +