From f14130fc2d14ca49c9d51e9eec6a443ba035e3b1 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Sat, 20 Feb 2021 05:10:19 +0000 Subject: [PATCH] Wrap TEST_ASSERT with do...while(0) Fix compile errors when doing if (blah) TEST_ASSERT(cond, message) --- util/test/demos/test_common.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/util/test/demos/test_common.h b/util/test/demos/test_common.h index 3f698809f..691472d91 100644 --- a/util/test/demos/test_common.h +++ b/util/test/demos/test_common.h @@ -316,12 +316,15 @@ std::string trim(const std::string &str); void DebugPrint(const char *fmt, ...); -#define TEST_ASSERT(cond, fmt, ...) \ - if(!(cond)) \ - { \ - DebugPrint("%s:%d Assert Failure '%s': " fmt "\n", __FILE__, __LINE__, #cond, ##__VA_ARGS__); \ - DEBUG_BREAK(); \ - } +#define TEST_ASSERT(cond, fmt, ...) \ + do \ + { \ + if(!(cond)) \ + { \ + DebugPrint("%s:%d Assert Failure '%s': " fmt "\n", __FILE__, __LINE__, #cond, ##__VA_ARGS__); \ + DEBUG_BREAK(); \ + } \ + } while(0) #define TEST_LOG(fmt, ...) \ do \