diff --git a/include/CppUTest/UtestMacros.h b/include/CppUTest/UtestMacros.h index 743bf069e..b266aa3f7 100644 --- a/include/CppUTest/UtestMacros.h +++ b/include/CppUTest/UtestMacros.h @@ -131,9 +131,9 @@ #define CHECK_EQUAL_LOCATION(expected, actual, text, file, line)\ do { if ((expected) != (actual)) { \ - if ((actual) != (actual)) \ + if (StringFrom(actual) != StringFrom(actual)) \ UtestShell::getCurrent()->print("WARNING:\n\tThe \"Actual Parameter\" parameter is evaluated multiple times resulting in different values.\n\tThus the value in the error message is probably incorrect.", file, line); \ - if ((expected) != (expected)) \ + if (StringFrom(expected) != StringFrom(expected)) \ UtestShell::getCurrent()->print("WARNING:\n\tThe \"Expected Parameter\" parameter is evaluated multiple times resulting in different values.\n\tThus the value in the error message is probably incorrect.", file, line); \ UtestShell::getCurrent()->assertEquals(true, StringFrom(expected).asCharString(), StringFrom(actual).asCharString(), text, file, line); \ } \ diff --git a/tests/CppUTest/TestUTestMacro.cpp b/tests/CppUTest/TestUTestMacro.cpp index ecc07a619..b6ce1f8a2 100644 --- a/tests/CppUTest/TestUTestMacro.cpp +++ b/tests/CppUTest/TestUTestMacro.cpp @@ -489,6 +489,13 @@ TEST(UnitTestMacros, failing_CHECK_EQUAL_withParamatersThatDontChangeWillNotGive fixture.assertPrintContainsNot("WARNING"); } +TEST(UnitTestMacros, CHECK_EQUAL_compilesWithArrayOperand) +{ + const char buf[] = "hello"; + const char* actual = buf; + CHECK_EQUAL(buf, actual); +} + TEST(UnitTestMacros, CHECK_EQUALBehavesAsProperMacro) { if (false) CHECK_EQUAL(1, 2);