X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FUtils%2Fauto_unit_test.hh;h=e6243d7f53dc5aa60a610b53730dc26f870e6e78;hb=5b2e9a63a43027c71ac470ac9bdecb72e8974951;hp=b81bed4f9ddf92067a33c71552b77685cc1a406d;hpb=1b32783499fa4d42ef090b210c0eec659a5b5a4d;p=senf.git diff --git a/senf/Utils/auto_unit_test.hh b/senf/Utils/auto_unit_test.hh index b81bed4..e6243d7 100644 --- a/senf/Utils/auto_unit_test.hh +++ b/senf/Utils/auto_unit_test.hh @@ -42,7 +42,7 @@ //#include "auto_unit_test.mpp" #include "auto_unit_test.ih" -///////////////////////////////hh.p//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// #if BOOST_VERSION >= 103400 @@ -59,8 +59,8 @@ /** \brief Check for compile failure - COMPILE_FAIL() is used to check, that a certain piece of code will produce a compile time - failure. + \c COMPILE_FAIL() is used to check, that a certain piece of code will produce a compile + time failure. \code #ifdef COMPILE_CHECK @@ -70,7 +70,7 @@ // fails to compile .... int x = "foo"; } - + COMPILE_FAIL(bar) { ... } @@ -78,49 +78,90 @@ \endcode This check is performed by the extended unit-test builder in \c senfscons. - + \ingroup unittest */ #define COMPILE_FAIL(n) void n() /** \brief Show exception information - \ref SENF_CHECK_NO_THROW() is an extension to \c BOOST_CHECK_NO_THROW() which will write out the + \c SENF_CHECK_NO_THROW() is an extension to \c BOOST_CHECK_NO_THROW() which will write out the unabridged exception information when an exception is thrown in addition to signaling an error. \ingroup unittest */ -#define SENF_CHECK_NO_THROW(expr) \ - BOOST_CHECK_NO_THROW( \ - try { expr ; } \ +#define SENF_CHECK_NO_THROW(expr) \ + BOOST_CHECK_NO_THROW( \ + try { expr ; } \ catch (std::exception & e) { std::cerr << e.what() << std::endl; throw; } ) namespace senf { namespace test { template - typename detail::NoCharIterator::type nocharIterator(Iterator i) - { return typename detail::NoCharIterator::type (i); } + typename detail::NoCharIterator::type nocharIterator(Iterator i); }} /** \brief Check ranges for equality, writing char's as int's - \ref SENF_CHECK_EQUAL_COLLECTIONS() is like \c BOOST_CHECK_EQUAL_COLLECTIONS(). The only - difference is, that \ref SENF_CHECK_EQUAL_COLLECTIONS() will write out collection values in + \c SENF_CHECK_EQUAL_COLLECTIONS() is like \c BOOST_CHECK_EQUAL_COLLECTIONS(). The only + difference is, that \c SENF_CHECK_EQUAL_COLLECTIONS() will write out collection values in numeric form (and not as single characters) if the elements are of any char type. Other types are not affected. + \hideinitializer \ingroup unittest */ -#define SENF_CHECK_EQUAL_COLLECTIONS(a,b,c,d) \ - BOOST_CHECK_EQUAL_COLLECTIONS(senf::test::nocharIterator(a), senf::test::nocharIterator(b), \ - senf::test::nocharIterator(c), senf::test::nocharIterator(d)) +#define SENF_CHECK_EQUAL_COLLECTIONS(left_begin, left_end, right_begin, right_end) \ + BOOST_CHECK_EQUAL_COLLECTIONS( \ + senf::test::nocharIterator(left_begin), senf::test::nocharIterator(left_end), \ + senf::test::nocharIterator(right_begin), senf::test::nocharIterator(right_end)) + +/** \brief Define new test case + + \c SENF_AUTO_UNIT_TEST() is like \c BOOST_AUTO_UNIT_TEST(). The only difference is, that + if an exception is thrown in the test case \c SENF_AUTO_UNIT_TEST() will write out the + complete what-message of the exception. + + \hideinitializer + \ingroup unittest + */ +#define SENF_AUTO_UNIT_TEST(name) \ + void senf_test_body_##name(); \ + BOOST_AUTO_UNIT_TEST(name) \ + { \ + try { \ + senf_test_body_##name(); \ + } \ + catch (std::exception & e) { \ + std::cerr << e.what() << std::endl; \ + throw; \ + } \ + } \ + void senf_test_body_##name() + + +#ifdef DOXYGEN + /** \brief Check for non-equality + + \c SENF_CHECK_NOT_EQUAL() is the opposite of \c BOOST_CHECK_EQUAL. + \hideinitializer + \ingroup unittest + */ + #define SENF_CHECK_NOT_EQUAL( Left, Rigth) +#else +#ifdef BOOST_CHECK_NE + #define SENF_CHECK_NOT_EQUAL( Left, Right) BOOST_CHECK_NE( Left, Right) +#else + #define SENF_CHECK_NOT_EQUAL( Left, Right) BOOST_CHECK( Left != Right) +#endif +#endif -///////////////////////////////hh.e//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// //#include "auto_unit_test.cci" //#include "auto_unit_test.ct" -//#include "auto_unit_test.cti" +#include "auto_unit_test.cti" #endif