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"
14 #include <libtest/stream.h>
15 #include <libtest/comparison.hpp>
18 A structure describing the test case.
23 test_callback_fn
*test_fn
;
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(__expected, __hint) \
72 if (not libtest::_compare_true_hint(__FILE__, __LINE__, __func__, ((__expected)), #__expected, ((__hint)))) \
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; \
119 #define test_compare(__expected, __actual) \
122 if (not libtest::_compare(__FILE__, __LINE__, __func__, ((__expected)), ((__actual)))) \
125 return TEST_FAILURE; \
129 #define test_zero(__actual) \
132 if (not libtest::_compare_zero(__FILE__, __LINE__, __func__, ((__actual)))) \
135 return TEST_FAILURE; \
139 #define test_compare_got(__expected, __actual, __hint) \
142 if (not libtest::_compare_hint(__FILE__, __LINE__, __func__, (__expected), (__actual), (__hint))) \
145 return TEST_FAILURE; \
150 #define test_strcmp(A,B) \
153 if (strcmp((A), (B))) \
155 fprintf(stderr, "\n%s:%d: Expected %s, got %s\n", __FILE__, __LINE__, (A), (B)); \
157 return TEST_FAILURE; \
161 #define test_memcmp(A,B,C) \
164 if (memcmp((A), (B), (C))) \
166 fprintf(stderr, "\n%s:%d: %.*s -> %.*s\n", __FILE__, __LINE__, (int)(C), (char *)(A), (int)(C), (char *)(B)); \
168 return TEST_FAILURE; \
172 #define test_return_if(__test_return_t) \
175 if ((__test_return_t) != TEST_SUCCESS) \
177 return __test_return_t; \