00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef IRPLIB_TEST_H
00021 #define IRPLIB_TEST_H
00022
00023 #ifdef HAVE_CONFIG_H
00024 # include <config.h>
00025 #endif
00026
00027
00028
00029
00030
00031
00032 #include <cpl.h>
00033
00034
00035
00036
00037
00040 #undef CPL_HAS_UNIT_TEST
00041
00042 #if defined CPL_VERSION_CODE && CPL_VERSION_CODE >= CPL_VERSION(4, 1, 0)
00043 #define CPL_HAS_UNIT_TEST
00044 #elif defined cpl_test_rel
00045 #define CPL_HAS_UNIT_TEST
00046 #endif
00047
00048 #ifdef CPL_HAS_UNIT_TEST
00049
00050 #define irplib_test(expr) cpl_test(expr)
00051
00052 #define irplib_test_eq(first, second) cpl_test_eq(first, second)
00053
00054 #define irplib_test_eq_string(first, second) cpl_test_eq_string(first, second)
00055
00056 #define irplib_test_abs(first, second, tolerance) \
00057 cpl_test_abs(first, second, tolerance)
00058
00059 #define irplib_test_rel(first, second, tolerance) \
00060 cpl_test_rel(first, second, tolerance)
00061
00062 #define IRPLIB_TEST_INIT \
00063 cpl_test_init_macro(__FILE__, PACKAGE_BUGREPORT, CPL_MSG_WARNING)
00064
00065 #define IRPLIB_TEST_END return cpl_test_end(0)
00066
00067 #else
00068
00069
00070
00086
00087 #define irplib_test(expr) \
00088 irplib_test_macro(expr, #expr, cpl_func, __FILE__, __LINE__)
00089
00090
00110
00111 #define irplib_test_eq(first, second) \
00112 irplib_test_eq_macro(first, #first, second, #second, \
00113 cpl_func, __FILE__, __LINE__)
00114
00130
00131 #define irplib_test_eq_string(first, second) \
00132 irplib_test_eq_string_macro(first, #first, second, #second, \
00133 cpl_func, __FILE__, __LINE__)
00134
00135
00154
00155 #define irplib_test_abs(first, second, tolerance) \
00156 irplib_test_abs_macro(first, #first, second, #second, \
00157 tolerance, #tolerance, \
00158 cpl_func, __FILE__, __LINE__)
00159
00160
00185
00186 #define irplib_test_rel(first, second, tolerance) \
00187 irplib_test_rel_macro(first, #first, second, #second, \
00188 tolerance, #tolerance, \
00189 cpl_func, __FILE__, __LINE__)
00190
00191
00196
00197 #define IRPLIB_TEST_INIT irplib_test_init_macro(__FILE__)
00198
00199
00204
00205 #define IRPLIB_TEST_END \
00206 return(irplib_test_end_macro(cpl_func, __FILE__, __LINE__) ? \
00207 EXIT_FAILURE : EXIT_SUCCESS)
00208
00209
00210
00211
00212
00213
00214 void
00215 irplib_test_init_macro(const char *file);
00216
00217 unsigned
00218 irplib_test_end_macro(const char *function, const char *file, unsigned line);
00219
00220 void
00221 irplib_test_macro(int expression, const char *expr_string,
00222 const char *function, const char *file, unsigned line);
00223
00224 void
00225 irplib_test_eq_macro(int first, const char *first_string,
00226 int second, const char *second_string,
00227 const char *function, const char *file, unsigned line);
00228 void
00229 irplib_test_eq_string_macro(const char *first, const char *first_string,
00230 const char *second, const char *second_string,
00231 const char *function,
00232 const char *file, unsigned line);
00233 void
00234 irplib_test_abs_macro(double first, const char *first_string,
00235 double second, const char *second_string,
00236 double tolerance, const char *tolerance_string,
00237 const char *function, const char *file, unsigned line);
00238
00239 void
00240 irplib_test_rel_macro(double first, const char *first_string,
00241 double second, const char *second_string,
00242 double tolerance, const char *tolerance_string,
00243 const char *function, const char *file, unsigned line);
00244
00247 #endif
00248 #endif