summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-07-25 13:55:23 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-07-25 13:55:23 +0200
commitfce1153321e432ed4a64e9742a8fc1c5558124e4 (patch)
treed0cf4e691c44196a7bc4b1347482ec72586cb43e
parentc3182c823bdba037e7f1daaffde8b44155ff4f48 (diff)
the order of languages after "none" is not important, so ignore it in tests
-rw-r--r--test/libapt/assert.h42
-rw-r--r--test/libapt/getlanguages_test.cc4
2 files changed, 40 insertions, 6 deletions
diff --git a/test/libapt/assert.h b/test/libapt/assert.h
index 5da76ae0a..92b662dfa 100644
--- a/test/libapt/assert.h
+++ b/test/libapt/assert.h
@@ -1,9 +1,9 @@
#include <iostream>
-#define equals(x,y) assertEquals(x, y, __LINE__)
+#define equals(x,y) assertEquals(y, x, __LINE__)
template < typename X, typename Y >
-void OutputAssert(X expect, char const* compare, Y get, unsigned long const &line) {
+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;
}
@@ -11,11 +11,45 @@ template < typename X, typename Y >
void assertEquals(X expect, Y get, unsigned long const &line) {
if (expect == get)
return;
- OutputAssert(expect, "==", get, line);
+ OutputAssertEqual(expect, "==", get, line);
}
void assertEquals(unsigned int const &expect, int const &get, unsigned long const &line) {
if (get < 0)
- OutputAssert(expect, "==", get, line);
+ OutputAssertEqual(expect, "==", get, line);
assertEquals<unsigned int const&, unsigned int const&>(expect, get, line);
}
+
+void assertEquals(int const &expect, unsigned int const &get, unsigned long const &line) {
+ if (expect < 0)
+ OutputAssertEqual(expect, "==", get, line);
+ assertEquals<unsigned int const&, unsigned int const&>(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<unsigned int const&, unsigned int const&>(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<unsigned int const&, unsigned int const&>(expect1, expect2, get, line);
+}
+
diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc
index 707142aef..3d63e0e74 100644
--- a/test/libapt/getlanguages_test.cc
+++ b/test/libapt/getlanguages_test.cc
@@ -138,8 +138,8 @@ int main(int argc,char *argv[])
equals(vec[1], "de");
equals(vec[2], "en");
equals(vec[3], "none");
- equals(vec[4], "pt");
- equals(vec[5], "tr");
+ equalsOr2(vec[4], "pt", "tr");
+ equalsOr2(vec[5], "tr", "pt");
_config->Set("Dir::State::lists", "/non-existing-dir");
_config->Set("Acquire::Languages::1", "none");