Apache HTTPD
teststrmatch.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. 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
19#include "apr.h"
20#include "apr_general.h"
21#include "apr_strmatch.h"
22#if APR_HAVE_STDLIB_H
23#include <stdlib.h>
24#endif
25#define APR_WANT_STDIO
26#define APR_WANT_STRFUNC
27#include "apr_want.h"
28
29static void test_str(abts_case *tc, void *data)
30{
31 apr_pool_t *pool = p;
36 const char *match = NULL;
37 const char *input1 = "string that contains a patterN...";
38 const char *input2 = "string that contains a pattern...";
39 const char *input3 = "pattern at the start of a string";
40 const char *input4 = "string that ends with a pattern";
41 const char *input5 = "patter\200n not found, negative chars in input";
42 const char *input6 = "patter\200n, negative chars, contains pattern...";
43
44 pattern = apr_strmatch_precompile(pool, "pattern", 1);
46
49
52
55
58
60 ABTS_PTR_EQUAL(tc, input2 + 23, match);
61
63 ABTS_PTR_EQUAL(tc, input1 + 5, match);
64
67
69 ABTS_PTR_EQUAL(tc, input1 + 23, match);
70
73
75 ABTS_PTR_EQUAL(tc, input4 + 24, match);
76
79
81 ABTS_PTR_EQUAL(tc, input6 + 35, match);
82}
83
85{
86 suite = ADD_SUITE(suite);
87
89
90 return suite;
91}
92
int int const char ** match
Definition ap_regex.h:279
const char * pattern
Definition ap_regex.h:243
void abts_run_test(abts_suite *ts, test_func f, void *value)
Definition abts.c:175
#define ABTS_PTR_EQUAL(a, b, c)
Definition abts.h:126
#define ADD_SUITE(suite)
Definition abts.h:67
#define ABTS_PTR_NOTNULL(a, b)
Definition abts.h:125
APR Miscellaneous library routines.
APR-UTIL string matching routines.
APR Standard Headers Support.
#define apr_strmatch(pattern, s, slen)
apr_size_t size
const char int apr_pool_t * pool
Definition apr_cstr.h:84
void * data
apr_pool_t * p
Definition md_event.c:32
return NULL
Definition mod_so.c:359
abts_suite * teststrmatch(abts_suite *suite)
static void test_str(abts_case *tc, void *data)