aboutsummaryrefslogtreecommitdiff
path: root/tests/include/unittest.hh
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-02-27 11:36:58 +0000
committerMark Haines <mark.haines@matrix.org>2015-02-27 11:36:58 +0000
commita98acb8f0dc38888631c2dea3de5f9a8e97c569e (patch)
tree36ea694d3996652714c9818ae7a30be7761745bc /tests/include/unittest.hh
parentea1ace8e1ead7374270f0b7c7bc9a1ea24b4dafa (diff)
Test out of order delivery of messages
Diffstat (limited to 'tests/include/unittest.hh')
-rw-r--r--tests/include/unittest.hh15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/include/unittest.hh b/tests/include/unittest.hh
index fb1c90d..437ea77 100644
--- a/tests/include/unittest.hh
+++ b/tests/include/unittest.hh
@@ -36,11 +36,17 @@ char const * TEST_CASE;
template<typename T>
void assert_equals(
+ const char *file,
+ unsigned line,
+ const char *expected_expr,
+ const char *actual_expr,
T const & expected,
T const & actual
) {
if (expected != actual) {
std::cout << "FAILED: " << TEST_CASE << std::endl;
+ std::cout << file << ":" << line << std::endl;
+ std::cout << expected_expr << " == " << actual_expr << std::endl;
std::cout << "Expected: " << expected << std::endl;
std::cout << "Actual: " << actual << std::endl;
std::exit(1);
@@ -49,18 +55,27 @@ void assert_equals(
void assert_equals(
+ const char *file,
+ unsigned line,
+ const char *expected_expr,
+ const char *actual_expr,
std::uint8_t const * expected,
std::uint8_t const * actual,
std::size_t length
) {
if (std::memcmp(expected, actual, length)) {
std::cout << "FAILED: " << TEST_CASE << std::endl;
+ std::cout << file << ":" << line << std::endl;
+ std::cout << expected_expr << " == " << actual_expr << std::endl;
print_hex(std::cout << "Expected: ", expected, length) << std::endl;
print_hex(std::cout << "Actual: ", actual, length) << std::endl;
std::exit(1);
}
}
+#define assert_equals(expected, actual, ...) assert_equals( \
+ __FILE__, __LINE__, #expected, #actual, expected, actual, ##__VA_ARGS__ \
+)
class TestCase {
public: