|
Boost-Commit : |
From: gennadiy.rozental_at_[hidden]
Date: 2008-07-06 21:01:17
Author: rogeeff
Date: 2008-07-06 21:01:17 EDT (Sun, 06 Jul 2008)
New Revision: 47153
URL: http://svn.boost.org/trac/boost/changeset/47153
Log:
Initial support for test tools to return value
Text files modified:
trunk/boost/test/impl/test_tools.ipp | 12 +++++++-----
trunk/boost/test/test_tools.hpp | 28 ++++++++++++++++++++++++++--
2 files changed, 33 insertions(+), 7 deletions(-)
Modified: trunk/boost/test/impl/test_tools.ipp
==============================================================================
--- trunk/boost/test/impl/test_tools.ipp (original)
+++ trunk/boost/test/impl/test_tools.ipp 2008-07-06 21:01:17 EDT (Sun, 06 Jul 2008)
@@ -61,7 +61,7 @@
// ************** TOOL BOX Implementation ************** //
// ************************************************************************** //
-void
+bool
check_impl( predicate_result const& pr, wrap_stringstream& check_descr,
const_string file_name, std::size_t line_num,
tool_level tl, check_type ct,
@@ -101,7 +101,7 @@
suffix = " failed";
break;
default:
- return;
+ return true;
}
switch( ct ) {
@@ -305,14 +305,14 @@
switch( tl ) {
case PASS:
framework::assertion_result( true );
- break;
+ return true;
case WARN:
- break;
+ return false;
case CHECK:
framework::assertion_result( false );
- break;
+ return false;
case REQUIRE:
framework::assertion_result( false );
@@ -321,6 +321,8 @@
throw execution_aborted();
}
+
+ return true;
}
//____________________________________________________________________________//
Modified: trunk/boost/test/test_tools.hpp
==============================================================================
--- trunk/boost/test/test_tools.hpp (original)
+++ trunk/boost/test/test_tools.hpp 2008-07-06 21:01:17 EDT (Sun, 06 Jul 2008)
@@ -78,17 +78,39 @@
//____________________________________________________________________________//
+#if defined(__GNUC__)
+# define BOOST_TEST_TOOLS_RETURN_VALUE
+#endif
+
+#ifdef BOOST_TEST_TOOLS_RETURN_VALUE
+#define BOOST_CHECK_IMPL( P, check_descr, TL, CT ) \
+({ \
+ BOOST_TEST_PASSPOINT(); \
+ BOOST_TEST_TOOL_IMPL( check_impl, P, check_descr, TL, CT ), 0 );\
+}) \
+/**/
+#else
#define BOOST_CHECK_IMPL( P, check_descr, TL, CT ) \
do { \
BOOST_TEST_PASSPOINT(); \
BOOST_TEST_TOOL_IMPL( check_impl, P, check_descr, TL, CT ), 0 );\
} while( ::boost::test_tools::dummy_cond ) \
/**/
+#endif
//____________________________________________________________________________//
#define BOOST_TEST_PASS_ARG_INFO( r, data, arg ) , arg, BOOST_STRINGIZE( arg )
+#ifdef BOOST_TEST_TOOLS_RETURN_VALUE
+#define BOOST_CHECK_WITH_ARGS_IMPL( P, check_descr, TL, CT, ARGS ) \
+({ \
+ BOOST_TEST_PASSPOINT(); \
+ BOOST_TEST_TOOL_IMPL( check_frwd, P, check_descr, TL, CT ) \
+ BOOST_PP_SEQ_FOR_EACH( BOOST_TEST_PASS_ARG_INFO, '_', ARGS ) ); \
+}) \
+/**/
+#else
#define BOOST_CHECK_WITH_ARGS_IMPL( P, check_descr, TL, CT, ARGS ) \
do { \
BOOST_TEST_PASSPOINT(); \
@@ -96,6 +118,7 @@
BOOST_PP_SEQ_FOR_EACH( BOOST_TEST_PASS_ARG_INFO, '_', ARGS ) ); \
} while( ::boost::test_tools::dummy_cond ) \
/**/
+#endif
//____________________________________________________________________________//
@@ -460,7 +483,7 @@
// ************************************************************************** //
BOOST_TEST_DECL
-void check_impl( predicate_result const& pr, wrap_stringstream& check_descr,
+bool check_impl( predicate_result const& pr, wrap_stringstream& check_descr,
const_string file_name, std::size_t line_num,
tool_level tl, check_type ct,
std::size_t num_args, ... );
@@ -485,13 +508,14 @@
#define IMPL_FRWD( z, n, dummy ) \
template<typename Pred \
BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), TEMPL_PARAMS, _ )> \
-inline void \
+inline bool \
check_frwd( Pred P, wrap_stringstream& check_descr, \
const_string file_name, std::size_t line_num, \
tool_level tl, check_type ct \
BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), FUNC_PARAMS, _ ) \
) \
{ \
+ return \
check_impl( P( BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), PRED_PARAMS, _ ) ), \
check_descr, file_name, line_num, tl, ct, \
BOOST_PP_ADD( n, 1 ) \
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk