From: tsutsumi <> Date: Mon, 8 Sep 2003 15:35:21 +0000 (+0000) Subject: fix multiple evaluate parameters. X-Git-Tag: rel-0-3~52 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7acf2ba727dec3b3aa075417ad0613a31afc4b92;p=ccunit%2Fccunit.git fix multiple evaluate parameters. --- diff --git a/src/ccunit/CCUnitAssert.h b/src/ccunit/CCUnitAssert.h index 2240fcf..372f1fe 100644 --- a/src/ccunit/CCUnitAssert.h +++ b/src/ccunit/CCUnitAssert.h @@ -35,6 +35,7 @@ */ extern void ccunit_assert (const char* file, unsigned int line, bool cond, const char* condstr); + /** * Check for a failed assertion. * @param file file name. @@ -63,9 +64,12 @@ extern void ccunit_assert_test (const char* file, unsigned int line, * @param ACTUAL actual value. */ #define CCUNIT_ASSERT_TEST(VFMT, TYP, EXPECT, OP, ACTUAL) \ - ccunit_assert_test (__FILE__, __LINE__, (EXPECT) OP (ACTUAL), \ - (#EXPECT " " #OP " " #ACTUAL), \ - VFMT, ((TYP)EXPECT), ((TYP)ACTUAL)) + do { \ + TYP ex = (TYP)EXPECT; \ + TYP ac = (TYP)ACTUAL; \ + ccunit_assert_test (__FILE__, __LINE__, ex OP ac, \ + (#EXPECT " " #OP " " #ACTUAL), VFMT, ex, ac); \ + } while (0) #define CCUNIT_ASSERT_TEST_INT(EXPECT, OP, ACTUAL) \ CCUNIT_ASSERT_TEST ("%d", int, EXPECT, OP, ACTUAL) @@ -88,9 +92,13 @@ extern void ccunit_assert_test (const char* file, unsigned int line, #define CCUNIT_ASSERT_TEST_STR(EXPECT, OP, ACTUAL) \ - ccunit_assert_test (__FILE__, __LINE__, strcmp(EXPECT, ACTUAL) OP 0, \ - "strcmp (" #EXPECT ", " #ACTUAL ") " #OP " 0", \ - "%s", (char*)EXPECT, (char*)ACTUAL) + do { \ + const char* ex = EXPECT; \ + const char* ac = ACTUAL; \ + ccunit_assert_test (__FILE__, __LINE__, strcmp(ex, ac) OP 0, \ + "strcmp (" #EXPECT ", " #ACTUAL ") " #OP " 0", \ + "%s", ex, ac); \ + } while (0) #define CCUNIT_ASSERT_NULL(ACTUAL) \ CCUNIT_ASSERT_TEST_PTR(NULL, ==, ACTUAL)