16 #ifndef CPPUNIT_EXPECT_H
17 #define CPPUNIT_EXPECT_H
18 #if __cplusplus >= 201103L || defined(DOXYGEN)
26 #define EXPECT_EQ(expected, actual, msg) \
27 static_assert(std::is_integral<decltype(expected)>::value, \
28 "EXPECT_EQ requires an integral type "); \
29 if ((actual) != (expected)) { \
31 if (std::is_same<decltype(expected), bool>::value) { \
32 printf("Expected: %s, actual: %s\n" msg "\n", (expected) ? "true" : "false", \
33 (actual) ? "true" : "false"); \
35 else if (std::is_unsigned<decltype(expected)>::value) { \
36 printf("Expected: %u, actual: %u\n" msg "\n", static_cast<unsigned>(expected), \
37 static_cast<unsigned>(actual)); \
40 printf("Expected: %d, actual: %d\n" msg "\n", static_cast<int>(expected), \
41 static_cast<int>(actual)); \
52 #define EXPECT_STREQ(expected, actual, msg) \
53 auto expected_str = static_cast<const char*>(expected); \
54 auto actual_str = static_cast<const char*>(actual); \
55 if (strcmp(expected_str, actual_str) != 0) { \
57 printf(msg " not equal! Expected: %s, actual: %s\n", expected_str, actual_str); \
60 #error This library needs C++11 and newer