summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-11-05 16:14:55 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-11-06 12:51:52 +1000
commit036d5e89302058301615b0299c44776ef2cfc38c (patch)
treed5f98d485c6fbceca4d4bf16e231e22ab689162b
parent23d40ceea9c903b676b21bd5793fa1bcf94f142b (diff)
common/helpers: fix ASSERT_ERROR to avoid double-calling its argument
Reported-by: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--tests/common/helpers.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/common/helpers.h b/tests/common/helpers.h
index be2f9e7..3927dab 100644
--- a/tests/common/helpers.h
+++ b/tests/common/helpers.h
@@ -95,8 +95,11 @@ void SetErrorTrap(Display *dpy);
const XErrorEvent* ReleaseErrorTrap(Display *dpy);
#define ASSERT_ERROR(err, code) \
- ASSERT_TRUE(err != NULL) << ("Expected " #code); \
- ASSERT_EQ(code, (int)err->error_code) << ("Expected " #code)
+{ \
+ const XErrorEvent* e = (err); \
+ ASSERT_TRUE(e != NULL) << ("Expected " #code); \
+ ASSERT_EQ(code, (int)e->error_code) << ("Expected " #code); \
+}
#define ASSERT_NO_ERROR(err) \
ASSERT_TRUE(err == NULL) << "Expected no error"