]> git.saurik.com Git - apt.git/commitdiff
add our own equals method as assert doesn't really show the offending
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 28 Nov 2009 22:27:11 +0000 (23:27 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 28 Nov 2009 22:27:11 +0000 (23:27 +0100)
values which causes the failure.

test/libapt/assert.h [new file with mode: 0644]

diff --git a/test/libapt/assert.h b/test/libapt/assert.h
new file mode 100644 (file)
index 0000000..5da76ae
--- /dev/null
@@ -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);
+}