summaryrefslogtreecommitdiff
path: root/test/testfnmatch.c
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2011-05-11 14:51:33 +0000
committerJoe Orton <jorton@apache.org>2011-05-11 14:51:33 +0000
commita32f576fe70f652cae884a472b3cff65ad3c0d3d (patch)
tree74d8f849aeb1537765d4683b6455b3cf7ddbf134 /test/testfnmatch.c
parentafa3e2327acec55257f2c53b4b7a82492e48d2f0 (diff)
downloadapr-a32f576fe70f652cae884a472b3cff65ad3c0d3d.tar.gz
* test/testfnmatch.c: Add a few more apr_fnmatch() tests to
improve (already good!) coverage a little. (test_fnmatch_test): New test. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1101905 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testfnmatch.c')
-rw-r--r--test/testfnmatch.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/testfnmatch.c b/test/testfnmatch.c
index 51e0a5f14..5a0813b62 100644
--- a/test/testfnmatch.c
+++ b/test/testfnmatch.c
@@ -75,6 +75,24 @@ static struct pattern_s {
{"tes*", "test", SUCCEEDS},
{"test*", "test", SUCCEEDS},
+ {"test*?*[a-z]*", "testgoop", SUCCEEDS},
+ {"te[^x]t", "test", SUCCEEDS},
+ {"te[^abc]t", "test", SUCCEEDS},
+ {"te[^x]t", "test", SUCCEEDS},
+ {"te[!x]t", "test", SUCCEEDS},
+ {"te[^x]t", "text", FAILS},
+ {"te[^\\x]t", "text", FAILS},
+ {"te[^x\\", "text", FAILS},
+ {"te[/]t", "text", FAILS},
+ {"te[S]t", "test", SUCCEEDS_IF(APR_FNM_CASE_BLIND)},
+ {"te[r-t]t", "test", SUCCEEDS},
+ {"te[r-t]t", "teSt", SUCCEEDS_IF(APR_FNM_CASE_BLIND)},
+ {"te[r-T]t", "test", SUCCEEDS_IF(APR_FNM_CASE_BLIND)},
+ {"te[R-T]t", "test", SUCCEEDS_IF(APR_FNM_CASE_BLIND)},
+ {"te[r-Tz]t", "tezt", SUCCEEDS},
+ {"te[R-T]t", "tent", FAILS},
+ {"\\/test", "/test", FAILS_IF(APR_FNM_NOESCAPE)},
+
{"test/this", "test/", FAILS},
{"test/", "test/this", FAILS},
{"test*/this", "test/this", SUCCEEDS},
@@ -133,6 +151,35 @@ static void test_fnmatch(abts_case *tc, void *data)
}
}
+static void test_fnmatch_test(abts_case *tc, void *data)
+{
+ static const struct test {
+ const char *pattern;
+ int result;
+ } ft_tests[] = {
+ { "a*b", 1 },
+ { "a?", 1 },
+ { "a\\b?", 1 },
+ { "a[b-c]", 1 },
+ { "a", 0 },
+ { "a\\", 0 },
+ { NULL, 0 }
+ };
+ const struct test *t;
+
+ for (t = ft_tests; t->pattern != NULL; t++) {
+ int res = apr_fnmatch_test(t->pattern);
+
+ if (res != t->result) {
+ char buf[128];
+
+ sprintf(buf, "apr_fnmatch_test(\"%s\") = %d, expected %d\n",
+ t->pattern, res, t->result);
+ abts_fail(tc, buf, __LINE__);
+ }
+ }
+}
+
static void test_glob(abts_case *tc, void *data)
{
int i;
@@ -177,6 +224,7 @@ abts_suite *testfnmatch(abts_suite *suite)
suite = ADD_SUITE(suite)
abts_run_test(suite, test_fnmatch, NULL);
+ abts_run_test(suite, test_fnmatch_test, NULL);
abts_run_test(suite, test_glob, NULL);
abts_run_test(suite, test_glob_currdir, NULL);