aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Romanko <me@blankhex.com>2025-11-09 10:58:17 +0300
committerMikhail Romanko <me@blankhex.com>2025-11-09 10:58:17 +0300
commit0fc57128fb676598757eff37392da2227991498d (patch)
tree975025e67fbaf57ff6540c299ed247ba7e365131
parent6d02598e20a126ea159ef4529340b93e5fa7b5ea (diff)
downloadbhlib-0fc57128fb676598757eff37392da2227991498d.tar.gz
Evaluate arguments in BH_VERIFY_STR_EQ once
-rw-r--r--test/include/BH/Unit.h9
1 files 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)