Commit 148ff090 authored by Pekka Pessi's avatar Pekka Pessi

tstdef.h: added TEST_P() and TEST_SIZE().

darcs-hash:20061121192809-65a35-b91137eb08d10cc432888a89b74fa4a74337ca51.gz
parent 17aa88af
......@@ -114,7 +114,7 @@
*
* // Check max bandwidth
* TEST_D(max_bandwidth(), DBL_MAX);
*
*
* END();
* }
* @endcode
......@@ -158,6 +158,8 @@ enum {
#define TEST_VOID(suite) TEST_VOID_(TSTFLAGS, suite)
/** Test that @a suite is equal to @a expected. @HIDE */
#define TEST(suite, expected) TEST_(TSTFLAGS, suite, expected)
/** Test that @a suite is same pointer as @a expected. @HIDE */
#define TEST_P(suite, expected) TEST_P_(TSTFLAGS, suite, expected)
/** Test that 64-bit @a suite is equal to @a expect. @HIDE */
#define TEST64(suite, expected) TEST64_(TSTFLAGS, suite, expected)
/** Test that @a suite is same double as @a expected. @HIDE */
......@@ -166,6 +168,9 @@ enum {
#define TEST_S(suite, expected) TEST_S_(TSTFLAGS, suite, expected)
/** Test that @a suite is results as identical memory as @a expected. @HIDE */
#define TEST_M(suite, expected, len) TEST_M_(TSTFLAGS, suite, expected, len)
/** Test that @a suite has same size as @a expected. @HIDE */
#define TEST_SIZE(suite, expected) TEST_SIZE_(TSTFLAGS, suite, expected)
#else
/* Deprecated */
#define TEST0(flags, suite) TEST_1_(flags, suite)
......@@ -197,20 +202,59 @@ enum {
(suite); } while(0)
/** @HIDE */
#define TEST_(flags, suite, expect) do { \
unsigned long _value, _expect; \
#define TEST_(flags, suite, expect) do { \
uintptr_t _value, _expect; \
if (flags & tst_verbatim) { \
printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \
fflush(stdout); } \
_value = (uintptr_t)(suite); \
_expect = (uintptr_t)(expect); \
if (_value == _expect) { \
if (flags & tst_verbatim) \
printf("%s: %s%sok: %s == %s \n", \
TSTNAME, #suite, #expect); \
break; \
} \
fprintf(stderr, "%s:%u: %s %s%sFAILED: " \
"%s != %s or "MOD_ZU" != "MOD_ZU"\n", \
__FILE__, __LINE__, TSTNAME, \
#suite, #expect, (size_t)_value, (size_t)_expect); \
fflush(stderr); \
return 1; \
} while(0)
/** @HIDE */
#define TEST_P_(flags, suite, expect) do { \
void const * _value, * _expect; \
if (flags & tst_verbatim) { \
printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \
fflush(stdout); } \
if ((_value = (suite)) == (_expect = (expect))) { \
if (flags & tst_verbatim) \
printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); \
break; \
} \
fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %p != %p\n", \
__FILE__, __LINE__, TSTNAME, \
#suite, #expect, _value, _expect); fflush(stderr); return 1; } \
while(0)
/** @HIDE */
#define TEST_SIZE_(flags, suite, expect) do { \
size_t _value, _expect; \
if (flags & tst_verbatim) { \
printf("%s: %s%stesting %s == %s\n", TSTNAME, #suite, #expect); \
fflush(stdout); } \
if ((_value = (unsigned long)(suite)) == \
(_expect = (unsigned long)(expect))) \
if ((_value = (size_t)(suite)) == \
(_expect = (size_t)(expect))) \
{ if (flags & tst_verbatim) \
printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); break; } \
fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %lu != %lu\n", \
fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or "MOD_ZU" != "MOD_ZU"\n", \
__FILE__, __LINE__, TSTNAME, \
#suite, #expect, _value, _expect); fflush(stderr); return 1; } \
#suite, #expect, _value, _expect); fflush(stderr); return 1; } \
while(0)
/** @HIDE */
#define TEST64_(flags, suite, expect) do { \
uint64_t _value, _expect; \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment