aboutsummaryrefslogtreecommitdiff
path: root/tests/include
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-06-16 15:15:40 +0100
committerMark Haines <mark.haines@matrix.org>2015-06-16 15:15:40 +0100
commit76f49cf17780c155dd02d39ebc40e1f62c0c2503 (patch)
treee4194d0feca2ac165ee8335af9155c981c1bbb0b /tests/include
parent11861404e444795a5437dcf193e71f68a96b5a59 (diff)
Add a test for the axolotl API
Diffstat (limited to 'tests/include')
-rw-r--r--tests/include/unittest.hh23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/include/unittest.hh b/tests/include/unittest.hh
index 437ea77..7c65f9f 100644
--- a/tests/include/unittest.hh
+++ b/tests/include/unittest.hh
@@ -53,6 +53,25 @@ void assert_equals(
}
}
+template<typename T>
+void assert_not_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 << "Unexpected: " << expected << std::endl;
+ std::cout << "Actual: " << actual << std::endl;
+ std::exit(1);
+ }
+}
+
void assert_equals(
const char *file,
@@ -77,6 +96,10 @@ void assert_equals(
__FILE__, __LINE__, #expected, #actual, expected, actual, ##__VA_ARGS__ \
)
+#define assert_not_equals(expected, actual, ...) assert_not_equals( \
+ __FILE__, __LINE__, #expected, #actual, expected, actual, ##__VA_ARGS__ \
+)
+
class TestCase {
public:
TestCase(const char *name) { TEST_CASE = name; }