Allow external override for XLATE support.
[apr-util.git] / test / test_apu.h
blob8d5f6ddee21767c70f6150c044baba283f06afa6
1 /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
2 * applicable.
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.
17 /* Some simple functions to make the test apps easier to write and
18 * a bit more consistent...
19 * this is a >copy< of apr_test.h
22 /* Things to bear in mind when using these...
24 * If you include '\t' within the string passed in it won't be included
25 * in the spacing, so use spaces instead :)
27 */
29 #ifndef APU_TEST_INCLUDES
30 #define APU_TEST_INCLUDES
32 #include "apr_strings.h"
33 #include "apr_time.h"
35 #define TEST_EQ(str, func, value, good, bad) \
36 printf("%-60s", str); \
37 { \
38 apr_status_t rv; \
39 if ((rv = func) == value){ \
40 char errmsg[200]; \
41 printf("%s\n", bad); \
42 fprintf(stderr, "Error was %d : %s\n", rv, \
43 apr_strerror(rv, (char*)&errmsg, 200)); \
44 exit(-1); \
45 } \
46 printf("%s\n", good); \
49 #define TEST_NEQ(str, func, value, good, bad) \
50 printf("%-60s", str); \
51 { \
52 apr_status_t rv; \
53 if ((rv = func) != value){ \
54 char errmsg[200]; \
55 printf("%s\n", bad); \
56 fprintf(stderr, "Error was %d : %s\n", rv, \
57 apr_strerror(rv, (char*)&errmsg, 200)); \
58 exit(-1); \
59 } \
60 printf("%s\n", good); \
63 #define TEST_STATUS(str, func, testmacro, good, bad) \
64 printf("%-60s", str); \
65 { \
66 apr_status_t rv = func; \
67 if (!testmacro(rv)) { \
68 char errmsg[200]; \
69 printf("%s\n", bad); \
70 fprintf(stderr, "Error was %d : %s\n", rv, \
71 apr_strerror(rv, (char*)&errmsg, 200)); \
72 exit(-1); \
73 } \
74 printf("%s\n", good); \
77 #define STD_TEST_NEQ(str, func) \
78 TEST_NEQ(str, func, APR_SUCCESS, "OK", "Failed");
80 #define PRINT_ERROR(rv) \
81 { \
82 char errmsg[200]; \
83 fprintf(stderr, "Error was %d : %s\n", rv, \
84 apr_strerror(rv, (char*)&errmsg, 200)); \
85 exit(-1); \
88 #define MSG_AND_EXIT(msg) \
89 printf("%s\n", msg); \
90 exit (-1);
92 #define TIME_FUNCTION(time, function) \
93 { \
94 apr_time_t tt = apr_time_now(); \
95 function; \
96 time = apr_time_now() - tt; \
100 #endif /* APU_TEST_INCLUDES */