17 #define TESTGRP(name) \
18 typedef test_group<name ## _shar> tg; \
19 typedef tg::object to; \
20 tg name ## _tg (#name);
37 Location(
const std::string& file,
int line,
const std::string& str)
38 : file(file), line(line), str(str) {}
40 const std::string& testfile,
int testline,
const std::string& str) :
41 file(loc.file), line(loc.line), str(loc.str),
42 testfile(testfile), testline(testline), teststr(str) {}
44 std::string
locstr()
const;
45 std::string
msg(
const std::string m)
const;
48 #define ensure(x) wibble::tests::impl_ensure(wibble::tests::Location(__FILE__, __LINE__, #x), (x))
49 #define inner_ensure(x) wibble::tests::impl_ensure(wibble::tests::Location(loc, __FILE__, __LINE__, #x), (x))
52 #define ensure_equals(x, y) wibble::tests::impl_ensure_equals(wibble::tests::Location(__FILE__, __LINE__, #x " == " #y), (x), (y))
53 #define inner_ensure_equals(x, y) wibble::tests::impl_ensure_equals(wibble::tests::Location(loc, __FILE__, __LINE__, #x " == " #y), (x), (y))
55 template <
class Actual,
class Expected>
58 if( expected != actual )
61 ss <<
"expected '" << expected <<
"' actual '" << actual <<
"'";
66 #define ensure_similar(x, y, prec) wibble::tests::impl_ensure_similar(wibble::tests::Location(__FILE__, __LINE__, #x " == " #y), (x), (y), (prec))
67 #define inner_ensure_similar(x, y, prec) wibble::tests::impl_ensure_similar(wibble::tests::Location(loc, __FILE__, __LINE__, #x " == " #y), (x), (y), (prec))
69 template <
class Actual,
class Expected,
class Precision>
72 if( actual < expected - precision || expected + precision < actual )
75 ss <<
"expected '" << expected <<
"' actual '" << actual <<
"'";