mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-02 07:36:17 +01:00
regex test: Check the expected PCRE version at runtime
We might be built against a newer version than we're run against. https://bugzilla.gnome.org/show_bug.cgi?id=760683
This commit is contained in:
parent
c3d6934f18
commit
db90987990
@ -1,9 +1,20 @@
|
||||
include $(top_srcdir)/glib-tap.mk
|
||||
|
||||
if USE_SYSTEM_PCRE
|
||||
pcre_lib = $(PCRE_LIBS)
|
||||
pcre_inc = $(PCRE_CFLAGS)
|
||||
else
|
||||
pcre_lib = pcre/libpcre.la
|
||||
pcre_inc =
|
||||
endif
|
||||
|
||||
LDADD = $(top_builddir)/glib/libglib-2.0.la -lm
|
||||
AM_CPPFLAGS = -g $(glib_INCLUDES) $(GLIB_DEBUG_FLAGS)
|
||||
DEFS = -DG_LOG_DOMAIN=\"GLib\" -DEXEEXT=\"$(EXEEXT)\"
|
||||
AM_CFLAGS = $(GLIB_WARN_CFLAGS)
|
||||
AM_CFLAGS = $(GLIB_WARN_CFLAGS) $(pcre_inc)
|
||||
|
||||
# The regex test uses pcre_version()
|
||||
regex_LDADD = $(LDADD) $(pcre_lib)
|
||||
|
||||
# These tests corrupt the gcov bookkeeping, so we
|
||||
# skip them. See bug 682133
|
||||
|
@ -2165,6 +2165,24 @@ test_max_lookbehind (void)
|
||||
g_regex_unref (regex);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
pcre_ge (guint64 major, guint64 minor)
|
||||
{
|
||||
const char *version;
|
||||
gchar *ptr;
|
||||
guint64 pcre_major, pcre_minor;
|
||||
|
||||
/* e.g. 8.35 2014-04-04 */
|
||||
version = pcre_version ();
|
||||
|
||||
pcre_major = g_ascii_strtoull (version, &ptr, 10);
|
||||
/* ptr points to ".MINOR (release date)" */
|
||||
g_assert (ptr[0] == '.');
|
||||
pcre_minor = g_ascii_strtoull (ptr + 1, NULL, 10);
|
||||
|
||||
return (pcre_major > major) || (pcre_major == major && pcre_minor >= minor);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@ -2261,14 +2279,17 @@ main (int argc, char *argv[])
|
||||
TEST_NEW_FAIL ("^(?(0)f|b)oo", 0, G_REGEX_ERROR_INVALID_CONDITION);
|
||||
TEST_NEW_FAIL ("(?<=\\C)X", 0, G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND);
|
||||
TEST_NEW_FAIL ("(?!\\w)(?R)", 0, G_REGEX_ERROR_INFINITE_LOOP);
|
||||
#if PCRE_MAJOR > 8 || (PCRE_MAJOR == 8 && PCRE_MINOR >= 37)
|
||||
/* The expected errors changed here. */
|
||||
TEST_NEW_FAIL ("(?P<sub>foo)\\g<sub", 0, G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR);
|
||||
TEST_NEW_FAIL ("(?(?<ab))", 0, G_REGEX_ERROR_ASSERTION_EXPECTED);
|
||||
#else
|
||||
TEST_NEW_FAIL ("(?P<sub>foo)\\g<sub", 0, G_REGEX_ERROR_MISSING_BACK_REFERENCE);
|
||||
TEST_NEW_FAIL ("(?(?<ab))", 0, G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR);
|
||||
#endif
|
||||
if (pcre_ge (8, 37))
|
||||
{
|
||||
/* The expected errors changed here. */
|
||||
TEST_NEW_FAIL ("(?P<sub>foo)\\g<sub", 0, G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR);
|
||||
TEST_NEW_FAIL ("(?(?<ab))", 0, G_REGEX_ERROR_ASSERTION_EXPECTED);
|
||||
}
|
||||
else
|
||||
{
|
||||
TEST_NEW_FAIL ("(?P<sub>foo)\\g<sub", 0, G_REGEX_ERROR_MISSING_BACK_REFERENCE);
|
||||
TEST_NEW_FAIL ("(?(?<ab))", 0, G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR);
|
||||
}
|
||||
TEST_NEW_FAIL ("(?P<x>eks)(?P<x>eccs)", 0, G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME);
|
||||
#if 0
|
||||
TEST_NEW_FAIL (?, 0, G_REGEX_ERROR_MALFORMED_PROPERTY);
|
||||
|
Loading…
Reference in New Issue
Block a user