Added more test cases for multiple * and ? in pattern.
authorDaniel Carl <danielcarl@gmx.de>
Sat, 6 Sep 2014 10:40:11 +0000 (12:40 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 6 Sep 2014 10:40:11 +0000 (12:40 +0200)
tests/test-util.c

index cd80420..a8d42f7 100644 (file)
@@ -169,6 +169,7 @@ static void test_wildmatch_questionmark(void)
 
     g_assert_false(util_wildmatch("foo\\?bar", "foorbar"));
     g_assert_false(util_wildmatch("?", ""));
+    g_assert_false(util_wildmatch("b??r", "bar"));
 }
 
 static void test_wildmatch_wildcard(void)
@@ -181,8 +182,13 @@ static void test_wildmatch_wildcard(void)
     g_assert_true(util_wildmatch("match\\*", "match*"));
     g_assert_true(util_wildmatch("do * match", "do a infix match"));
     g_assert_true(util_wildmatch("*://*.io/*", "http://fanglingsu.github.io/vimb/"));
+    /* multiple * should act like a single one */
+    g_assert_true(util_wildmatch("**", ""));
+    g_assert_true(util_wildmatch("match **", "Match as much as possible"));
+    g_assert_true(util_wildmatch("f***u", "fu"));
 
     g_assert_false(util_wildmatch("match\\*", "match fail"));
+    g_assert_false(util_wildmatch("f***u", "full"));
 }
 
 int main(int argc, char *argv[])