diff options
author | Daniel Carl <danielcarl@gmx.de> | 2014-09-07 00:35:06 +0200 |
---|---|---|
committer | Daniel Carl <danielcarl@gmx.de> | 2014-09-07 00:35:06 +0200 |
commit | 584b9fa94f9020c2b14b074002a9caf9bc5c8043 (patch) | |
tree | df483387f421faaadca434cf9725e844afcb31bd /tests | |
parent | 9dd67ade189d799ead56857c01ede3798aa23215 (diff) |
Allow to match multiple patterns (#100).
Change the matching functions to not end at the NUL of the pattern. In stead
we give a pattern length parameter. This allows to process multiple patterns
without the need to put NUL-bytes into it or to allocate memory for the parts
to match.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-util.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test-util.c b/tests/test-util.c index 38b7bf2..b89d620 100644 --- a/tests/test-util.c +++ b/tests/test-util.c @@ -248,6 +248,23 @@ static void test_wildmatch_complete(void) g_assert_true(util_wildmatch("http{s,}://{fanglingsu.,}github.{io,com}/*vimb/", "https://github.com/fanglingsu/vimb/")); } +static void test_wildmatch_multi(void) +{ + /* check if sinlge pattern matching works */ + g_assert_true(util_wildmatch_multi("", "")); + g_assert_true(util_wildmatch_multi("single", "single")); + g_assert_true(util_wildmatch_multi("s*e", "single")); + + g_assert_true(util_wildmatch_multi("foo,b{a,o,}r,ba?", "foo")); + g_assert_true(util_wildmatch_multi("foo,b{a,o,}r,ba?", "bar")); + g_assert_true(util_wildmatch_multi("foo,b{a,o,}r,ba?", "bor")); + g_assert_true(util_wildmatch_multi("foo,b{a,o,}r,ba?", "br")); + g_assert_true(util_wildmatch_multi("foo,b{a,o,}r,ba?", "baz")); + g_assert_true(util_wildmatch_multi("foo,b{a,o,}r,ba?", "bat")); + + g_assert_false(util_wildmatch_multi("foo,b{a,o,}r,ba?", "foo,")); +} + int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); @@ -264,6 +281,7 @@ int main(int argc, char *argv[]) g_test_add_func("/test-util/wildmatch-wildcard", test_wildmatch_wildcard); g_test_add_func("/test-util/wildmatch-curlybraces", test_wildmatch_curlybraces); g_test_add_func("/test-util/wildmatch-complete", test_wildmatch_complete); + g_test_add_func("/test-util/wildmatch-multi", test_wildmatch_multi); return g_test_run(); } |