~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr/test/testfnmatch.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
#include "testutil.h"
 
18
#include "apr_file_info.h"
 
19
#include "apr_fnmatch.h"
 
20
#include "apr_tables.h"
 
21
 
 
22
/* XXX NUM_FILES must be equal to the nummber of expected files with a
 
23
 * .txt extension in the data directory at the time testfnmatch
 
24
 * happens to be run (!?!). */
 
25
 
 
26
#define NUM_FILES (5)
 
27
 
 
28
static void test_glob(abts_case *tc, void *data)
 
29
{
 
30
    int i;
 
31
    char **list;
 
32
    apr_array_header_t *result;
 
33
    
 
34
    APR_ASSERT_SUCCESS(tc, "glob match against data/*.txt",
 
35
                       apr_match_glob("data\\*.txt", &result, p));
 
36
 
 
37
    ABTS_INT_EQUAL(tc, NUM_FILES, result->nelts);
 
38
 
 
39
    list = (char **)result->elts;
 
40
    for (i = 0; i < result->nelts; i++) {
 
41
        char *dot = strrchr(list[i], '.');
 
42
        ABTS_STR_EQUAL(tc, dot, ".txt");
 
43
    }
 
44
}
 
45
 
 
46
static void test_glob_currdir(abts_case *tc, void *data)
 
47
{
 
48
    int i;
 
49
    char **list;
 
50
    apr_array_header_t *result;
 
51
    apr_filepath_set("data", p);
 
52
    
 
53
    APR_ASSERT_SUCCESS(tc, "glob match against *.txt with data as current",
 
54
                       apr_match_glob("*.txt", &result, p));
 
55
 
 
56
 
 
57
    ABTS_INT_EQUAL(tc, NUM_FILES, result->nelts);
 
58
 
 
59
    list = (char **)result->elts;
 
60
    for (i = 0; i < result->nelts; i++) {
 
61
        char *dot = strrchr(list[i], '.');
 
62
        ABTS_STR_EQUAL(tc, dot, ".txt");
 
63
    }
 
64
    apr_filepath_set("..", p);
 
65
}
 
66
 
 
67
abts_suite *testfnmatch(abts_suite *suite)
 
68
{
 
69
    suite = ADD_SUITE(suite)
 
70
 
 
71
    abts_run_test(suite, test_glob, NULL);
 
72
    abts_run_test(suite, test_glob_currdir, NULL);
 
73
 
 
74
    return suite;
 
75
}
 
76