c36572ea00776867f7b30601506b0b8ccd2eccb5
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.
11 A structure describing the test case.
16 test_callback_fn
*test_fn
;
19 #define TEST_STRINGIFY(x) #x
20 #define TEST_TOSTRING(x) TEST_STRINGIFY(x)
21 #define TEST_AT __FILE__ ":" TEST_TOSTRING(__LINE__)
24 #define test_assert_errno(A) \
28 fprintf(stderr, "\nAssertion failed at %s:%d: ", __FILE__, __LINE__);\
30 fprintf(stderr, "\n"); \
36 #define test_assert(A, B) \
40 fprintf(stderr, "\nAssertion, %s(%s), failed at %s:%d: ", (B), #A, __FILE__, __LINE__);\
41 fprintf(stderr, "\n"); \
47 #define test_truth(A) \
51 fprintf(stderr, "\nAssertion failed at %s:%d: %s\n", __FILE__, __LINE__, #A);\
53 return TEST_FAILURE; \
57 #define test_true(A) \
61 fprintf(stderr, "\nAssertion failed at %s:%d: %s\n", __FILE__, __LINE__, #A);\
63 return TEST_FAILURE; \
67 #define test_true_got(A,B) \
71 fprintf(stderr, "\nAssertion failed at %s:%d: \"%s\" received \"%s\"\n", __FILE__, __LINE__, #A, (B));\
73 return TEST_FAILURE; \
77 #define test_skip(A,B) \
82 return TEST_SKIPPED; \
86 #define test_fail(A) \
90 fprintf(stderr, "\nFailed at %s:%d: %s\n", __FILE__, __LINE__, #A);\
92 return TEST_FAILURE; \
97 #define test_false(A) \
101 fprintf(stderr, "\nAssertion failed in %s:%d: %s\n", __FILE__, __LINE__, #A);\
103 return TEST_FAILURE; \
107 #define test_false_with(A,B) \
111 fprintf(stderr, "\nAssertion failed at %s:%d: %s with %s\n", __FILE__, __LINE__, #A, (B));\
113 return TEST_FAILURE; \
118 #define test_compare(A,B) \
123 fprintf(stderr, "\n%s:%d: Expected %s, got %lu\n", __FILE__, __LINE__, #A, (unsigned long)(B)); \
125 return TEST_FAILURE; \
129 #define test_compare_got(A,B,C) \
134 fprintf(stderr, "\n%s:%d: Expected %s, got %s\n", __FILE__, __LINE__, #A, (C)); \
136 return TEST_FAILURE; \
141 #define test_strcmp(A,B) \
144 if (strcmp((A), (B))) \
146 fprintf(stderr, "\n%s:%d: Expected %s, got %s\n", __FILE__, __LINE__, (A), (B)); \
148 return TEST_FAILURE; \
152 #define test_memcmp(A,B,C) \
155 if (memcmp((A), (B), (C))) \
157 fprintf(stderr, "\n%s:%d: %.*s -> %.*s\n", __FILE__, __LINE__, (int)(C), (char *)(A), (int)(C), (char *)(B)); \
159 return TEST_FAILURE; \