1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
18
#include "apr_file_info.h"
19
#include "apr_fnmatch.h"
20
#include "apr_tables.h"
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 (!?!). */
28
static void test_glob(abts_case *tc, void *data)
32
apr_array_header_t *result;
34
APR_ASSERT_SUCCESS(tc, "glob match against data/*.txt",
35
apr_match_glob("data\\*.txt", &result, p));
37
ABTS_INT_EQUAL(tc, NUM_FILES, result->nelts);
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");
46
static void test_glob_currdir(abts_case *tc, void *data)
50
apr_array_header_t *result;
51
apr_filepath_set("data", p);
53
APR_ASSERT_SUCCESS(tc, "glob match against *.txt with data as current",
54
apr_match_glob("*.txt", &result, p));
57
ABTS_INT_EQUAL(tc, NUM_FILES, result->nelts);
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");
64
apr_filepath_set("..", p);
67
abts_suite *testfnmatch(abts_suite *suite)
69
suite = ADD_SUITE(suite)
71
abts_run_test(suite, test_glob, NULL);
72
abts_run_test(suite, test_glob_currdir, NULL);