From cefb7c1f24b3b8c12898f1c8c042970b7a429dca Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 28 Nov 2009 23:27:11 +0100 Subject: add our own equals method as assert doesn't really show the offending values which causes the failure. --- test/libapt/assert.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/libapt/assert.h (limited to 'test/libapt/assert.h') 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 + +#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(expect, get, line); +} -- cgit v1.2.3