From e803e5916c135293664a16502c2cde21f55b836d Mon Sep 17 00:00:00 2001 From: John Safranek Date: Tue, 25 Oct 2022 11:42:51 -0700 Subject: [PATCH] Assert Consistency 1. Make whitespace in asserts consistent. 2. Added typecasting of the string inputs for AssertStr. --- tests/unit.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/unit.h b/tests/unit.h index 67f431179..3ac29ad19 100644 --- a/tests/unit.h +++ b/tests/unit.h @@ -55,16 +55,14 @@ #define AssertFalse(x) Assert(!(x), ("%s is false", #x), (#x " => TRUE")) #define AssertNotNull(x) Assert( (x), ("%s is not null", #x), (#x " => NULL")) -#define AssertNull(x) do { \ - PEDANTIC_EXTENSION void* _x = (void *) (x); \ - \ - Assert(!_x, ("%s is null", #x), (#x " => %p", _x)); \ +#define AssertNull(x) do { \ + PEDANTIC_EXTENSION void* _x = (void*)(x); \ + Assert(!_x, ("%s is null", #x), (#x " => %p", _x)); \ } while(0) #define AssertInt(x, y, op, er) do { \ int _x = (int)(x); \ int _y = (int)(y); \ - \ Assert(_x op _y, ("%s " #op " %s", #x, #y), ("%d " #er " %d", _x, _y)); \ } while(0) @@ -76,10 +74,9 @@ #define AssertIntLE(x, y) AssertInt(x, y, <=, >) #define AssertStr(x, y, op, er) do { \ - const char* _x = x; \ - const char* _y = y; \ - int _z = (_x && _y) ? strcmp(_x, _y) : -1; \ - \ + const char* _x = (const char*)(x); \ + const char* _y = (const char*)(y); \ + int _z = (_x && _y) ? strcmp(_x, _y) : -1; \ Assert(_z op 0, ("%s " #op " %s", #x, #y), \ ("\"%s\" " #er " \"%s\"", _x, _y));\ } while(0)