~ubuntu-branches/debian/experimental/apt/experimental

« back to all changes in this revision

Viewing changes to test/libapt/assert.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2010-02-18 22:07:23 UTC
  • mfrom: (9.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100218220723-zb7zdh6fmsmp30tr
Tags: 0.7.26~exp2
fix crash when LANGUAGE is not set

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <iostream>
 
2
 
 
3
#define equals(x,y) assertEquals(x, y, __LINE__)
 
4
 
 
5
template < typename X, typename Y >
 
6
void OutputAssert(X expect, char const* compare, Y get, unsigned long const &line) {
 
7
        std::cerr << "Test FAILED: »" << expect << "« " << compare << " »" << get << "« at line " << line << std::endl;
 
8
}
 
9
 
 
10
template < typename X, typename Y >
 
11
void assertEquals(X expect, Y get, unsigned long const &line) {
 
12
        if (expect == get)
 
13
                return;
 
14
        OutputAssert(expect, "==", get, line);
 
15
}
 
16
 
 
17
void assertEquals(unsigned int const &expect, int const &get, unsigned long const &line) {
 
18
        if (get < 0)
 
19
                OutputAssert(expect, "==", get, line);
 
20
        assertEquals<unsigned int const&, unsigned int const&>(expect, get, line);
 
21
}