From ad2c09798782968a1be0a68fd266dd48c295c446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Fri, 14 Jun 2024 09:15:14 -0700 Subject: [PATCH] Fixed assert when % is used in condition. --- include/bx/macros.h | 4 ++-- tests/macros_test.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/bx/macros.h b/include/bx/macros.h index e9b3348..f8a793c 100644 --- a/include/bx/macros.h +++ b/include/bx/macros.h @@ -285,7 +285,7 @@ #define _BX_ASSERT(_condition, _format, ...) \ BX_MACRO_BLOCK_BEGIN \ if (!BX_IGNORE_C4127(_condition) \ - && bx::assertFunction(bx::Location::current(), "ASSERT " #_condition " -> " _format, ##__VA_ARGS__) ) \ + && bx::assertFunction(bx::Location::current(), "ASSERT %s -> " _format, #_condition, ##__VA_ARGS__) ) \ { \ bx::debugBreak(); \ } \ @@ -294,7 +294,7 @@ #define _BX_ASSERT_LOC(_location, _condition, _format, ...) \ BX_MACRO_BLOCK_BEGIN \ if (!BX_IGNORE_C4127(_condition) \ - && bx::assertFunction(_location, "ASSERT " #_condition " -> " _format, ##__VA_ARGS__) ) \ + && bx::assertFunction(_location, "ASSERT %s -> " _format, #_condition, ##__VA_ARGS__) ) \ { \ bx::debugBreak(); \ } \ diff --git a/tests/macros_test.cpp b/tests/macros_test.cpp index 94a7882..e41268e 100644 --- a/tests/macros_test.cpp +++ b/tests/macros_test.cpp @@ -30,7 +30,7 @@ BX_NO_INLINE void unusedFunction() void testAssert() { - BX_ASSERT(false, "Assert works!"); + BX_ASSERT(false % 1, "Assert works!"); } TEST_CASE("Macros", "") @@ -51,7 +51,7 @@ TEST_CASE("Macros", "") REQUIRE(5 == BX_VA_ARGS_COUNT(1, 2, 3, 4, 5) ); REQUIRE(6 == BX_VA_ARGS_COUNT(1, 2, 3, 4, 5, 6) ); - REQUIRE(0 == bx::strCmp(BX_STRINGIZE(TEST 1234 %^&*), "TEST 1234 %^&*") ); + REQUIRE(0 == bx::strCmp(BX_STRINGIZE(TEST 1234 % 1 ^&*), "TEST 1234 % 1 ^&*") ); { struct PodStruct { int32_t x, y, z; };