|
@@ -123,38 +123,40 @@
|
|
|
|
|
|
|
|
|
#define EXPECT_DECLS \
|
|
|
- int _ret = 0
|
|
|
+ int _ret = TEST_SKIPPED
|
|
|
#define EXPECT_RESULT() \
|
|
|
- ((_ret == 0) ? TEST_SUCCESS : TEST_FAIL)
|
|
|
+ _ret
|
|
|
#define EXPECT_SUCCESS() \
|
|
|
- (_ret == 0)
|
|
|
+ (_ret == TEST_SUCCESS)
|
|
|
#define EXPECT_FAIL() \
|
|
|
- (_ret != 0)
|
|
|
+ (_ret == TEST_FAIL)
|
|
|
|
|
|
#define ExpFail(description, result) do { \
|
|
|
printf("\nERROR - %s line %d failed with:", __FILE__, __LINE__); \
|
|
|
fputs("\n expected: ", stdout); printf description; \
|
|
|
fputs("\n result: ", stdout); printf result; fputs("\n\n", stdout); \
|
|
|
fflush(stdout); \
|
|
|
- _ret = -1; \
|
|
|
+ _ret = TEST_FAIL; \
|
|
|
} while (0)
|
|
|
|
|
|
-#define Expect(test, description, result) \
|
|
|
- if ((_ret == 0) && (!(test))) ExpFail(description, result)
|
|
|
+#define Expect(test, description, result) do { \
|
|
|
+ if (_ret != TEST_FAIL) { if (!(test)) ExpFail(description, result); \
|
|
|
+ else _ret = TEST_SUCCESS; } \
|
|
|
+} while (0)
|
|
|
|
|
|
#define ExpectTrue(x) Expect( (x), ("%s is true", #x), (#x " => FALSE"))
|
|
|
#define ExpectFalse(x) Expect(!(x), ("%s is false", #x), (#x " => TRUE"))
|
|
|
#define ExpectNotNull(x) Expect( (x), ("%s is not null", #x), (#x " => NULL"))
|
|
|
|
|
|
#define ExpectNull(x) do { \
|
|
|
- if (_ret == 0) { \
|
|
|
+ if (_ret != TEST_FAIL) { \
|
|
|
PEDANTIC_EXTENSION void* _x = (void*)(x); \
|
|
|
Expect(!_x, ("%s is null", #x), (#x " => %p", _x)); \
|
|
|
} \
|
|
|
} while(0)
|
|
|
|
|
|
#define ExpectInt(x, y, op, er) do { \
|
|
|
- if (_ret == 0) { \
|
|
|
+ if (_ret != TEST_FAIL) { \
|
|
|
int _x = (int)(x); \
|
|
|
int _y = (int)(y); \
|
|
|
Expect(_x op _y, ("%s " #op " %s", #x, #y), ("%d " #er " %d", _x, _y));\
|
|
@@ -169,7 +171,7 @@
|
|
|
#define ExpectIntLE(x, y) ExpectInt(x, y, <=, >)
|
|
|
|
|
|
#define ExpectStr(x, y, op, er) do { \
|
|
|
- if (_ret == 0) { \
|
|
|
+ if (_ret != TEST_FAIL) { \
|
|
|
const char* _x = (const char*)(x); \
|
|
|
const char* _y = (const char*)(y); \
|
|
|
int _z = (_x && _y) ? strcmp(_x, _y) : -1; \
|
|
@@ -186,7 +188,7 @@
|
|
|
#define ExpectStrLE(x, y) ExpectStr(x, y, <=, >)
|
|
|
|
|
|
#define ExpectPtr(x, y, op, er) do { \
|
|
|
- if (_ret == 0) { \
|
|
|
+ if (_ret != TEST_FAIL) { \
|
|
|
PRAGMA_DIAG_PUSH; \
|
|
|
/* remarkably, without this inhibition, */ \
|
|
|
/* the _Pragma()s make the declarations warn. */ \
|
|
@@ -209,7 +211,7 @@
|
|
|
#define ExpectPtrLE(x, y) ExpectPtr(x, y, <=, >)
|
|
|
|
|
|
#define ExpectBuf(x, y, z, op, er) do { \
|
|
|
- if (_ret == 0) { \
|
|
|
+ if (_ret != TEST_FAIL) { \
|
|
|
const byte* _x = (const byte*)(x); \
|
|
|
const byte* _y = (const byte*)(y); \
|
|
|
int _z = (int)(z); \
|