diff options
author | Sébastien Wilmet <swilmet@gnome.org> | 2013-07-15 13:52:14 +0200 |
---|---|---|
committer | Sébastien Wilmet <swilmet@gnome.org> | 2013-07-23 15:43:22 +0200 |
commit | 6fbb1463429748bed7ab6593779430ee1c0664f5 (patch) | |
tree | 52d31250b1bc70bf7d300c67b2c22e5fed26f676 /glib/tests/regex.c | |
parent | d9e01e0c37eb7928a99aeaa3d51007198991928d (diff) | |
download | glib-6fbb1463429748bed7ab6593779430ee1c0664f5.tar.gz |
GRegex: add g_regex_get_max_lookbehind()
It is useful for multi-segment regex matching.
A unit test is included.
https://bugzilla.gnome.org/show_bug.cgi?id=689794
Diffstat (limited to 'glib/tests/regex.c')
-rw-r--r-- | glib/tests/regex.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/glib/tests/regex.c b/glib/tests/regex.c index f205bf2cf..ea7385f6a 100644 --- a/glib/tests/regex.c +++ b/glib/tests/regex.c @@ -2084,6 +2084,24 @@ test_explicit_crlf (void) g_regex_unref (regex); } +static void +test_max_lookbehind (void) +{ + GRegex *regex; + + regex = g_regex_new ("abc", 0, 0, NULL); + g_assert_cmpint (g_regex_get_max_lookbehind (regex), ==, 0); + g_regex_unref (regex); + + regex = g_regex_new ("\\babc", 0, 0, NULL); + g_assert_cmpint (g_regex_get_max_lookbehind (regex), ==, 1); + g_regex_unref (regex); + + regex = g_regex_new ("(?<=123)abc", 0, 0, NULL); + g_assert_cmpint (g_regex_get_max_lookbehind (regex), ==, 3); + g_regex_unref (regex); +} + int main (int argc, char *argv[]) { @@ -2102,6 +2120,7 @@ main (int argc, char *argv[]) g_test_add_func ("/regex/recursion", test_recursion); g_test_add_func ("/regex/multiline", test_multiline); g_test_add_func ("/regex/explicit-crlf", test_explicit_crlf); + g_test_add_func ("/regex/max-lookbehind", test_max_lookbehind); /* TEST_NEW(pattern, compile_opts, match_opts) */ TEST_NEW("[A-Z]+", G_REGEX_CASELESS | G_REGEX_EXTENDED | G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTBOL | G_REGEX_MATCH_PARTIAL); |