]>
git.saurik.com Git - apt.git/blob - test/libapt/assert.h
3 #define equals(x,y) assertEquals(y, x, __LINE__)
5 template < typename X
, typename Y
>
6 void OutputAssertEqual(X expect
, char const* compare
, Y get
, unsigned long const &line
) {
7 std::cerr
<< "Test FAILED: »" << expect
<< "« " << compare
<< " »" << get
<< "« at line " << line
<< std::endl
;
10 template < typename X
, typename Y
>
11 void assertEquals(X expect
, Y get
, unsigned long const &line
) {
14 OutputAssertEqual(expect
, "==", get
, line
);
17 void assertEquals(unsigned int const &expect
, int const &get
, unsigned long const &line
) {
19 OutputAssertEqual(expect
, "==", get
, line
);
20 assertEquals
<unsigned int const&, unsigned int const&>(expect
, get
, line
);
23 void assertEquals(int const &expect
, unsigned int const &get
, unsigned long const &line
) {
25 OutputAssertEqual(expect
, "==", get
, line
);
26 assertEquals
<unsigned int const&, unsigned int const&>(expect
, get
, line
);
30 #define equalsOr2(x,y,z) assertEqualsOr2(y, z, x, __LINE__)
32 template < typename X
, typename Y
>
33 void OutputAssertEqualOr2(X expect1
, X expect2
, char const* compare
, Y get
, unsigned long const &line
) {
34 std::cerr
<< "Test FAILED: »" << expect1
<< "« or »" << expect2
<< "« " << compare
<< " »" << get
<< "« at line " << line
<< std::endl
;
37 template < typename X
, typename Y
>
38 void assertEqualsOr2(X expect1
, X expect2
, Y get
, unsigned long const &line
) {
39 if (expect1
== get
|| expect2
== get
)
41 OutputAssertEqualOr2(expect1
, expect2
, "==", get
, line
);
44 void assertEqualsOr2(unsigned int const &expect1
, unsigned int const &expect2
, int const &get
, unsigned long const &line
) {
46 OutputAssertEqualOr2(expect1
, expect2
, "==", get
, line
);
47 assertEqualsOr2
<unsigned int const&, unsigned int const&>(expect1
, expect2
, get
, line
);
50 void assertEqualsOr2(int const &expect1
, int const &expect2
, unsigned int const &get
, unsigned long const &line
) {
51 if (expect1
< 0 && expect2
< 0)
52 OutputAssertEqualOr2(expect1
, expect2
, "==", get
, line
);
53 assertEqualsOr2
<unsigned int const&, unsigned int const&>(expect1
, expect2
, get
, line
);