23#define LOCATION(stmt) ::wibble::Location( __FILE__, __LINE__, stmt )
28#define LOCATION_I(stmt, i) ::wibble::Location( __FILE__, __LINE__, stmt, i )
30#define assert(x) assert_fn( LOCATION( #x ), x )
31#define assert_pred(p, x) assert_pred_fn( \
32 LOCATION( #p "( " #x " )" ), x, p( x ) )
33#define assert_eq(x, y) assert_eq_fn( LOCATION( #x " == " #y ), x, y )
34#define assert_leq(x, y) assert_leq_fn( LOCATION( #x " <= " #y ), x, y )
35#define assert_eq_l(i, x, y) assert_eq_fn( LOCATION_I( #x " == " #y, i ), x, y )
36#define assert_neq(x, y) assert_neq_fn( LOCATION( #x " != " #y ), x, y )
37#define assert_list_eq(x, y) \
38 assert_list_eq_fn( LOCATION( #x " == " #y ), \
39 sizeof( y ) / sizeof( y[0] ), x, y )
41#define assert(x) ((void)0)
42#define assert_pred(p, x) ((void)0)
43#define assert_eq(x, y) ((void)0)
44#define assert_leq(x, y) ((void)0)
45#define assert_eq_l(i, x, y) ((void)0)
46#define assert_neq(x, y) ((void)0)
47#define assert_list_eq(x, y) ((void)0)
50#define assert_unreachable(...) assert_die_fn( LOCATION( wibble::str::fmtf(__VA_ARGS__) ) )
51#define assert_unimplemented() assert_die_fn( LOCATION( "not imlemented" ) )
52#define assert_die() assert_die_fn( LOCATION( "forbidden code path tripped" ) )
56 std::ostringstream
str;
65 str <<
": assertion `" << l.
stmt <<
"' failed;";
95template<
typename X,
typename Y >
101 << x <<
"] != [" <<
y
106template<
typename X,
typename Y >
117template<
typename X >
126template<
typename X >
131 while ( !l.empty() ) {
132 if ( l.head() != check[ i ] ) {
134 f <<
" list disagrees at position "
145 << i <<
"] != [" <<
c <<
"] instead";
149template<
typename X,
typename Y >
156 << x <<
"] == [" <<
y <<
"] instead";
std::string fmt(const char *f,...)
Definition string.cpp:123
void assert_list_eq_fn(Location loc, int c, X l, const typename X::Type check[])
Definition test.h:127
void assert_die_fn(Location l)
Definition test.cpp:6
void assert_fn(Location l, X x)
Definition test.h:86
void endAssertFailure()
Definition test.h:163
void assert_leq_fn(Location l, X x, Y y)
Definition test.h:107
void assert_neq_fn(Location l, X x, Y y)
Definition test.h:150
int assertFailure
Definition test.cpp:4
void assert_eq_fn(Location l, X x, Y y)
Definition test.h:96
void assert_pred_fn(Location l, X x, bool p)
Definition test.h:118
void beginAssertFailure()
Definition test.h:159
std::ostream & operator<<(std::ostream &o, const std::pair< X, Y > &x)
Definition parse.h:52
bool expect
Definition test.h:57
AssertFailed(Location l, std::ostream &s=std::cerr)
Definition test.h:58
std::ostringstream str
Definition test.h:56
std::ostream & stream
Definition test.h:55
~AssertFailed()
Definition test.h:68
~ExpectFailure()
Definition test.h:173
ExpectFailure()
Definition test.h:172
int line
Definition test.h:17
int iteration
Definition test.h:17
const char * file
Definition test.h:16
Location(const char *f, int l, std::string st, int iter=-1)
Definition test.h:19
std::string stmt
Definition test.h:18
void Test
Definition test.h:178
#define assert(x)
Definition test.h:30