From 0fc57128fb676598757eff37392da2227991498d Mon Sep 17 00:00:00 2001 From: Mikhail Romanko Date: Sun, 9 Nov 2025 10:58:17 +0300 Subject: [PATCH] Evaluate arguments in BH_VERIFY_STR_EQ once --- test/include/BH/Unit.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/include/BH/Unit.h b/test/include/BH/Unit.h index 9f9b3bb..a831ee3 100644 --- a/test/include/BH/Unit.h +++ b/test/include/BH/Unit.h @@ -40,10 +40,13 @@ typedef int (*BH_UnitCallback)(void); #define BH_VERIFY_STR_EQ(actual, expected) \ do { \ - BH_VERIFY((actual) != NULL && (expected) != NULL); \ - if (strcmp((actual), (expected)) != 0) { \ + const char *a, *b; \ + a = (actual); \ + b = (expected); \ + BH_VERIFY(a != NULL && b != NULL); \ + if (strcmp(a, b) != 0) { \ printf("%s:%d\tExpected '%s', got '%s'\n", \ - __FILE__, __LINE__, (expected), (actual)); \ + __FILE__, __LINE__, a, b); \ return -1; \ } \ } while(0)