@@ -58,6 +58,8 @@ struct TestCase {
5858
5959#define CHECK_OP (val1, op, val2 ) __ASSERT_OR_CHECK_OP(false , val1, op, val2)
6060
61+ #define CSTR (s ) ((s) ? (s) : " (null)" )
62+
6163#define __ASSERTED (isAssert ) \
6264 test_case.has_failed_assertions = true ; \
6365 if (isAssert) { \
@@ -67,16 +69,16 @@ struct TestCase {
6769#define __ASSERT_OR_CHECK_OP (isAssert, val1, op, val2 ) \
6870 { \
6971 const bool is_string = \
70- std::is_same<decltype (val1), const char *>::value || std::is_same<decltype (val2 ), const char *>::value || \
71- std::is_same<decltype (val1 ), char *>::value || std::is_same<decltype (val2), char *>::value; \
72+ std::is_same<decltype (val1), const char *>::value || std::is_same<decltype (val1 ), char *>::value || \
73+ std::is_same<decltype (val2 ), const char *>::value || std::is_same<decltype (val2), char *>::value; \
7274 if (is_string) { \
7375 if ((std::string (#op) == " ==" ) || (std::string (#op) == " !=" )) { \
7476 const char * str1 = reinterpret_cast <const char *>(val1); \
7577 const char * str2 = reinterpret_cast <const char *>(val2); \
76- if ((std::string (#op) == " ==" && (str1 && str2 && strcmp (str1, str2) != 0 )) || \
78+ if ((std::string (#op) == " ==" && (str1 != str2) && !(str1 && str2 && strcmp (str1, str2) == 0 )) || \
7779 (std::string (#op) == " !=" && (str1 == str2 || (str1 && str2 && strcmp (str1, str2) == 0 )))) { \
7880 printf (" Assertion failed: (%s %s %s),\n\t actual values: %s = \" %s\" , %s = \" %s\"\n\t at %s:%d\n " , \
79- #val1, #op, #val2, #val1, str1, #val2, str2, __FILE__, __LINE__); \
81+ #val1, #op, #val2, #val1, CSTR ( str1) , #val2, CSTR ( str2) , __FILE__, __LINE__); \
8082 __ASSERTED (isAssert) \
8183 } \
8284 } else { \
0 commit comments