mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Assert Consistency
1. Make whitespace in asserts consistent. 2. Added typecasting of the string inputs for AssertStr.
This commit is contained in:
15
tests/unit.h
15
tests/unit.h
@ -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)
|
||||||
|
Reference in New Issue
Block a user