7 #error ensure_THROW macro is already defined
10 /** Helper macros to ensure that a call throws exception.
12 * #include <tut_macros.h>
13 * ensure_THROW( this_function_should_throw_bad_alloc(), std::bad_alloc );
16 #define ensure_THROW( x, e ) \
20 fail(#x " has not thrown expected exception " #e); \
25 catch(const std::exception &ex) \
27 fail( std::string(#x " has thrown unexpected exception ")+tut::type_name(ex)+": "+ex.what()); \
31 fail(#x " has thrown unexpected unknown exception"); \
34 #ifdef ensure_NO_THROW
35 #error ensure_NO_THROW macro is already defined
38 /** Helper macro to ensure a call does not throw any exceptions.
40 * #include <tut_macros.h>
41 * ensure_NO_THROW( this_function_should_never_throw() );
44 #define ensure_NO_THROW( x ) \
49 catch(const std::exception &ex) \
51 fail( std::string(#x " has thrown unexpected exception ")+tut::type_name(ex)+": "+ex.what()); \
55 fail(#x " has thrown unexpected unknown exception"); \
59 #define TUT_TESTCASE(object) template<> template<> void object::test<__COUNTER__>()