Main Page | Modules | Namespace List | Data Structures | File List | Data Fields | Globals | Related Pages

/usr/src/rpmbuilder/BUILD/apr-util-APU_0_9_BRANCH/test/test_apu.h

00001 /* Copyright 2000-2004 The Apache Software Foundation
00002  *
00003  * Licensed under the Apache License, Version 2.0 (the "License");
00004  * you may not use this file except in compliance with the License.
00005  * You may obtain a copy of the License at
00006  *
00007  *     http://www.apache.org/licenses/LICENSE-2.0
00008  *
00009  * Unless required by applicable law or agreed to in writing, software
00010  * distributed under the License is distributed on an "AS IS" BASIS,
00011  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012  * See the License for the specific language governing permissions and
00013  * limitations under the License.
00014  */
00015 
00016 /* Some simple functions to make the test apps easier to write and
00017  * a bit more consistent...
00018  * this is a >copy< of apr_test.h
00019  */
00020 
00021 /* Things to bear in mind when using these...
00022  *
00023  * If you include '\t' within the string passed in it won't be included
00024  * in the spacing, so use spaces instead :)
00025  * 
00026  */ 
00027 
00028 #ifndef APU_TEST_INCLUDES
00029 #define APU_TEST_INCLUDES
00030 
00031 #include "apr_strings.h"
00032 #include "apr_time.h"
00033 
00034 #define TEST_EQ(str, func, value, good, bad) \
00035     printf("%-60s", str); \
00036     { \
00037     apr_status_t rv; \
00038     if ((rv = func) == value){ \
00039         char errmsg[200]; \
00040         printf("%s\n", bad); \
00041         fprintf(stderr, "Error was %d : %s\n", rv, \
00042                 apr_strerror(rv, (char*)&errmsg, 200)); \
00043         exit(-1); \
00044     } \
00045     printf("%s\n", good); \
00046     }
00047 
00048 #define TEST_NEQ(str, func, value, good, bad) \
00049     printf("%-60s", str); \
00050     { \
00051     apr_status_t rv; \
00052     if ((rv = func) != value){ \
00053         char errmsg[200]; \
00054         printf("%s\n", bad); \
00055         fprintf(stderr, "Error was %d : %s\n", rv, \
00056                 apr_strerror(rv, (char*)&errmsg, 200)); \
00057         exit(-1); \
00058     } \
00059     printf("%s\n", good); \
00060     }
00061 
00062 #define TEST_STATUS(str, func, testmacro, good, bad) \
00063     printf("%-60s", str); \
00064     { \
00065         apr_status_t rv = func; \
00066         if (!testmacro(rv)) { \
00067             char errmsg[200]; \
00068             printf("%s\n", bad); \
00069             fprintf(stderr, "Error was %d : %s\n", rv, \
00070                     apr_strerror(rv, (char*)&errmsg, 200)); \
00071             exit(-1); \
00072         } \
00073         printf("%s\n", good); \
00074     }
00075 
00076 #define STD_TEST_NEQ(str, func) \
00077         TEST_NEQ(str, func, APR_SUCCESS, "OK", "Failed");
00078 
00079 #define PRINT_ERROR(rv) \
00080     { \
00081         char errmsg[200]; \
00082         fprintf(stderr, "Error was %d : %s\n", rv, \
00083                 apr_strerror(rv, (char*)&errmsg, 200)); \
00084         exit(-1); \
00085     }
00086 
00087 #define MSG_AND_EXIT(msg) \
00088     printf("%s\n", msg); \
00089     exit (-1);
00090 
00091 #define TIME_FUNCTION(time, function) \
00092     { \
00093         apr_time_t tt = apr_time_now(); \
00094         function; \
00095         time = apr_time_now() - tt; \
00096     }
00097     
00098     
00099 #endif /* APU_TEST_INCLUDES */

Generated on Fri Apr 23 07:22:21 2004 for Apache Portable Runtime Utility Library by doxygen 1.3.4