136 #define TSTNAME name, __func__, "() " 138 #define TSTNAME name, __FUNCTION__, "() " 140 #define TSTNAME name, "", "" 153 #error <TSTFLAGS is not defined> 157 #define BEGIN() BEGIN_(TSTFLAGS); { extern int tstdef_dummy 159 #define END() (void) tstdef_dummy; } END_(TSTFLAGS) 163 #define TEST0(suite) TEST_1_(TSTFLAGS, suite) 165 #define TEST_1(suite) TEST_1_(TSTFLAGS, suite) 167 #define TEST_VOID(suite) TEST_VOID_(TSTFLAGS, suite) 169 #define TEST(suite, expected) TEST_(TSTFLAGS, suite, expected) 171 #define TEST_P(suite, expected) TEST_P_(TSTFLAGS, suite, expected) 173 #define TEST64(suite, expected) TEST64_(TSTFLAGS, suite, expected) 175 #define TEST_D(suite, expected) TEST_D_(TSTFLAGS, suite, expected) 177 #define TEST_S(suite, expected) TEST_S_(TSTFLAGS, suite, expected) 179 #define TEST_M(suite, expected, len) TEST_M_(TSTFLAGS, suite, expected, len) 181 #define TEST_SIZE(suite, expected) TEST_SIZE_(TSTFLAGS, suite, expected) 184 #define TEST_LOG(x) \ 186 if (tstflags & tst_log) \ 190 #define TEST_FAILED(flags) \ 191 ((flags) & tst_abort) ? abort() : (void)0; return 1 194 #define TEST_1_(flags, suite) do { \ 195 if (flags & tst_verbatim) { \ 196 printf("%s: %s%stesting %s\n", TSTNAME, #suite); \ 198 if ((suite)) { if (flags & tst_verbatim) \ 199 printf("%s: %s%sok: (%s)\n", TSTNAME, #suite); break ; } \ 200 fprintf(stderr, "%s:%u: %s %s%sFAILED: (%s)\n", \ 201 __FILE__, __LINE__, TSTNAME, #suite); fflush(stderr); \ 202 TEST_FAILED(flags); } \ 206 #define TEST_VOID_(flags, suite) do { \ 207 if (flags & tst_verbatim) { \ 208 printf("%s: %s%stesting %s\n", TSTNAME, #suite); \ 213 #define TEST_(flags, suite, expect) do { \ 214 uintptr_t _value, _expect; \ 215 if (flags & tst_verbatim) { \ 216 printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \ 218 _value = (uintptr_t)(suite); \ 219 _expect = (uintptr_t)(expect); \ 220 if (_value == _expect) { \ 221 if (flags & tst_verbatim) \ 222 printf("%s: %s%sok: %s == %s \n", \ 223 TSTNAME, #suite, #expect); \ 226 fprintf(stderr, "%s:%u: %s %s%sFAILED: " \ 227 "%s != %s or "MOD_ZU" != "MOD_ZU"\n", \ 228 __FILE__, __LINE__, TSTNAME, \ 229 #suite, #expect, (size_t)_value, (size_t)_expect); \ 231 TEST_FAILED(flags); \ 235 #define TEST_P_(flags, suite, expect) do { \ 236 void const * _value, * _expect; \ 237 if (flags & tst_verbatim) { \ 238 printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \ 240 if ((_value = (suite)) == (_expect = (expect))) { \ 241 if (flags & tst_verbatim) \ 242 printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); \ 245 fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %p != %p\n", \ 246 __FILE__, __LINE__, TSTNAME, \ 247 #suite, #expect, _value, _expect); fflush(stderr); \ 248 TEST_FAILED(flags); \ 252 #define TEST_SIZE_(flags, suite, expect) do { \ 253 size_t _value, _expect; \ 254 if (flags & tst_verbatim) { \ 255 printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \ 257 if ((_value = (size_t)(suite)) == \ 258 (_expect = (size_t)(expect))) \ 259 { if (flags & tst_verbatim) \ 260 printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); break; } \ 261 fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or "MOD_ZU" != "MOD_ZU"\n", \ 262 __FILE__, __LINE__, TSTNAME, \ 263 #suite, #expect, _value, _expect); fflush(stderr); \ 264 TEST_FAILED(flags); \ 269 #define TEST64_(flags, suite, expect) do { \ 270 uint64_t _value, _expect; \ 271 if (flags & tst_verbatim) { \ 272 printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \ 274 if ((_value = (uint64_t)(suite)) == (_expect = (uint64_t)(expect))) \ 275 { if (flags & tst_verbatim) \ 276 printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); break; } \ 277 fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or "LLU" != "LLU"\n", \ 278 __FILE__, __LINE__, TSTNAME, \ 279 #suite, #expect, (unsigned longlong)_value, \ 280 (unsigned longlong)_expect); fflush(stderr); \ 281 TEST_FAILED(flags); \ 285 #define TEST_D_(flags, suite, expect) do { \ 286 double _value, _expect; \ 287 if (flags & tst_verbatim) { \ 288 printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \ 290 if ((_value = (double)(suite)) == (_expect = (double)(expect))) \ 291 { if (flags & tst_verbatim) \ 292 printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); break; } \ 293 fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %g != %g\n", \ 294 __FILE__, __LINE__, TSTNAME, \ 295 #suite, #expect, _value, _expect); fflush(stderr); \ 296 TEST_FAILED(flags); \ 300 #define TEST_S_(flags, suite, expect) do { \ 301 char const * _value, * _expect; \ 302 if (flags & tst_verbatim) { \ 303 printf("%s: %s%stesting %s is %s\n", TSTNAME, #suite, #expect); \ 306 _expect = (expect); \ 307 if (((_value == NULL || _expect == NULL) && _value == _expect) || \ 308 (_value != NULL && _expect != NULL && strcmp(_value, _expect) == 0)) \ 309 { if (flags & tst_verbatim) \ 310 printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect);break;}\ 311 fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %s%s%s != \"%s\"\n", \ 312 __FILE__, __LINE__, TSTNAME, \ 314 _value ? "\"" : "", _value ? _value : "NULL", _value ? "\"" : "", \ 315 _expect); fflush(stderr); \ 316 TEST_FAILED(flags); \ 320 #define TEST_M_(flags, suite, expect, len) do { \ 321 void const * _value, * _expect; \ 323 if (flags & tst_verbatim) { \ 324 printf("%s: %s%stesting %s is %s\n", TSTNAME, #suite, #expect); \ 327 _expect = (expect); \ 328 _len = (size_t)(len); \ 329 if (((_value == NULL || _expect == NULL) && _value == _expect) || \ 330 memcmp(_value, _expect, _len) == 0) \ 331 { if (flags & tst_verbatim) \ 332 printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect);break;}\ 333 fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s "\ 334 "or \"%.*s\" != \"%.*s\"\n", \ 335 __FILE__, __LINE__, TSTNAME, \ 336 #suite, #expect, (int)_len, \ 337 (char *)_value, (int)_len, (char *)_expect); \ 339 TEST_FAILED(flags); \ 343 #define BEGIN_(flags) \ 344 if (flags & tst_verbatim) printf("%s: %s%sstarting\n", TSTNAME) 347 #define END_(flags) \ 348 if (flags & tst_verbatim) \ 349 printf("%s: %s%sfinished fully successful\n", TSTNAME); \ If (TSTFLAGS & tst_verbatim) is non-zero, be verbatim.
Definition: tstdef.h:145
Basic integer types for su library.
If (TSTFLAGS & tst_log) is non-zero, log intermediate results.
Definition: tstdef.h:149
If (TSTFLAGS & tst_abort) is non-zero, abort() when failed.
Definition: tstdef.h:147