From bb93178b8b5c2f8021977dbc34066f0d0fb8b9b9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 15 Apr 2014 10:21:52 +0200 Subject: clear HitEof flag in FileFd::Seek fseek and co do this to their eof-flags and it is more logic this way as we will usually seek away from the end (e.g. to re-read the file). The commit also improves the testcase further and adds a test for the binary compressor codepath (as gz, bzip2 and xz are handled by libraries) via the use of 'rev' as a 'compressor'. --- test/libapt/assert.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/libapt/assert.h') diff --git a/test/libapt/assert.h b/test/libapt/assert.h index 357801592..3e45143a3 100644 --- a/test/libapt/assert.h +++ b/test/libapt/assert.h @@ -2,6 +2,7 @@ #include #include +#include #if __GNUC__ >= 4 #pragma GCC diagnostic push @@ -14,6 +15,7 @@ template < typename X, typename Y > APT_NORETURN void OutputAssertEqual(X expect, char const* compare, Y get, unsigned long const &line) { std::cerr << "Test FAILED: »" << expect << "« " << compare << " »" << get << "« at line " << line << std::endl; + _error->DumpErrors(std::cerr); std::exit(EXIT_FAILURE); } -- cgit v1.2.3 From f00832cc273e52a47fb88e49849891b771de4e17 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 16 Apr 2014 17:09:37 +0200 Subject: use Google C++ Testing Framework for libapt tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit My commit 45df0ad2 from 26. Nov 2009 had a little remark: "The commit also includes a very very simple testapp." This was never intended to be permanent, but as usually… The commit adds the needed make magic to compile gtest statically as it is required and links it against a small runner. All previous testcase binaries are reimplemented in gtest and combined in this runner. While most code is a 1:1 translation some had to be rewritten like compareversion_test.cc, but the coverage remains the same. --- test/libapt/assert.h | 126 --------------------------------------------------- 1 file changed, 126 deletions(-) delete mode 100644 test/libapt/assert.h (limited to 'test/libapt/assert.h') diff --git a/test/libapt/assert.h b/test/libapt/assert.h deleted file mode 100644 index 3e45143a3..000000000 --- a/test/libapt/assert.h +++ /dev/null @@ -1,126 +0,0 @@ -#include -#include - -#include -#include - -#if __GNUC__ >= 4 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wmissing-declarations" -#endif - -#define equals(x,y) assertEquals(y, x, __LINE__) -#define equalsNot(x,y) assertEqualsNot(y, x, __LINE__) - -template < typename X, typename Y > -APT_NORETURN void OutputAssertEqual(X expect, char const* compare, Y get, unsigned long const &line) { - std::cerr << "Test FAILED: »" << expect << "« " << compare << " »" << get << "« at line " << line << std::endl; - _error->DumpErrors(std::cerr); - std::exit(EXIT_FAILURE); -} - -template < typename X, typename Y > -void assertEquals(X expect, Y get, unsigned long const &line) { - if (expect == get) - return; - OutputAssertEqual(expect, "==", get, line); -} - -template < typename X, typename Y > -void assertEqualsNot(X expect, Y get, unsigned long const &line) { - if (expect != get) - return; - OutputAssertEqual(expect, "!=", get, line); -} - -void assertEquals(unsigned int const &expect, int const &get, unsigned long const &line) { - if (get < 0) - OutputAssertEqual(expect, "==", get, line); - assertEquals(expect, get, line); -} - -void assertEquals(int const &expect, unsigned int const &get, unsigned long const &line) { - if (expect < 0) - OutputAssertEqual(expect, "==", get, line); - assertEquals(expect, get, line); -} - -void assertEquals(unsigned long const &expect, int const &get, unsigned long const &line) { - if (get < 0) - OutputAssertEqual(expect, "==", get, line); - assertEquals(expect, get, line); -} - -void assertEquals(int const &expect, unsigned long const &get, unsigned long const &line) { - if (expect < 0) - OutputAssertEqual(expect, "==", get, line); - assertEquals(expect, get, line); -} - - -#define equalsOr2(x,y,z) assertEqualsOr2(y, z, x, __LINE__) - -template < typename X, typename Y > -void OutputAssertEqualOr2(X expect1, X expect2, char const* compare, Y get, unsigned long const &line) { - std::cerr << "Test FAILED: »" << expect1 << "« or »" << expect2 << "« " << compare << " »" << get << "« at line " << line << std::endl; -} - -template < typename X, typename Y > -void assertEqualsOr2(X expect1, X expect2, Y get, unsigned long const &line) { - if (expect1 == get || expect2 == get) - return; - OutputAssertEqualOr2(expect1, expect2, "==", get, line); -} - -void assertEqualsOr2(unsigned int const &expect1, unsigned int const &expect2, int const &get, unsigned long const &line) { - if (get < 0) - OutputAssertEqualOr2(expect1, expect2, "==", get, line); - assertEqualsOr2(expect1, expect2, get, line); -} - -void assertEqualsOr2(int const &expect1, int const &expect2, unsigned int const &get, unsigned long const &line) { - if (expect1 < 0 && expect2 < 0) - OutputAssertEqualOr2(expect1, expect2, "==", get, line); - assertEqualsOr2(expect1, expect2, get, line); -} - - -#define equalsOr3(w,x,y,z) assertEqualsOr3(x, y, z, w, __LINE__) - -template < typename X, typename Y > -void OutputAssertEqualOr3(X expect1, X expect2, X expect3, char const* compare, Y get, unsigned long const &line) { - std::cerr << "Test FAILED: »" << expect1 << "« or »" << expect2 << "« or »" << expect3 << "« " << compare << " »" << get << "« at line " << line << std::endl; -} - -template < typename X, typename Y > -void assertEqualsOr3(X expect1, X expect2, X expect3, Y get, unsigned long const &line) { - if (expect1 == get || expect2 == get || expect3 == get) - return; - OutputAssertEqualOr3(expect1, expect2, expect3, "==", get, line); -} - -#define equalsOr4(v,w,x,y,z) assertEqualsOr4(w, x, y, z, v, __LINE__) - -template < typename X, typename Y > -void OutputAssertEqualOr4(X expect1, X expect2, X expect3, X expect4, char const* compare, Y get, unsigned long const &line) { - std::cerr << "Test FAILED: »" << expect1 << "« or »" << expect2 << "« or »" << expect3 << "« or »" << expect4 << "« " << compare << " »" << get << "« at line " << line << std::endl; -} - -template < typename X, typename Y > -void assertEqualsOr4(X expect1, X expect2, X expect3, X expect4, Y get, unsigned long const &line) { - if (expect1 == get || expect2 == get || expect3 == get || expect4 == get) - return; - OutputAssertEqualOr4(expect1, expect2, expect3, expect4, "==", get, line); -} - -// simple helper to quickly output a vectors -template < typename X > -void dumpVector(X vec) { - for (typename X::const_iterator v = vec.begin(); - v != vec.end(); ++v) - std::cout << *v << std::endl; -} - -#if __GNUC__ >= 4 - #pragma GCC diagnostic pop -#endif -- cgit v1.2.3