Merge pull request #5733 from ejohnstown/assert-whitespace

This commit is contained in:
Hayden Roche
2022-10-25 13:45:54 -07:00
committed by GitHub

View File

@ -55,16 +55,14 @@
#define AssertFalse(x) Assert(!(x), ("%s is false", #x), (#x " => TRUE")) #define AssertFalse(x) Assert(!(x), ("%s is false", #x), (#x " => TRUE"))
#define AssertNotNull(x) Assert( (x), ("%s is not null", #x), (#x " => NULL")) #define AssertNotNull(x) Assert( (x), ("%s is not null", #x), (#x " => NULL"))
#define AssertNull(x) do { \ #define AssertNull(x) do { \
PEDANTIC_EXTENSION void* _x = (void *) (x); \ PEDANTIC_EXTENSION void* _x = (void*)(x); \
\ Assert(!_x, ("%s is null", #x), (#x " => %p", _x)); \
Assert(!_x, ("%s is null", #x), (#x " => %p", _x)); \
} while(0) } while(0)
#define AssertInt(x, y, op, er) do { \ #define AssertInt(x, y, op, er) do { \
int _x = (int)(x); \ int _x = (int)(x); \
int _y = (int)(y); \ int _y = (int)(y); \
\
Assert(_x op _y, ("%s " #op " %s", #x, #y), ("%d " #er " %d", _x, _y)); \ Assert(_x op _y, ("%s " #op " %s", #x, #y), ("%d " #er " %d", _x, _y)); \
} while(0) } while(0)
@ -76,10 +74,9 @@
#define AssertIntLE(x, y) AssertInt(x, y, <=, >) #define AssertIntLE(x, y) AssertInt(x, y, <=, >)
#define AssertStr(x, y, op, er) do { \ #define AssertStr(x, y, op, er) do { \
const char* _x = x; \ const char* _x = (const char*)(x); \
const char* _y = y; \ const char* _y = (const char*)(y); \
int _z = (_x && _y) ? strcmp(_x, _y) : -1; \ int _z = (_x && _y) ? strcmp(_x, _y) : -1; \
\
Assert(_z op 0, ("%s " #op " %s", #x, #y), \ Assert(_z op 0, ("%s " #op " %s", #x, #y), \
("\"%s\" " #er " \"%s\"", _x, _y));\ ("\"%s\" " #er " \"%s\"", _x, _y));\
} while(0) } while(0)