00001 #ifndef TEST_HPP
00002 #define TEST_HPP
00003
00004 void report_failure(char const* str, char const* file, int line);
00005
00006 #if defined(_MSC_VER)
00007 #define COUNTER_GUARD(x)
00008 #else
00009 #define COUNTER_GUARD(type) \
00010 struct BOOST_PP_CAT(type, _counter_guard) \
00011 { \
00012 ~BOOST_PP_CAT(type, _counter_guard()) \
00013 { \
00014 TEST_CHECK(counted_type<type>::count == 0); \
00015 } \
00016 } BOOST_PP_CAT(type, _guard)
00017 #endif
00018
00019 #define TEST_REPORT_AUX(x, line, file) \
00020 report_failure(x, line, file)
00021
00022 #define TEST_CHECK(x) \
00023 if (!(x)) \
00024 TEST_REPORT_AUX("TEST_CHECK failed: \"" #x "\"", __FILE__, __LINE__)
00025
00026 #define TEST_ERROR(x) \
00027 TEST_REPORT_AUX((std::string("ERROR: \"") + x + "\"").c_str(), __FILE__, __LINE__)
00028
00029 #define TEST_NOTHROW(x) \
00030 try \
00031 { \
00032 x; \
00033 } \
00034 catch (...) \
00035 { \
00036 TEST_ERROR("Exception thrown: " #x); \
00037 }
00038
00039 #endif // TEST_HPP
00040