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
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 :)
29 #ifndef APU_TEST_INCLUDES
30 #define APU_TEST_INCLUDES
32 #include "apr_strings.h"
35 #define TEST_EQ(str, func, value, good, bad) \
36 printf("%-60s", str); \
39 if ((rv = func) == value){ \
41 printf("%s\n", bad); \
42 fprintf(stderr, "Error was %d : %s\n", rv, \
43 apr_strerror(rv, (char*)&errmsg, 200)); \
46 printf("%s\n", good); \
49 #define TEST_NEQ(str, func, value, good, bad) \
50 printf("%-60s", str); \
53 if ((rv = func) != value){ \
55 printf("%s\n", bad); \
56 fprintf(stderr, "Error was %d : %s\n", rv, \
57 apr_strerror(rv, (char*)&errmsg, 200)); \
60 printf("%s\n", good); \
63 #define TEST_STATUS(str, func, testmacro, good, bad) \
64 printf("%-60s", str); \
66 apr_status_t rv = func; \
67 if (!testmacro(rv)) { \
69 printf("%s\n", bad); \
70 fprintf(stderr, "Error was %d : %s\n", rv, \
71 apr_strerror(rv, (char*)&errmsg, 200)); \
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) \
83 fprintf(stderr, "Error was %d : %s\n", rv, \
84 apr_strerror(rv, (char*)&errmsg, 200)); \
88 #define MSG_AND_EXIT(msg) \
89 printf("%s\n", msg); \
92 #define TIME_FUNCTION(time, function) \
94 apr_time_t tt = apr_time_now(); \
96 time = apr_time_now() - tt; \
100 #endif /* APU_TEST_INCLUDES */