Loading...
Searching...
No Matches
Go to the documentation of this file.
6#ifndef CLIPM_TESTLIB_DEFINES_H
7#define CLIPM_TESTLIB_DEFINES_H
22#if (defined HAVE_DECL___FUNC__ && !HAVE_DECL___FUNC__)
26#define __func__ __FUNC__
28#define __func__ "unspecified func"
34#define __file__ __FILE__
38#define clipm_testlib_image_save_if_verbose_nr(image, descriptor, nr) \
40 _clipm_testlib_image_save_if_verbose( image, \
48#define clipm_testlib_image_save_if_verbose(image, descriptor) \
50 _clipm_testlib_image_save_if_verbose( image, \
58#define CLIPM_TRY_TESTLIB_ASSERT( CONDITION) \
62 clipm_testlib_msg_error( \
63 "Not fulfilling condition \"%s\"", #CONDITION); \
64 CLIPM_TRY_EXIT_WITH_ERROR( CPL_ERROR_ILLEGAL_OUTPUT); \
68 cpl_msg_indent_more(); \
69 clipm_testlib_msg_debug("Assert: "#CONDITION); \
70 cpl_msg_indent_less(); \
76#define CLIPM_TRY_TESTLIB_ASSERT_ZERO( VALUE, \
81 val = (double)(VALUE); \
82 tol = (double)(TOLERANCE); \
83 if (!(fabs(val) <= tol)) \
86 clipm_testlib_msg_error( \
87 "Not fulfilling condition \"fabs(%s) == %s\"", \
91 clipm_testlib_msg_error( \
92 "Not fulfilling condition \"fabs(%s) < %s\"", \
95 clipm_testlib_msg_error( \
96 "Residual is %g", val); \
97 CLIPM_TRY_EXIT_WITH_ERROR( CPL_ERROR_ILLEGAL_OUTPUT); \
101 cpl_msg_indent_more(); \
103 clipm_testlib_msg_debug( "Assert: \"%s == %s\"", \
107 clipm_testlib_msg_debug( "Assert: \"fabs(%s) <= %s\"", \
110 cpl_msg_indent_less(); \
117#if CLIPM_GET_INSTALLED_CPL_VERSION >= 4
118 #define clipm_testlib_expected_message(EXPECTED, GOT_CODE) \
120 clipm_testlib_msg_error( \
121 "-> expected error %d (%s),", \
123 cpl_error_get_message_default(EXPECTED)); \
124 clipm_testlib_msg_error( \
125 " got error %d (%s),", \
127 cpl_error_get_message_default(GOT_CODE)); \
128 clipm_testlib_msg_error( \
134 #define clipm_testlib_expected_message(EXPECTED, GOT_CODE) \
136 clipm_testlib_msg_error( \
137 "-> expected error %d,", \
139 clipm_testlib_msg_error( \
142 clipm_testlib_msg_error( \
151#if CLIPM_GET_INSTALLED_CPL_VERSION >= 4
152#define CLIPM_TRY_TESTLIB_CHECK_RETURN_ERROR_AND_RECOVER( \
157 cpl_error_code error; \
158 cpl_errorstate state; \
159 state = cpl_errorstate_get(); \
160 clipm_testlib_msg_info("Checking clean abort with error code %d", \
163 cpl_msg_indent_more(); \
164 if (cpl_errorstate_is_equal(state)) \
167 cpl_msg_info( __func__, \
169 cpl_error_get_message(), \
170 cpl_error_get_function()); \
174 if (error != cpl_error_get_code()) \
175 cpl_error_set_message(__func__, CPL_ERROR_ILLEGAL_OUTPUT, \
176 "return error does not match" \
178 cpl_errorstate_dump( state, \
180 clipm_testlib_errorstate_dump_one); \
182 cpl_msg_indent_less(); \
183 if (error != (CODE)) \
185 clipm_testlib_expected_message( CODE, error); \
186 CLIPM_TRY_CHECK_ERROR_STATE(); \
187 CLIPM_TRY_EXIT_WITH_ERROR( CPL_ERROR_ILLEGAL_OUTPUT); \
190 CLIPM_TRY_TESTLIB_ASSERT(OTHER_CONDITION); \
192 CLIPM_ERROR_RECOVER_TRYSTATE(); \
196#define CLIPM_TRY_TESTLIB_CHECK_RETURN_ERROR_AND_RECOVER( \
201 cpl_error_code error; \
202 clipm_testlib_msg_info("Checking clean abort with error code %d", \
205 cpl_msg_indent_more(); \
206 if (error == CPL_ERROR_NONE && cpl_error_get_code() == CPL_ERROR_NONE) \
207 clipm_testlib_msg_info("Successful."); \
210 clipm_testlib_msg_error( "\"%s\" in %s", \
211 cpl_error_get_message(), \
212 cpl_error_get_where()); \
213 if (error != cpl_error_get_code()) \
215 cpl_error_set(__func__, CPL_ERROR_ILLEGAL_OUTPUT); \
216 clipm_testlib_msg_error( "return error does not match" \
220 cpl_msg_indent_less(); \
221 if (error != (CODE)) \
223 clipm_testlib_expected_message( CODE, error); \
224 CLIPM_TRY_CHECK_ERROR_STATE(); \
225 CLIPM_TRY_EXIT_WITH_ERROR( CPL_ERROR_ILLEGAL_OUTPUT); \
228 CLIPM_TRY_TESTLIB_ASSERT(OTHER_CONDITION); \
230 CLIPM_ERROR_RECOVER_TRYSTATE(); \
238#define CLIPM_TRY_TESTLIB_DONT_CHECK( CODE ) \
239 clipm_testlib_msg_info( \
240 "Note: check for error code %d not implemented/possible", \