2 * uTest Copyright (C) 2011 Data Differential, http://datadifferential.com/
4 * Use and distribution licensed under the BSD license. See
5 * the COPYING file in the parent directory for full text.
10 #ifndef __INTEL_COMPILER
11 #pragma GCC diagnostic ignored "-Wold-style-cast"
15 A structure describing the test case.
20 test_callback_fn
*test_fn
;
24 bool test_is_local(void);
26 #define test_assert_errno(A) \
30 fprintf(stderr, "\n%s:%d: Assertion failed for %s: ", __FILE__, __LINE__, __func__);\
32 fprintf(stderr, "\n"); \
38 #define test_assert(A, B) \
42 fprintf(stderr, "\n%s:%d: Assertion failed %s, with message %s, in %s", __FILE__, __LINE__, (B), #A, __func__ );\
43 fprintf(stderr, "\n"); \
49 #define test_truth(A) \
53 fprintf(stderr, "\n%s:%d: Assertion \"%s\" failed, in %s\n", __FILE__, __LINE__, #A, __func__);\
55 return TEST_FAILURE; \
59 #define test_true(A) \
63 fprintf(stderr, "\n%s:%d: Assertion \"%s\" failed, in %s\n", __FILE__, __LINE__, #A, __func__);\
65 return TEST_FAILURE; \
69 #define test_true_got(A,B) \
73 fprintf(stderr, "\n%s:%d: Assertion \"%s\" failed, received \"%s\"\n", __FILE__, __LINE__, #A, (B));\
75 return TEST_FAILURE; \
79 #define test_skip(A,B) \
84 return TEST_SKIPPED; \
88 #define test_fail(A) \
92 fprintf(stderr, "\n%s:%d: Failed with %s, in %s\n", __FILE__, __LINE__, #A, __func__);\
94 return TEST_FAILURE; \
99 #define test_false(A) \
103 fprintf(stderr, "\n%s:%d: Assertion failed %s, in %s\n", __FILE__, __LINE__, #A, __func__);\
105 return TEST_FAILURE; \
109 #define test_false_with(A,B) \
113 fprintf(stderr, "\n%s:%d: Assertion failed %s with %s\n", __FILE__, __LINE__, #A, (B));\
115 return TEST_FAILURE; \
120 #define test_compare(A,B) \
125 fprintf(stderr, "\n%s:%d: Expected %s, got %lu\n", __FILE__, __LINE__, #A, (unsigned long)(B)); \
127 return TEST_FAILURE; \
131 #define test_compare_got(A,B,C) \
136 fprintf(stderr, "\n%s:%d: Expected %s, got %s\n", __FILE__, __LINE__, #A, (C)); \
138 return TEST_FAILURE; \
143 #define test_strcmp(A,B) \
146 if (strcmp((A), (B))) \
148 fprintf(stderr, "\n%s:%d: Expected %s, got %s\n", __FILE__, __LINE__, (A), (B)); \
150 return TEST_FAILURE; \
154 #define test_memcmp(A,B,C) \
157 if (memcmp((A), (B), (C))) \
159 fprintf(stderr, "\n%s:%d: %.*s -> %.*s\n", __FILE__, __LINE__, (int)(C), (char *)(A), (int)(C), (char *)(B)); \
161 return TEST_FAILURE; \
165 #define test_return_if(__test_return_t) \
168 if ((__test_return_t) != TEST_SUCCESS) \
170 return __test_return_t; \