tut logo

tut_macros.hpp Source File


tut_macros.hpp
1 #ifndef TUT_MACROS_HPP
2 #define TUT_MACROS_HPP
3 
4 #include <tut/tut.hpp>
5 
6 #ifdef ensure_THROW
7 #error ensure_THROW macro is already defined
8 #endif
9 
16 #define ensure_THROW( x, e ) \
17 try \
18 { \
19  x; \
20  fail(#x " has not thrown expected exception " #e); \
21 } \
22 catch(const e &) \
23 { \
24 } \
25 catch(const std::exception &ex) \
26 { \
27  fail( std::string(#x " has thrown unexpected exception ")+tut::type_name(ex)+": "+ex.what()); \
28 } \
29 catch(...) \
30 { \
31  fail(#x " has thrown unexpected unknown exception"); \
32 }
33 
34 #ifdef ensure_NO_THROW
35 #error ensure_NO_THROW macro is already defined
36 #endif
37 
44 #define ensure_NO_THROW( x ) \
45 try \
46 { \
47  x; \
48 } \
49 catch(const std::exception &ex) \
50 { \
51  fail( std::string(#x " has thrown unexpected exception ")+tut::type_name(ex)+": "+ex.what()); \
52 } \
53 catch(...) \
54 { \
55  fail(#x " has thrown unexpected unknown exception"); \
56 }
57 
58 #ifdef __COUNTER__
59 #define TUT_TESTCASE(object) template<> template<> void object::test<__COUNTER__>()
60 #endif
61 
62 #endif
63 

All Rights Reserved. Generated on Wed Dec 18 2013 11:19:52 for TUT by doxygen 1.8.5