File: assert.h

package info (click to toggle)
apt 0.8.10.3%2Bsqueeze7
  • links: PTS
  • area: main
  • in suites: squeeze-lts
  • size: 13,540 kB
  • ctags: 4,423
  • sloc: cpp: 38,033; perl: 6,867; xml: 3,869; sh: 3,068; makefile: 686; python: 309
file content (21 lines) | stat: -rw-r--r-- 709 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

#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<unsigned int const&, unsigned int const&>(expect, get, line);
}