--- C:/Users/IGAZTA~1/AppData/Local/Temp/lightweight_test.hpp-revBASE.svn002.tmp.hpp vie feb 25 00:24:54 2011 +++ C:/Data/Libs/LocalSVN/boost-trunk/boost/detail/lightweight_test.hpp mié mar 13 21:01:54 2013 @@ -12,6 +12,7 @@ // // Copyright (c) 2002, 2009 Peter Dimov // Copyright (2) Beman Dawes 2010, 2011 +// Copyright (3) Ion Gaztanaga 2013 // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -20,6 +21,8 @@ // BOOST_TEST(expression) // BOOST_ERROR(message) // BOOST_TEST_EQ(expr1, expr2) +// BOOST_TEST_NE(expr1, expr2) +// BOOST_TEST_THROWS(expr1, excep) // // int boost::report_errors() // @@ -27,6 +30,7 @@ #include #include #include +#include // IDE's like Visual Studio perform better if output goes to std::cout or // some other stream, so allow user to configure output stream: @@ -79,6 +83,14 @@ ++test_errors(); } +inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function) +{ + BOOST_LIGHTWEIGHT_TEST_OSTREAM + << file << "(" << line << "): Exception '" << excep << "' not thrown in function '" + << function << "'" << std::endl; + ++test_errors(); +} + template inline void test_eq_impl( char const * expr1, char const * expr2, char const * file, int line, char const * function, T const & t, U const & u ) { @@ -139,5 +151,19 @@ #define BOOST_ERROR(msg) ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) #define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) +#define BOOST_TEST_THROWS( EXPR, EXCEP ) \ + BOOST_TRY { \ + EXPR; \ + ::boost::detail::throw_failed_impl \ + (#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION);\ + } \ + BOOST_CATCH(EXCEP const&) { \ + } \ + BOOST_CATCH(...) { \ + ::boost::detail::throw_failed_impl \ + (#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION);\ + } \ + BOOST_CATCH_END \ +// #endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED