Test: Print expect macros to stderr
Also now properly reporting test case failure.
This commit is contained in:
+4
-3
@@ -6,13 +6,14 @@
|
|||||||
|
|
||||||
#define EXPECT(x) \
|
#define EXPECT(x) \
|
||||||
if (!(x)) { \
|
if (!(x)) { \
|
||||||
printf("\033[31;1mFAIL\033[0m: %s:%d: EXPECT(%s) failed\n", \
|
fprintf(stderr, "\033[31;1mFAIL\033[0m: %s:%d: EXPECT(%s) failed\n", \
|
||||||
__FILE__, __LINE__, #x); \
|
__FILE__, __LINE__, #x); \
|
||||||
|
Test::TestSuite::the().currentTestCaseFailed(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EXPECT_EQ(a, b) \
|
#define EXPECT_EQ(a, b) \
|
||||||
if (a != b) { \
|
if (a != b) { \
|
||||||
std::cout << "\033[31;1mFAIL\033[0m: " << __FILE__ << ":" << __LINE__ \
|
std::cerr << "\033[31;1mFAIL\033[0m: " << __FILE__ << ":" << __LINE__ \
|
||||||
<< ": EXPECT_EQ(" << #a << ", " << #b ") failed with" \
|
<< ": EXPECT_EQ(" << #a << ", " << #b ") failed with" \
|
||||||
<< " lhs='" << a << "' and rhs='" << b << "'" << std::endl; \
|
<< " lhs='" << a << "' and rhs='" << b << "'" << std::endl; \
|
||||||
Test::TestSuite::the().currentTestCaseFailed(); \
|
Test::TestSuite::the().currentTestCaseFailed(); \
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
|
|
||||||
#define EXPECT_NE(a, b) \
|
#define EXPECT_NE(a, b) \
|
||||||
if (a == b) { \
|
if (a == b) { \
|
||||||
std::cout << "\033[31;1mFAIL\033[0m: " << __FILE__ << ":" << __LINE__ \
|
std::cerr << "\033[31;1mFAIL\033[0m: " << __FILE__ << ":" << __LINE__ \
|
||||||
<< ": EXPECT_NE(" << #a << ", " << #b ") failed with" \
|
<< ": EXPECT_NE(" << #a << ", " << #b ") failed with" \
|
||||||
<< " lhs='" << a << "' and rhs='" << b << "'" << std::endl; \
|
<< " lhs='" << a << "' and rhs='" << b << "'" << std::endl; \
|
||||||
Test::TestSuite::the().currentTestCaseFailed(); \
|
Test::TestSuite::the().currentTestCaseFailed(); \
|
||||||
|
|||||||
Reference in New Issue
Block a user