You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.8 KiB
38 lines
1.8 KiB
#ifndef TEST_H |
|
#define TEST_H |
|
|
|
#include <cstdio> // fprintf |
|
#include <iostream> // cerr |
|
|
|
#define VERIFY(x, result) \ |
|
if (!(x)) { \ |
|
fprintf(stderr, " \033[31;1mFAIL:\033[0m %s:%d: VERIFY(%s) failed\n", \ |
|
__FILE__, __LINE__, #x); \ |
|
Test::TestSuite::the().currentTestCaseFailed(); \ |
|
result; \ |
|
} |
|
|
|
#define EXPECT(x) \ |
|
if (!(x)) { \ |
|
fprintf(stderr, " \033[31;1mFAIL:\033[0m %s:%d: EXPECT(%s) failed\n", \ |
|
__FILE__, __LINE__, #x); \ |
|
Test::TestSuite::the().currentTestCaseFailed(); \ |
|
} |
|
|
|
#define EXPECT_EQ(a, b) \ |
|
if (a != b) { \ |
|
std::cerr << " \033[31;1mFAIL:\033[0m " << __FILE__ << ":" << __LINE__ \ |
|
<< ": EXPECT_EQ(" << #a << ", " << #b ") failed with" \ |
|
<< " lhs='" << a << "' and rhs='" << b << "'" << std::endl; \ |
|
Test::TestSuite::the().currentTestCaseFailed(); \ |
|
} |
|
|
|
#define EXPECT_NE(a, b) \ |
|
if (a == b) { \ |
|
std::cerr << " \033[31;1mFAIL:\033[0m " << __FILE__ << ":" << __LINE__ \ |
|
<< ": EXPECT_NE(" << #a << ", " << #b ") failed with" \ |
|
<< " lhs='" << a << "' and rhs='" << b << "'" << std::endl; \ |
|
Test::TestSuite::the().currentTestCaseFailed(); \ |
|
} |
|
|
|
#endif // TEST_H
|
|
|