1 /* Copyright 2000-2004 The Apache Software Foundation
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 /* Some simple functions to make the test apps easier to write and
17 * a bit more consistent...
18 * this is a >copy< of apr_test.h
21 /* Things to bear in mind when using these...
23 * If you include '\t' within the string passed in it won't be included
24 * in the spacing, so use spaces instead :)
28 #ifndef APU_TEST_INCLUDES
29 #define APU_TEST_INCLUDES
31 #include "apr_strings.h"
34 #define TEST_EQ(str, func, value, good, bad) \
35 printf("%-60s", str); \
38 if ((rv = func) == value){ \
40 printf("%s\n", bad); \
41 fprintf(stderr, "Error was %d : %s\n", rv, \
42 apr_strerror(rv, (char*)&errmsg, 200)); \
45 printf("%s\n", good); \
48 #define TEST_NEQ(str, func, value, good, bad) \
49 printf("%-60s", str); \
52 if ((rv = func) != value){ \
54 printf("%s\n", bad); \
55 fprintf(stderr, "Error was %d : %s\n", rv, \
56 apr_strerror(rv, (char*)&errmsg, 200)); \
59 printf("%s\n", good); \
62 #define TEST_STATUS(str, func, testmacro, good, bad) \
63 printf("%-60s", str); \
65 apr_status_t rv = func; \
66 if (!testmacro(rv)) { \
68 printf("%s\n", bad); \
69 fprintf(stderr, "Error was %d : %s\n", rv, \
70 apr_strerror(rv, (char*)&errmsg, 200)); \
73 printf("%s\n", good); \
76 #define STD_TEST_NEQ(str, func) \
77 TEST_NEQ(str, func, APR_SUCCESS, "OK", "Failed");
79 #define PRINT_ERROR(rv) \
82 fprintf(stderr, "Error was %d : %s\n", rv, \
83 apr_strerror(rv, (char*)&errmsg, 200)); \
87 #define MSG_AND_EXIT(msg) \
88 printf("%s\n", msg); \
91 #define TIME_FUNCTION(time, function) \
93 apr_time_t tt = apr_time_now(); \
95 time = apr_time_now() - tt; \
99 #endif /* APU_TEST_INCLUDES */