From commits-return-12032-apmail-apr-commits-archive=apr.apache.org@apr.apache.org Mon May 2 17:02:56 2011 Return-Path: X-Original-To: apmail-apr-commits-archive@www.apache.org Delivered-To: apmail-apr-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7CB773A80 for ; Mon, 2 May 2011 17:02:56 +0000 (UTC) Received: (qmail 85293 invoked by uid 500); 2 May 2011 17:02:56 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 85254 invoked by uid 500); 2 May 2011 17:02:56 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 85246 invoked by uid 99); 2 May 2011 17:02:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 May 2011 17:02:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 May 2011 17:02:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 360F52388901; Mon, 2 May 2011 17:02:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1098664 - /apr/apr/branches/1.4.x/test/testfnmatch.c Date: Mon, 02 May 2011 17:02:33 -0000 To: commits@apr.apache.org From: wrowe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110502170233.360F52388901@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: wrowe Date: Mon May 2 17:02:32 2011 New Revision: 1098664 URL: http://svn.apache.org/viewvc?rev=1098664&view=rev Log: Some fnmatch patterns, more needed Modified: apr/apr/branches/1.4.x/test/testfnmatch.c Modified: apr/apr/branches/1.4.x/test/testfnmatch.c URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/test/testfnmatch.c?rev=1098664&r1=1098663&r2=1098664&view=diff ============================================================================== --- apr/apr/branches/1.4.x/test/testfnmatch.c (original) +++ apr/apr/branches/1.4.x/test/testfnmatch.c Mon May 2 17:02:32 2011 @@ -25,6 +25,59 @@ #define NUM_FILES (5) +#define APR_FNM_ANY 0 +#define APR_FNM_NONE 128 + +/* A string is expected to match pattern only if a success_flags bit is true, + * and is expected to fail for all other cases (so APR_FNM_NONE is bit never tested). + */ +static struct pattern_s { + const char *pattern; + const char *string; + int success_flags; +} patterns[] = { + + {"test", "test", APR_FNM_ANY}, + {"test/this", "test/this", APR_FNM_ANY}, + {"teST", "TEst", APR_FNM_CASE_BLIND}, + {"*", "", APR_FNM_ANY}, + {"*", "test", APR_FNM_ANY}, + {".*", ".test", APR_FNM_PERIOD}, + {"*", ".test", APR_FNM_NONE}, + {"", "test", APR_FNM_NONE}, + {"", "*", APR_FNM_NONE}, + {"test", "*", APR_FNM_NONE}, + {"test/this", "test/", APR_FNM_NONE}, + {"test/", "test/this", APR_FNM_NONE}, + + {NULL, NULL, 0} +}; + +#define APR_FNM_MAX 15 /* all bits */ + +static void test_fnmatch(abts_case *tc, void *data) +{ + struct pattern_s *test = patterns; + int i; + int res; + + for (test = patterns; test->pattern; ++test) + for (i = 0; i <= APR_FNM_MAX; ++i) + { + res = apr_fnmatch(test->pattern, test->string, i); + if ((i & test->success_flags) == test->success_flags) { + if (res == APR_FNM_NOMATCH) + break; + } + else { + if (res != APR_FNM_NOMATCH) + break; + } + } + + ABTS_INT_EQUAL(tc, APR_FNM_MAX + 1, i); +} + static void test_glob(abts_case *tc, void *data) { int i; @@ -68,6 +121,7 @@ abts_suite *testfnmatch(abts_suite *suit { suite = ADD_SUITE(suite) + abts_run_test(suite, test_fnmatch, NULL); abts_run_test(suite, test_glob, NULL); abts_run_test(suite, test_glob_currdir, NULL);