Go to the documentation of this file.
64 #define CK_CPPSTART extern "C" {
69 #if defined(__GNUC__) && defined(__GNUC_MINOR__)
70 #define GCC_VERSION_AT_LEAST(major, minor) \
71 ((__GNUC__ > (major)) || \
72 (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
74 #define GCC_VERSION_AT_LEAST(major, minor) 0
77 #if GCC_VERSION_AT_LEAST(2,95)
78 #define CK_ATTRIBUTE_UNUSED __attribute__ ((unused))
80 #define CK_ATTRIBUTE_UNUSED
83 #ifdef HAVE_SYS_TYPES_H
84 #include <sys/types.h>
100 #define CHECK_MAJOR_VERSION (0)
101 #define CHECK_MINOR_VERSION (9)
102 #define CHECK_MICRO_VERSION (6)
109 #define NULL ((void*)0)
143 #define tcase_add_test(tc,tf) tcase_add_test_raise_signal(tc,tf,0)
146 #define tcase_add_test_raise_signal(tc,tf,signal) \
147 _tcase_add_test((tc),(tf),"" # tf "",(signal), 0, 0, 1)
150 #define tcase_add_exit_test(tc, tf, expected_exit_value) \
151 _tcase_add_test((tc),(tf),"" # tf "",0,(expected_exit_value),0,1)
159 #define tcase_add_loop_test(tc,tf,s,e) \
160 _tcase_add_test((tc),(tf),"" # tf "",0,0,(s),(e))
165 #define tcase_add_loop_test_raise_signal(tc,tf,signal,s,e) \
166 _tcase_add_test((tc),(tf),"" # tf "",(signal),0,(s),(e))
169 #define tcase_add_loop_exit_test(tc,tf,expected_exit_value,s,e) \
170 _tcase_add_test((tc),(tf),"" # tf "",0,(expected_exit_value),(s),(e))
220 #define START_TEST(__testname)\
221 static void __testname (int _i CK_ATTRIBUTE_UNUSED)\
223 tcase_fn_start (""# __testname, __FILE__, __LINE__);
232 #define fail_unless(expr, ...)\
233 _fail_unless(expr, __FILE__, __LINE__,\
234 "Assertion '"#expr"' failed" , ## __VA_ARGS__, NULL)
243 #define fail_if(expr, ...)\
244 _fail_unless(!(expr), __FILE__, __LINE__,\
245 "Failure '"#expr"' occured" , ## __VA_ARGS__, NULL)
248 #define fail(...) _fail_unless(0, __FILE__, __LINE__, "Failed" , ## __VA_ARGS__, NULL)
252 int line,
const char *expr, ...);
255 #define ck_abort() ck_abort_msg(NULL)
256 #define ck_abort_msg fail
257 #define ck_assert(C) ck_assert_msg(C, NULL)
258 #define ck_assert_msg fail_unless
262 #define _ck_assert_int(X, OP, Y) do { \
265 ck_assert_msg(_ck_x OP _ck_y, "Assertion '"#X#OP#Y"' failed: "#X"==%d, "#Y"==%d", _ck_x, _ck_y); \
267 #define ck_assert_int_eq(X, Y) _ck_assert_int(X, ==, Y)
268 #define ck_assert_int_ne(X, Y) _ck_assert_int(X, !=, Y)
269 #define ck_assert_int_lt(X, Y) _ck_assert_int(X, <, Y)
270 #define ck_assert_int_le(X, Y) _ck_assert_int(X, <=, Y)
271 #define ck_assert_int_gt(X, Y) _ck_assert_int(X, >, Y)
272 #define ck_assert_int_ge(X, Y) _ck_assert_int(X, >=, Y)
277 #define _ck_assert_str(X, OP, Y) do { \
278 const char* _ck_x = (X); \
279 const char* _ck_y = (Y); \
280 ck_assert_msg(0 OP strcmp(_ck_y, _ck_x), \
281 "Assertion '"#X#OP#Y"' failed: "#X"==\"%s\", "#Y"==\"%s\"", _ck_x, _ck_y); \
283 #define ck_assert_str_eq(X, Y) _ck_assert_str(X, ==, Y)
284 #define ck_assert_str_ne(X, Y) _ck_assert_str(X, !=, Y)
285 #define ck_assert_str_lt(X, Y) _ck_assert_str(X, <, Y)
286 #define ck_assert_str_le(X, Y) _ck_assert_str(X, <=, Y)
287 #define ck_assert_str_gt(X, Y) _ck_assert_str(X, >, Y)
288 #define ck_assert_str_ge(X, Y) _ck_assert_str(X, >=, Y)
294 #define mark_point() _mark_point(__FILE__,__LINE__)