src/cx/test.h

changeset 890
54565fd74e74
parent 814
5f9e07d3dd6c
equal deleted inserted replaced
889:f549fd9fbd8f 890:54565fd74e74
94 #ifndef UCX_COMMON_H 94 #ifndef UCX_COMMON_H
95 /** 95 /**
96 * Function pointer compatible with fwrite-like functions. 96 * Function pointer compatible with fwrite-like functions.
97 */ 97 */
98 typedef size_t (*cx_write_func)( 98 typedef size_t (*cx_write_func)(
99 void const *, 99 const void *,
100 size_t, 100 size_t,
101 size_t, 101 size_t,
102 void * 102 void *
103 ); 103 );
104 #endif // UCX_COMMON_H 104 #endif // UCX_COMMON_H
132 132
133 /** The number of failed tests after the suite has been run. */ 133 /** The number of failed tests after the suite has been run. */
134 unsigned int failure; 134 unsigned int failure;
135 135
136 /** The optional name of this test suite. */ 136 /** The optional name of this test suite. */
137 char const *name; 137 const char *name;
138 138
139 /** 139 /**
140 * Internal list of test cases. 140 * Internal list of test cases.
141 * Use cx_test_register() to add tests to this list. 141 * Use cx_test_register() to add tests to this list.
142 */ 142 */
146 /** 146 /**
147 * Creates a new test suite. 147 * Creates a new test suite.
148 * @param name optional name of the suite 148 * @param name optional name of the suite
149 * @return a new test suite 149 * @return a new test suite
150 */ 150 */
151 static inline CxTestSuite* cx_test_suite_new(char const *name) { 151 static inline CxTestSuite* cx_test_suite_new(const char *name) {
152 CxTestSuite* suite = (CxTestSuite*) malloc(sizeof(CxTestSuite)); 152 CxTestSuite* suite = (CxTestSuite*) malloc(sizeof(CxTestSuite));
153 if (suite != NULL) { 153 if (suite != NULL) {
154 suite->name = name; 154 suite->name = name;
155 suite->success = 0; 155 suite->success = 0;
156 suite->failure = 0; 156 suite->failure = 0;
274 * written to the test suites output stream. 274 * written to the test suites output stream.
275 * @param condition the condition to check 275 * @param condition the condition to check
276 * @param message the message that shall be printed out on failure 276 * @param message the message that shall be printed out on failure
277 */ 277 */
278 #define CX_TEST_ASSERTM(condition,message) if (!(condition)) { \ 278 #define CX_TEST_ASSERTM(condition,message) if (!(condition)) { \
279 char const* _assert_msg_ = message; \ 279 const char *_assert_msg_ = message; \
280 _writefnc_(_assert_msg_, 1, strlen(_assert_msg_), _output_); \ 280 _writefnc_(_assert_msg_, 1, strlen(_assert_msg_), _output_); \
281 _writefnc_(".\n", 1, 2, _output_); \ 281 _writefnc_(".\n", 1, 2, _output_); \
282 _suite_->failure++; \ 282 _suite_->failure++; \
283 longjmp(_env_, 1);\ 283 longjmp(_env_, 1);\
284 } (void) 0 284 } (void) 0

mercurial