summaryrefslogtreecommitdiff
path: root/test/libapt
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2009-11-28 23:27:11 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2009-11-28 23:27:11 +0100
commitcefb7c1f24b3b8c12898f1c8c042970b7a429dca (patch)
treef1942d7d43f69bbf8be0a0ebf001848659d22ad2 /test/libapt
parent2c4b9b0b9e504a9bdfdcb8080bbc3587c11de299 (diff)
add our own equals method as assert doesn't really show the offending
values which causes the failure.
Diffstat (limited to 'test/libapt')
-rw-r--r--test/libapt/assert.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/libapt/assert.h b/test/libapt/assert.h
new file mode 100644
index 000000000..5da76ae0a
--- /dev/null
+++ b/test/libapt/assert.h
@@ -0,0 +1,21 @@
+#include <iostream>
+
+#define equals(x,y) assertEquals(x, y, __LINE__)
+
+template < typename X, typename Y >
+void OutputAssert(X expect, char const* compare, Y get, unsigned long const &line) {
+ std::cerr << "Test FAILED: »" << expect << "« " << compare << " »" << get << "« at line " << line << std::endl;
+}
+
+template < typename X, typename Y >
+void assertEquals(X expect, Y get, unsigned long const &line) {
+ if (expect == get)
+ return;
+ OutputAssert(expect, "==", get, line);
+}
+
+void assertEquals(unsigned int const &expect, int const &get, unsigned long const &line) {
+ if (get < 0)
+ OutputAssert(expect, "==", get, line);
+ assertEquals<unsigned int const&, unsigned int const&>(expect, get, line);
+}