diff --git a/include/boost/test/auto_unit_test.hpp b/include/boost/test/auto_unit_test.hpp deleted file mode 100644 index 629f4bce..00000000 --- a/include/boost/test/auto_unit_test.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : deprecated -// *************************************************************************** - -#ifndef BOOST_TEST_AUTO_UNIT_TEST_HPP_071894GER -#define BOOST_TEST_AUTO_UNIT_TEST_HPP_071894GER - -#include - -#endif // BOOST_TEST_AUTO_UNIT_TEST_HPP_071894GER diff --git a/include/boost/test/debug.hpp b/include/boost/test/debug.hpp index 4bdbb8fb..24c42d95 100644 --- a/include/boost/test/debug.hpp +++ b/include/boost/test/debug.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2006-2010. +// (C) Copyright Gennadiy Rozental 2006-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -17,9 +17,11 @@ // Boost.Test #include -#include #include +// Boost +#include + // STL #include @@ -56,7 +58,7 @@ struct dbg_startup_info { unit_test::const_string init_done_lock; }; -typedef unit_test::callback1 dbg_starter; +typedef boost::function dbg_starter; // ************************************************************************** // // ************** debugger setup ************** // diff --git a/include/boost/test/debug_config.hpp b/include/boost/test/debug_config.hpp index c5573166..1e52058e 100644 --- a/include/boost/test/debug_config.hpp +++ b/include/boost/test/debug_config.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2006-2010. +// (C) Copyright Gennadiy Rozental 2006-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/test/detail/config.hpp b/include/boost/test/detail/config.hpp index c44c7b97..0d305876 100644 --- a/include/boost/test/detail/config.hpp +++ b/include/boost/test/detail/config.hpp @@ -85,6 +85,12 @@ class type_info; //____________________________________________________________________________// +#if !defined(__BORLANDC__) && !BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) && !BOOST_WORKAROUND( __SUNPRO_CC, < 0x5100 ) +#define BOOST_TEST_SUPPORT_TOKEN_ITERATOR 1 +#endif + +//____________________________________________________________________________// + #if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_TEST_DYN_LINK) # define BOOST_TEST_DYN_LINK #endif diff --git a/include/boost/test/execution_monitor.hpp b/include/boost/test/execution_monitor.hpp index 309266fa..81425a13 100644 --- a/include/boost/test/execution_monitor.hpp +++ b/include/boost/test/execution_monitor.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. +// (C) Copyright Gennadiy Rozental 2001-2011. // (C) Copyright Beman Dawes 2001. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -35,7 +35,6 @@ // Boost.Test #include #include -#include #include // Boost @@ -43,6 +42,7 @@ #include #include #include +#include #include @@ -103,7 +103,7 @@ public: // Constructor translator_holder_base( translator_holder_base_ptr next, const_string tag ) : m_next( next ) - , m_tag( tag.begin(), tag.end() ) + , m_tag( std::string() + tag ) { } @@ -112,7 +112,8 @@ public: // translator holder interface // invokes the function F inside the try/catch guarding against specific exception - virtual int operator()( unit_test::callback0 const& F ) = 0; + virtual int operator()( boost::function const& F ) = 0; + // erases specific translator holder from the chain translator_holder_base_ptr erase( translator_holder_base_ptr this_, const_string tag ) { @@ -234,7 +235,7 @@ public: // try to detect hardware floating point exceptions (!= 0), and which specific exception to catch unit_test::readwrite_property p_detect_fp_exceptions; - int execute( unit_test::callback0 const& F ); + int execute( boost::function const& F ); // Returns: Value returned by function call F(). // // Effects: Calls executes supplied function F inside a try/catch block which also may @@ -244,6 +245,9 @@ public: // a hardware or software signal, trap, or other exception. // // Note: execute() doesn't consider it an error for F to return a non-zero value. + + void vexecute( boost::function const& F ); + // Effects: Same as above, but returns nothing // register custom (user supplied) exception translator template @@ -262,7 +266,7 @@ public: private: // implementation helpers - int catch_signals( unit_test::callback0 const& F ); + int catch_signals( boost::function const& F ); // Data members detail::translator_holder_base_ptr m_custom_translators; @@ -283,7 +287,7 @@ public: : translator_holder_base( next, tag ), m_translator( tr ) {} // translator holder interface - virtual int operator()( unit_test::callback0 const& F ) + virtual int operator()( boost::function const& F ) { try { return m_next ? (*m_next)( F ) : F(); diff --git a/include/boost/test/framework.hpp b/include/boost/test/framework.hpp index 738e1ad5..2f5eef6e 100644 --- a/include/boost/test/framework.hpp +++ b/include/boost/test/framework.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2005-2010. +// (C) Copyright Gennadiy Rozental 2005-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -20,7 +20,6 @@ #include #include - #include // STL @@ -105,7 +104,7 @@ BOOST_TEST_DECL void test_unit_aborted( test_unit const& ); namespace impl { // publisized to facilitate internal unit test only -void apply_filters( test_unit_id ); +void apply_filters( test_unit_id ); } // namespace impl diff --git a/include/boost/test/impl/cpp_main.ipp b/include/boost/test/impl/cpp_main.ipp index 3fb20cfe..01de26e6 100644 --- a/include/boost/test/impl/cpp_main.ipp +++ b/include/boost/test/impl/cpp_main.ipp @@ -46,13 +46,13 @@ struct cpp_main_caller { , m_argc( argc ) , m_argv( argv ) {} - int operator()() { return (*m_cpp_main_func)( m_argc, m_argv ); } + int operator()() { return (*m_cpp_main_func)( m_argc, m_argv ); } private: // Data members - int (*m_cpp_main_func)( int argc, char* argv[] ); - int m_argc; - char** m_argv; + int (*m_cpp_main_func)( int argc, char* argv[] ); + int m_argc; + char** m_argv; }; } // local namespace @@ -74,8 +74,7 @@ prg_exec_monitor_main( int (*cpp_main)( int argc, char* argv[] ), int argc, char ex_mon.p_catch_system_errors.value = p != "no"; - result = ex_mon.execute( - ::boost::unit_test::callback0( cpp_main_caller( cpp_main, argc, argv ) ) ); + result = ex_mon.execute( cpp_main_caller( cpp_main, argc, argv ) ); if( result == 0 ) result = ::boost::exit_success; diff --git a/include/boost/test/impl/decorators.ipp b/include/boost/test/impl/decorators.ipp new file mode 100755 index 00000000..81632888 --- /dev/null +++ b/include/boost/test/impl/decorators.ipp @@ -0,0 +1,201 @@ +// (C) Copyright Gennadiy Rozental 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/test for the library home page. +// +// File : $RCSfile$ +// +// Version : $Revision$ +// +// Description : unit test decorators implementation +// *************************************************************************** + +#ifndef BOOST_TEST_DECORATORS_IPP_091911GER +#define BOOST_TEST_DECORATORS_IPP_091911GER + +// Boost.Test +#include +#include +#include +#if BOOST_TEST_SUPPORT_TOKEN_ITERATOR +#include +#endif + +#include + +//____________________________________________________________________________// + +namespace boost { + +namespace unit_test { + +namespace decorator { + +// ************************************************************************** // +// ************** decorator::collector ************** // +// ************************************************************************** // + +collector::collector( for_test_unit const& D ) +{ + m_tu_decorator.reset( D.clone() ); + + if( instance() != NULL ) { + for_test_unit_ptr leaf = m_tu_decorator; + while( leaf->m_next ) + leaf = leaf->m_next; + + leaf->m_next = instance()->m_tu_decorator; + instance()->m_tu_decorator.reset(); + } + + instance() = this; +} + +//____________________________________________________________________________// + +collector*& +collector::instance() +{ + static collector* s_instance = 0; + + return s_instance; +} + +//____________________________________________________________________________// + +void +collector::store_in( test_unit& tu ) +{ + tu.p_decorators.value = m_tu_decorator; + m_tu_decorator.reset(); + instance() = 0; +} + +//____________________________________________________________________________// + +// ************************************************************************** // +// ************** decorator::for_test_unit ************** // +// ************************************************************************** // + +for_test_unit const& +for_test_unit::operator+( for_test_unit const& rhs ) const +{ + rhs.m_next.reset( clone() ); + + return rhs; +} + +//____________________________________________________________________________// + +void +for_test_unit::apply( test_unit& tu ) +{ + if( m_next ) + m_next->apply( tu ); + do_apply( tu ); +} + +//____________________________________________________________________________// + +for_test_unit* +for_test_unit::clone() const +{ + for_test_unit* res = do_clone(); + res->m_next = m_next; + return res; +} + +//____________________________________________________________________________// + +// ************************************************************************** // +// ************** decorator::label ************** // +// ************************************************************************** // + +void +label::do_apply( test_unit& tu ) +{ + tu.add_label( m_label ); +} + +//____________________________________________________________________________// + +// ************************************************************************** // +// ************** decorator::expected_failures ************** // +// ************************************************************************** // + +void +expected_failures::do_apply( test_unit& tu ) +{ + tu.increase_exp_fail( m_exp_fail ); +} + +//____________________________________________________________________________// + +// ************************************************************************** // +// ************** decorator::timeout ************** // +// ************************************************************************** // + +void +timeout::do_apply( test_unit& tu ) +{ + tu.p_timeout.value = m_timeout; +} + +//____________________________________________________________________________// + +// ************************************************************************** // +// ************** decorator::description ************** // +// ************************************************************************** // + +void +description::do_apply( test_unit& tu ) +{ + tu.p_description.value += m_description; +} + +//____________________________________________________________________________// + +// ************************************************************************** // +// ************** decorator::depends_on ************** // +// ************************************************************************** // + +void +depends_on::do_apply( test_unit& tu ) +{ +#if !BOOST_TEST_SUPPORT_TOKEN_ITERATOR + throw setup_error( "depends_on decorator is not supported on this platform" ); +#else + string_token_iterator tit( m_dependency, (dropped_delimeters = "/", kept_delimeters = dt_none) ); + + test_unit* dep = &framework::master_test_suite(); + while( tit != string_token_iterator() ) { + BOOST_TEST_SETUP_ASSERT( dep->p_type == tut_suite, std::string( "incorrect dependency specification " ) + m_dependency ); + + test_unit_id next_id = static_cast(dep)->get( *tit ); + + if( next_id == INV_TEST_UNIT_ID ) + throw framework::setup_error( std::string( "incorrect dependency specification " ) + m_dependency ); + + dep = &framework::get( next_id, tut_any ); + ++tit; + } + + tu.depends_on( dep ); +#endif +} + +//____________________________________________________________________________// + +} // namespace decorator + +} // namespace unit_test + +} // namespace boost + +//____________________________________________________________________________// + +#include + +#endif // BOOST_TEST_DECORATORS_IPP_091911GER diff --git a/include/boost/test/impl/exception_safety.ipp b/include/boost/test/impl/exception_safety.ipp index 43944417..3561efd0 100644 --- a/include/boost/test/impl/exception_safety.ipp +++ b/include/boost/test/impl/exception_safety.ipp @@ -23,21 +23,21 @@ #include #include -#include #include #include -#include +#include #include #include #include -#include +#include #include #include // Boost #include +#include // STL #include @@ -509,7 +509,7 @@ exception_safety_tester::report_error() // ************************************************************************** // void BOOST_TEST_DECL -exception_safety( callback0<> const& F, const_string test_name ) +exception_safety( boost::function const& F, const_string test_name ) { exception_safety_tester est( test_name ); diff --git a/include/boost/test/impl/execution_monitor.ipp b/include/boost/test/impl/execution_monitor.ipp index 32774be8..4f15b491 100644 --- a/include/boost/test/impl/execution_monitor.ipp +++ b/include/boost/test/impl/execution_monitor.ipp @@ -791,7 +791,7 @@ static void boost_execution_monitor_attaching_signal_handler( int sig, siginfo_t // ************************************************************************** // int -execution_monitor::catch_signals( unit_test::callback0 const& F ) +execution_monitor::catch_signals( boost::function const& F ) { using namespace detail; @@ -1071,7 +1071,7 @@ invalid_param_handler( wchar_t const* /* expr */, // ************************************************************************** // int -execution_monitor::catch_signals( unit_test::callback0 const& F ) +execution_monitor::catch_signals( boost::function const& F ) { _invalid_parameter_handler old_iph = _invalid_parameter_handler(); BOOST_TEST_CRT_HOOK_TYPE old_crt_hook = 0; @@ -1124,7 +1124,7 @@ public: } // namespace detail int -execution_monitor::catch_signals( unit_test::callback0 const& F ) +execution_monitor::catch_signals( boost::function const& F ) { return detail::do_invoke( m_custom_translators , F ); } @@ -1148,7 +1148,7 @@ execution_monitor::execution_monitor() //____________________________________________________________________________// int -execution_monitor::execute( unit_test::callback0 const& F ) +execution_monitor::execute( boost::function const& F ) { if( debug::under_debugger() ) p_catch_system_errors.value = false; @@ -1273,6 +1273,20 @@ execution_monitor::execute( unit_test::callback0 const& F ) //____________________________________________________________________________// +void +execution_monitor::vexecute( boost::function const& F ) +{ + struct forward { + explicit forward( boost::function const& F ) : m_F( F ) {} + + int operator()() { m_F(); return 0; } + + boost::function const& m_F; + }; + + execute( forward( F ) ); +} + // ************************************************************************** // // ************** system_error ************** // // ************************************************************************** // diff --git a/include/boost/test/impl/framework.ipp b/include/boost/test/impl/framework.ipp index 36c37e19..ec3ad97d 100644 --- a/include/boost/test/impl/framework.ipp +++ b/include/boost/test/impl/framework.ipp @@ -22,14 +22,13 @@ #include #include #include -#include +#include #include #include #include #include -#if !defined(__BORLANDC__) && !BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) && !BOOST_WORKAROUND( __SUNPRO_CC, < 0x5100 ) -#define BOOST_TEST_SUPPORT_RUN_BY_NAME +#if BOOST_TEST_SUPPORT_TOKEN_ITERATOR #include #endif @@ -61,33 +60,13 @@ namespace boost { namespace unit_test { // ************************************************************************** // -// ************** test_start calls wrapper ************** // +// ************** test_init call wrapper ************** // // ************************************************************************** // namespace ut_detail { -struct test_start_caller { - test_start_caller( test_observer* to, counter_t tc_amount ) - : m_to( to ) - , m_tc_amount( tc_amount ) - {} - - int operator()() - { - m_to->test_start( m_tc_amount ); - return 0; - } - -private: - // Data members - test_observer* m_to; - counter_t m_tc_amount; -}; - -//____________________________________________________________________________// - -struct test_init_caller { - explicit test_init_caller( init_unit_test_func init_func ) +struct test_init_invoker { + explicit test_init_invoker( init_unit_test_func init_func ) : m_init_func( init_func ) {} int operator()() @@ -108,20 +87,6 @@ struct test_init_caller { init_unit_test_func m_init_func; }; -// ************************************************************************** // -// ************** tu_enabler ************** // -// ************************************************************************** // - -struct tu_enabler : public test_tree_visitor { - explicit tu_enabler( bool on_off ) : m_on_off( on_off ) {} -private: - virtual void visit( test_case const& tc ) { tc.p_enabled.value = m_on_off; } - virtual bool test_suite_start( test_suite const& ts ) { ts.p_enabled.value = m_on_off; return true; } - - // Data members - bool m_on_off; -}; - // ************************************************************************** // // ************** name_filter ************** // // ************************************************************************** // @@ -180,7 +145,7 @@ public: // Constructor name_filter( tu_enable_list& tu_to_enable, const_string tc_to_run ) : m_tu_to_enable( tu_to_enable ), m_depth( 0 ) { -#ifdef BOOST_TEST_SUPPORT_RUN_BY_NAME +#ifdef BOOST_TEST_SUPPORT_TOKEN_ITERATOR string_token_iterator tit( tc_to_run, (dropped_delimeters = "/", kept_delimeters = dt_none) ); while( tit != string_token_iterator() ) { @@ -246,21 +211,12 @@ public: {} private: - bool filter_unit( test_unit const& tu ) - { - return tu.has_label( m_label ); - } - // test_tree_visitor interface - virtual void visit( test_case const& tc ) + virtual bool visit( test_unit const& tu ) { - if( filter_unit( tc ) ) - m_tu_to_enable.push_back( std::make_pair( tc.p_id, false ) ); // found a test case; add it to enable list without children - } - virtual bool test_suite_start( test_suite const& ts ) - { - if( filter_unit( ts ) ) { - m_tu_to_enable.push_back( std::make_pair( ts.p_id, true ) ); // found a test suite; add it to enable list with children and stop recursion + if( tu.has_label( m_label ) ) { + // found a test unit; add it to list of tu to enable with children and stop recursion in case of suites + m_tu_to_enable.push_back( std::make_pair( tu.p_id, tu.p_type == tut_suite ) ); return false; } @@ -268,29 +224,40 @@ private: } // Data members - const_string m_label; tu_enable_list& m_tu_to_enable; + const_string m_label; }; // ************************************************************************** // -// ************** tu_collector ************** // +// ************** change_status ************** // // ************************************************************************** // -class tu_collector : public test_tree_visitor { +class change_status : public test_tree_visitor { public: - explicit tu_collector( tu_enable_list& tu_to_enable ) : m_tu_to_enable( tu_to_enable ) {} + explicit change_status( bool enable_or_disable ) : m_new_status( enable_or_disable ) {} private: // test_tree_visitor interface - virtual void visit( test_case const& tc ) + virtual bool visit( test_unit const& tu ) { tu.p_enabled.value = m_new_status; return true; } + + // Data members + bool m_new_status; +}; + +// ************************************************************************** // +// ************** collect_disabled ************** // +// ************************************************************************** // + +class collect_disabled : public test_tree_visitor { +public: + explicit collect_disabled( tu_enable_list& tu_to_enable ) : m_tu_to_enable( tu_to_enable ) {} + +private: + // test_tree_visitor interface + virtual bool visit( test_unit const& tu ) { - if( !tc.p_enabled ) - m_tu_to_enable.push_back( std::make_pair( tc.p_id, false ) ); - } - virtual bool test_suite_start( test_suite const& ts ) - { - if( !ts.p_enabled ) - m_tu_to_enable.push_back( std::make_pair( ts.p_id, false ) ); + if( !tu.p_enabled ) + m_tu_to_enable.push_back( std::make_pair( tu.p_id, false ) ); return true; } @@ -299,6 +266,22 @@ private: tu_enable_list& m_tu_to_enable; }; +// ************************************************************************** // +// ************** apply_decorators ************** // +// ************************************************************************** // + +class apply_decorators : public test_tree_visitor { +private: + // test_tree_visitor interface + virtual bool visit( test_unit const& tu ) + { + if( tu.p_decorators.get() ) + tu.p_decorators.get()->apply( const_cast(tu) ); + + return true; + } +}; + } // namespace ut_detail // ************************************************************************** // @@ -360,7 +343,6 @@ public: unsigned long elapsed = static_cast( tc_timer.elapsed() * 1e6 ); - // notify all observers about abortion if( unit_test_monitor.is_critical_error( run_result ) ) { BOOST_TEST_FOREACH( test_observer*, to, m_observers ) @@ -487,7 +469,7 @@ init( init_unit_test_func init_func, int argc, char* argv[] ) try { boost::execution_monitor em; - ut_detail::test_init_caller tic( init_func ); + ut_detail::test_init_invoker tic( init_func ); em.execute( tic ); } @@ -495,6 +477,9 @@ init( init_unit_test_func init_func, int argc, char* argv[] ) throw setup_error( ex.what() ); } + ut_detail::apply_decorators ad; + traverse_test_tree( master_test_suite().p_id, ad, true ); + impl::apply_filters( master_test_suite().p_id ); s_frk_impl().m_is_initialized = true; @@ -507,14 +492,14 @@ void apply_filters( test_unit_id tu_id ) { if( runtime_config::test_to_run().empty() ) { - ut_detail::tu_enabler enable( true ); - - traverse_test_tree( tu_id, enable ); + // enable all test units for this run + ut_detail::change_status enabler( true ); + traverse_test_tree( tu_id, enabler, true ); } else { - // 10. first disable all tu - ut_detail::tu_enabler disable( false ); - traverse_test_tree( tu_id, disable ); + // 10. First disable all test units. We'll re-enable only those that pass the filters + ut_detail::change_status disabler( false ); + traverse_test_tree( tu_id, disabler, true ); // 20. collect tu to enable based on filters ut_detail::tu_enable_list tu_to_enable; @@ -568,17 +553,17 @@ apply_filters( test_unit_id tu_id ) // 35. add all children to the list recursively if( data.second && tu.p_type == tut_suite ) { - ut_detail::tu_collector collect( tu_to_enable ); - traverse_test_tree( tu.p_id, collect, true ); + ut_detail::collect_disabled V( tu_to_enable ); + traverse_test_tree( tu.p_id, V, true ); } } } } -} // namespace impl - //____________________________________________________________________________// +} // namespace impl + bool is_initialized() { @@ -787,7 +772,7 @@ run( test_unit_id id, bool continue_test ) boost::execution_monitor em; try { - em.execute( ut_detail::test_start_caller( to, tcc.p_count ) ); + em.vexecute( boost::bind( &test_observer::test_start, to, tcc.p_count ) ); } catch( execution_exception const& ex ) { throw setup_error( ex.what() ); diff --git a/include/boost/test/impl/interaction_based.ipp b/include/boost/test/impl/interaction_based.ipp index 60a5eb67..97d39a67 100644 --- a/include/boost/test/impl/interaction_based.ipp +++ b/include/boost/test/impl/interaction_based.ipp @@ -22,9 +22,8 @@ // Boost.Test #include -#include -#include -#include +#include +#include #include // for setup_error #include diff --git a/include/boost/test/impl/logged_expectations.ipp b/include/boost/test/impl/logged_expectations.ipp index 66eda672..8db01113 100644 --- a/include/boost/test/impl/logged_expectations.ipp +++ b/include/boost/test/impl/logged_expectations.ipp @@ -22,16 +22,16 @@ #include -#include #include -#include +#include #include #include // Boost #include +#include // STL #include @@ -224,7 +224,7 @@ expectations_logger::return_value( const_string default_value ) // ************************************************************************** // void BOOST_TEST_DECL -logged_expectations( callback0<> const& F, const_string log_file_name, bool test_or_log ) +logged_expectations( boost::function const& F, const_string log_file_name, bool test_or_log ) { expectations_logger el( log_file_name, test_or_log ); diff --git a/include/boost/test/impl/test_tools.ipp b/include/boost/test/impl/test_tools.ipp index 67cc650b..bd7fcdd0 100644 --- a/include/boost/test/impl/test_tools.ipp +++ b/include/boost/test/impl/test_tools.ipp @@ -18,7 +18,7 @@ // Boost.Test #include #include -#include +#include #include #include // execution_aborted #include diff --git a/include/boost/test/impl/unit_test_monitor.ipp b/include/boost/test/impl/unit_test_monitor.ipp index 6b8ad6c1..56b3005c 100644 --- a/include/boost/test/impl/unit_test_monitor.ipp +++ b/include/boost/test/impl/unit_test_monitor.ipp @@ -32,26 +32,6 @@ namespace boost { namespace unit_test { -namespace { - -template -struct zero_return_wrapper_t { - explicit zero_return_wrapper_t( F const& f ) : m_f( f ) {} - - int operator()() { m_f(); return 0; } - - F const& m_f; -}; - -template -zero_return_wrapper_t -zero_return_wrapper( F const& f ) -{ - return zero_return_wrapper_t( f ); -} - -} - // ************************************************************************** // // ************** unit_test_monitor ************** // // ************************************************************************** // @@ -66,7 +46,7 @@ unit_test_monitor_t::execute_and_translate( test_case const& tc ) p_use_alt_stack.value = runtime_config::use_alt_stack(); p_detect_fp_exceptions.value = runtime_config::detect_fp_exceptions(); - execute( callback0( zero_return_wrapper( tc.test_func() ) ) ); + vexecute( tc.p_test_func ); } catch( execution_exception const& ex ) { framework::exception_caught( ex ); diff --git a/include/boost/test/impl/unit_test_suite.ipp b/include/boost/test/impl/unit_test_suite.ipp index 77872ddf..793a3fe4 100644 --- a/include/boost/test/impl/unit_test_suite.ipp +++ b/include/boost/test/impl/unit_test_suite.ipp @@ -102,7 +102,7 @@ test_unit::increase_exp_fail( unsigned num ) void test_unit::add_label( const_string l ) { - m_labels.push_back( std::string( l.begin(), l.end() ) ); + m_labels.push_back( std::string() + l ); } //____________________________________________________________________________// @@ -119,14 +119,10 @@ test_unit::has_label( const_string l ) const // ************** test_case ************** // // ************************************************************************** // -test_case::test_case( const_string name, callback0<> const& test_func ) +test_case::test_case( const_string name, boost::function const& test_func ) : test_unit( name, static_cast(type) ) -, m_test_func( test_func ) +, p_test_func( test_func ) { - // !! weirdest MSVC BUG; try to remove this statement; looks like it eats first token of next statement -#if BOOST_WORKAROUND(BOOST_MSVC,<1300) - 0; -#endif framework::register_test_unit( this ); } @@ -155,7 +151,7 @@ test_suite::add( test_unit* tu, counter_t expected_failures, unsigned timeout ) m_members.push_back( tu->p_id ); tu->p_parent_id.value = p_id; - if( tu->p_expected_failures ) + if( tu->p_expected_failures != 0 ) increase_exp_fail( tu->p_expected_failures ); if( expected_failures ) @@ -214,7 +210,7 @@ traverse_test_tree( test_case const& tc, test_tree_visitor& V, bool ignore_statu void traverse_test_tree( test_suite const& suite, test_tree_visitor& V, bool ignore_status ) { - if( (!suite.p_enabled && !ignore_status) || !V.test_suite_start( suite ) ) + if( (!ignore_status && !suite.p_enabled) || !V.test_suite_start( suite ) ) return; try { @@ -252,19 +248,6 @@ traverse_test_tree( test_unit_id id, test_tree_visitor& V, bool ignore_status ) //____________________________________________________________________________// -// ************************************************************************** // -// ************** test_case_counter ************** // -// ************************************************************************** // - -void -test_case_counter::visit( test_case const& tc ) -{ - if( tc.p_enabled ) - ++p_count.value; -} - -//____________________________________________________________________________// - // ************************************************************************** // // ************** object generators ************** // // ************************************************************************** // @@ -285,21 +268,24 @@ normalize_test_case_name( const_string name ) // ************** auto_test_unit_registrar ************** // // ************************************************************************** // -auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, counter_t exp_fail ) +auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, decorator::collector* decorators, counter_t exp_fail ) { curr_ts_store().back()->add( tc, exp_fail ); + + if( decorators ) + decorators->store_in( *tc ); } //____________________________________________________________________________// -auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name ) +auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name, decorator::collector* decorators ) { test_unit_id id = curr_ts_store().back()->get( ts_name ); test_suite* ts; if( id != INV_TEST_UNIT_ID ) { - ts = &framework::get( id ); // !! test for invalid tu type + ts = &framework::get( id ); BOOST_ASSERT( ts->p_parent_id == curr_ts_store().back()->p_id ); } else { @@ -307,14 +293,21 @@ auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name ) curr_ts_store().back()->add( ts ); } + if( decorators ) + decorators->store_in( *ts ); + curr_ts_store().push_back( ts ); } //____________________________________________________________________________// -auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_gen ) +auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector* decorators ) { curr_ts_store().back()->add( tc_gen ); + + // !! ??if( decorators ) + // decorators->apply( *tc ); + } //____________________________________________________________________________// @@ -355,8 +348,6 @@ global_fixture::global_fixture() } // namespace boost -//____________________________________________________________________________// - #include #endif // BOOST_TEST_UNIT_TEST_SUITE_IPP_012205GER diff --git a/include/boost/test/included/test_exec_monitor.hpp b/include/boost/test/included/test_exec_monitor.hpp deleted file mode 100644 index b9e3ef96..00000000 --- a/include/boost/test/included/test_exec_monitor.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : included (vs. linked) version of Test Execution Monitor -// *************************************************************************** - -#ifndef BOOST_INCLUDED_TEST_EXEC_MONITOR_HPP_071894GER -#define BOOST_INCLUDED_TEST_EXEC_MONITOR_HPP_071894GER - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BOOST_TEST_INCLUDED -#include - -#endif // BOOST_INCLUDED_TEST_EXEC_MONITOR_HPP_071894GER diff --git a/include/boost/test/included/unit_test.hpp b/include/boost/test/included/unit_test.hpp index 45833902..6d8a60b1 100644 --- a/include/boost/test/included/unit_test.hpp +++ b/include/boost/test/included/unit_test.hpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include diff --git a/include/boost/test/included/unit_test_framework.hpp b/include/boost/test/included/unit_test_framework.hpp deleted file mode 100644 index 2eab54ea..00000000 --- a/include/boost/test/included/unit_test_framework.hpp +++ /dev/null @@ -1,2 +0,0 @@ -// deprecated -#include diff --git a/include/boost/test/exception_safety.hpp b/include/boost/test/interaction/exception_safety.hpp similarity index 91% rename from include/boost/test/exception_safety.hpp rename to include/boost/test/interaction/exception_safety.hpp index b64ff2fb..1b4c4425 100644 --- a/include/boost/test/exception_safety.hpp +++ b/include/boost/test/interaction/exception_safety.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2005-2010. +// (C) Copyright Gennadiy Rozental 2005-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -18,12 +18,12 @@ // Boost.Test #include -#include #include #include // Boost #include +#include // STL #include @@ -53,8 +53,7 @@ struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \ BOOST_AUTO_TU_REGISTRAR( test_name )( \ boost::unit_test::make_test_case( \ &BOOST_AUTO_TC_INVOKER( test_name ), #test_name ), \ - boost::unit_test::ut_detail::auto_tc_exp_fail< \ - BOOST_AUTO_TC_UNIQUE_ID( test_name )>::instance()->value() ); \ + boost::unit_test::decorator::collector::instance() ); \ \ void test_name::test_method() \ /**/ @@ -67,8 +66,7 @@ namespace itest { // ************** exception safety test ************** // // ************************************************************************** // -void BOOST_TEST_DECL exception_safety( unit_test::callback0<> const& F, - unit_test::const_string test_name = "" ); +void BOOST_TEST_DECL exception_safety( boost::function const& F, unit_test::const_string test_name = "" ); } // namespace itest @@ -80,7 +78,7 @@ void BOOST_TEST_DECL exception_safety( unit_test::callback0<> const& F, #ifndef BOOST_ITEST_NO_NEW_OVERLOADS -#include +#include # ifdef BOOST_NO_STDC_NAMESPACE namespace std { using ::isprint; using ::malloc; using ::free; } @@ -184,8 +182,6 @@ operator delete[]( void* p, std::nothrow_t const& ) throw() #endif // BOOST_ITEST_NO_NEW_OVERLOADS -//____________________________________________________________________________// - #include #endif // BOOST_TEST_EXCEPTION_SAFETY_HPP_111705GER diff --git a/include/boost/test/interaction_based.hpp b/include/boost/test/interaction/interaction_based.hpp similarity index 99% rename from include/boost/test/interaction_based.hpp rename to include/boost/test/interaction/interaction_based.hpp index 42718bc5..4be81d81 100644 --- a/include/boost/test/interaction_based.hpp +++ b/include/boost/test/interaction/interaction_based.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2005-2010. +// (C) Copyright Gennadiy Rozental 2005-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/test/logged_expectations.hpp b/include/boost/test/interaction/logged_expectations.hpp similarity index 87% rename from include/boost/test/logged_expectations.hpp rename to include/boost/test/interaction/logged_expectations.hpp index 5f418558..dcf87408 100644 --- a/include/boost/test/logged_expectations.hpp +++ b/include/boost/test/interaction/logged_expectations.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2005-2010. +// (C) Copyright Gennadiy Rozental 2005-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -18,7 +18,9 @@ // Boost.Test #include #include -#include + +// Boost +#include #include @@ -46,8 +48,7 @@ struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \ BOOST_AUTO_TU_REGISTRAR( test_name )( \ boost::unit_test::make_test_case( \ &BOOST_AUTO_TC_INVOKER( test_name ), #test_name ), \ - boost::unit_test::ut_detail::auto_tc_exp_fail< \ - BOOST_AUTO_TC_UNIQUE_ID( test_name )>::instance()->value() ); \ + boost::unit_test::decorator::collector::instance() ); \ \ void test_name::test_method() \ /**/ @@ -61,9 +62,7 @@ namespace itest { // ************************************************************************** // void BOOST_TEST_DECL -logged_expectations( unit_test::callback0<> const& F, - unit_test::const_string log_file_name, - bool test_or_log = true ); +logged_expectations( boost::function const& F, unit_test::const_string log_file_name, bool test_or_log = true ); } // namespace itest diff --git a/include/boost/test/mock_object.hpp b/include/boost/test/interaction/mock_object.hpp similarity index 99% rename from include/boost/test/mock_object.hpp rename to include/boost/test/interaction/mock_object.hpp index 32eb9f73..4eb9635f 100644 --- a/include/boost/test/mock_object.hpp +++ b/include/boost/test/interaction/mock_object.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2005-2010. +// (C) Copyright Gennadiy Rozental 2005-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -17,7 +17,7 @@ // Boost.Test #include -#include +#include // Boost #include diff --git a/include/boost/test/minimal.hpp b/include/boost/test/minimal.hpp index f74b0d7d..8b63937a 100644 --- a/include/boost/test/minimal.hpp +++ b/include/boost/test/minimal.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2002-2010. +// (C) Copyright Gennadiy Rozental 2002-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -118,9 +118,7 @@ int BOOST_TEST_CALL_DECL main( int argc, char* argv[] ) } catch( boost::execution_exception const& exex ) { if( exex.code() != boost::execution_exception::no_error ) - BOOST_ERROR( (std::string( "exception \"" ). - append( exex.what().begin(), exex.what().end() ). - append( "\" caught" ) ).c_str() ); + BOOST_ERROR( (std::string( "exception \"" ) + exex.what() + "\" caught").c_str() ); std::cerr << "\n**** Testing aborted."; } diff --git a/include/boost/test/parameterized_test.hpp b/include/boost/test/parameterized_test.hpp index 0662e185..055723b1 100644 --- a/include/boost/test/parameterized_test.hpp +++ b/include/boost/test/parameterized_test.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. +// (C) Copyright Gennadiy Rozental 2001-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -17,12 +17,14 @@ // Boost.Test #include -#include // Boost #include #include +#include +#include + #include //____________________________________________________________________________// @@ -44,27 +46,8 @@ namespace boost { namespace unit_test { -// ************************************************************************** // -// ************** test_func_with_bound_param ************** // -// ************************************************************************** // - namespace ut_detail { -template -struct test_func_with_bound_param { - template - test_func_with_bound_param( callback1 test_func, T const& param ) - : m_test_func( test_func ) - , m_param( param ) - {} - - void operator()() { m_test_func( m_param ); } - -private: - callback1 m_test_func; - ParamType m_param; -}; - // ************************************************************************** // // ************** param_test_case_generator ************** // // ************************************************************************** // @@ -72,10 +55,10 @@ private: template class param_test_case_generator : public test_unit_generator { public: - param_test_case_generator( callback1 const& test_func, - const_string tc_name, - ParamIter par_begin, - ParamIter par_end ) + param_test_case_generator( boost::function const& test_func, + const_string tc_name, + ParamIter par_begin, + ParamIter par_end ) : m_test_func( test_func ) , m_tc_name( ut_detail::normalize_test_case_name( tc_name ) ) , m_par_begin( par_begin ) @@ -87,8 +70,7 @@ public: if( m_par_begin == m_par_end ) return (test_unit*)0; - test_func_with_bound_param bound_test_func( m_test_func, *m_par_begin ); - test_unit* res = new test_case( m_tc_name, bound_test_func ); + test_unit* res = new test_case( m_tc_name, boost::bind( m_test_func, *m_par_begin ) ); ++m_par_begin; @@ -97,7 +79,7 @@ public: private: // Data members - callback1 m_test_func; + boost::function m_test_func; std::string m_tc_name; mutable ParamIter m_par_begin; ParamIter m_par_end; @@ -126,10 +108,10 @@ struct user_param_tc_method_invoker { template inline ut_detail::param_test_case_generator -make_test_case( callback1 const& test_func, - const_string tc_name, - ParamIter par_begin, - ParamIter par_end ) +make_test_case( boost::function const& test_func, + const_string tc_name, + ParamIter par_begin, + ParamIter par_end ) { return ut_detail::param_test_case_generator( test_func, tc_name, par_begin, par_end ); } diff --git a/include/boost/test/prg_exec_monitor.hpp b/include/boost/test/prg_exec_monitor.hpp index 2ef3a6a0..fa5dcd81 100644 --- a/include/boost/test/prg_exec_monitor.hpp +++ b/include/boost/test/prg_exec_monitor.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. +// (C) Copyright Gennadiy Rozental 2001-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/test/progress_monitor.hpp b/include/boost/test/progress_monitor.hpp index 9eb5882c..be3b8d1a 100644 --- a/include/boost/test/progress_monitor.hpp +++ b/include/boost/test/progress_monitor.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2005-2010. +// (C) Copyright Gennadiy Rozental 2005-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -16,7 +16,7 @@ #define BOOST_TEST_PROGRESS_MONITOR_HPP_020105GER // Boost.Test -#include +#include #include // STL diff --git a/include/boost/test/results_collector.hpp b/include/boost/test/results_collector.hpp index 571f881d..b5a2870b 100644 --- a/include/boost/test/results_collector.hpp +++ b/include/boost/test/results_collector.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. +// (C) Copyright Gennadiy Rozental 2001-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -17,7 +17,7 @@ #define BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER // Boost.Test -#include +#include #include #include diff --git a/include/boost/test/results_reporter.hpp b/include/boost/test/results_reporter.hpp index 9e0031fc..bbd9a6b0 100644 --- a/include/boost/test/results_reporter.hpp +++ b/include/boost/test/results_reporter.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. +// (C) Copyright Gennadiy Rozental 2001-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/test/test_case_template.hpp b/include/boost/test/test_case_template.hpp deleted file mode 100644 index 44136c3d..00000000 --- a/include/boost/test/test_case_template.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2003-2010. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : deprecated -// *************************************************************************** - -#include diff --git a/include/boost/test/test_exec_monitor.hpp b/include/boost/test/test_exec_monitor.hpp deleted file mode 100644 index ecdfc6db..00000000 --- a/include/boost/test/test_exec_monitor.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : Entry point for the end user into the Test Execution Monitor. -// *************************************************************************** - -#ifndef BOOST_TEST_EXEC_MONITOR_HPP_071894GER -#define BOOST_TEST_EXEC_MONITOR_HPP_071894GER - -// Boost.Test -#include - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** Auto Linking ************** // -// ************************************************************************** // - -// Automatically link to the correct build variant where possible. -#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_TEST_NO_LIB) && \ - !defined(BOOST_TEST_SOURCE) && !defined(BOOST_TEST_INCLUDED) - -# define BOOST_LIB_NAME boost_test_exec_monitor -# include - -#endif // auto-linking disabled - -#endif // BOOST_TEST_EXEC_MONITOR_HPP_071894GER diff --git a/include/boost/test/test_tools.hpp b/include/boost/test/test_tools.hpp index 86547f63..bc11d052 100644 --- a/include/boost/test/test_tools.hpp +++ b/include/boost/test/test_tools.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. +// (C) Copyright Gennadiy Rozental 2001-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -16,7 +16,6 @@ #define BOOST_TEST_TEST_TOOLS_HPP_012705GER // Boost.Test -#include #ifndef BOOST_TEST_PROD #include #define BOOST_TEST_TOOLS_STRINGIZE( arg ) BOOST_TEST_STRINGIZE( arg ) @@ -24,15 +23,6 @@ #define BOOST_TEST_PASSPOINT() #define BOOST_TEST_TOOLS_STRINGIZE( arg ) BOOST_STRINGIZE( arg ) #endif -#include - -#include -#include -#include - -#include -#include -#include // Boost #include @@ -42,24 +32,6 @@ #include #include -#include - -#include -#include -#include - -#include - -// STL -#include // for std::size_t -#include -#include // for std::boolalpha -#include // for CHAR_BIT - -#ifdef BOOST_MSVC -# pragma warning(disable: 4127) // conditional expression is constant -#endif - #include //____________________________________________________________________________// @@ -303,50 +275,6 @@ do { \ //____________________________________________________________________________// -// ***************************** // -// deprecated interface - -#define BOOST_BITWISE_EQUAL( L, R ) BOOST_CHECK_BITWISE_EQUAL( L, R ) -#define BOOST_MESSAGE( M ) BOOST_TEST_MESSAGE( M ) -#define BOOST_CHECKPOINT( M ) BOOST_TEST_CHECKPOINT( M ) - -namespace boost { - -namespace test_tools { - -typedef unit_test::const_string const_string; - -namespace { bool dummy_cond = false; } - -// ************************************************************************** // -// ************** print_log_value ************** // -// ************************************************************************** // - -template -struct print_log_value { - void operator()( std::ostream& ostr, T const& t ) - { - // avoid warning: 'boost::test_tools::::dummy_cond' defined but not used - if (::boost::test_tools::dummy_cond) {} - - typedef typename mpl::or_,is_function,is_abstract >::type cant_use_nl; - - set_precision( ostr, cant_use_nl() ); - - ostr << t; // by default print the value - } - - void set_precision( std::ostream& ostr, mpl::false_ ) - { - if( std::numeric_limits::is_specialized && std::numeric_limits::radix == 2 ) - ostr.precision( 2 + std::numeric_limits::digits * 301/1000 ); - } - - void set_precision( std::ostream&, mpl::true_ ) {} -}; - -//____________________________________________________________________________// - #define BOOST_TEST_DONT_PRINT_LOG_VALUE( the_type ) \ namespace boost { namespace test_tools { \ template<> \ @@ -358,393 +286,7 @@ struct print_log_value { \ //____________________________________________________________________________// -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -template -struct print_log_value< T[N] > { - void operator()( std::ostream& ostr, T const* t ) - { - ostr << t; - } -}; -#endif - -//____________________________________________________________________________// - -template<> -struct BOOST_TEST_DECL print_log_value { - void operator()( std::ostream& ostr, bool t ) - { - ostr << std::boolalpha << t; - } -}; - -//____________________________________________________________________________// - -template<> -struct BOOST_TEST_DECL print_log_value { - void operator()( std::ostream& ostr, char t ); -}; - -//____________________________________________________________________________// - -template<> -struct BOOST_TEST_DECL print_log_value { - void operator()( std::ostream& ostr, unsigned char t ); -}; - -//____________________________________________________________________________// - -template<> -struct BOOST_TEST_DECL print_log_value { - void operator()( std::ostream& ostr, char const* t ); -}; - -//____________________________________________________________________________// - -template<> -struct BOOST_TEST_DECL print_log_value { - void operator()( std::ostream& ostr, wchar_t const* t ); -}; - -//____________________________________________________________________________// - -namespace tt_detail { - -// ************************************************************************** // -// ************** tools classification ************** // -// ************************************************************************** // - -enum check_type { - CHECK_PRED, - CHECK_MSG, - CHECK_EQUAL, - CHECK_NE, - CHECK_LT, - CHECK_LE, - CHECK_GT, - CHECK_GE, - CHECK_CLOSE, - CHECK_CLOSE_FRACTION, - CHECK_SMALL, - CHECK_BITWISE_EQUAL, - CHECK_PRED_WITH_ARGS, - CHECK_EQUAL_COLL -}; - -enum tool_level { - WARN, CHECK, REQUIRE, PASS -}; - -// ************************************************************************** // -// ************** print_helper ************** // -// ************************************************************************** // -// Adds level of indirection to the output operation, allowing us to customize -// it for types that do not support operator << directly or for any other reason - -template -struct print_helper_t { - explicit print_helper_t( T const& t ) : m_t( t ) {} - - T const& m_t; -}; - -//____________________________________________________________________________// - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -// Borland suffers premature pointer decay passing arrays by reference -template -struct print_helper_t< T[N] > { - explicit print_helper_t( T const * t ) : m_t( t ) {} - - T const * m_t; -}; -#endif - -//____________________________________________________________________________// - -template -inline print_helper_t print_helper( T const& t ) -{ - return print_helper_t( t ); -} - -//____________________________________________________________________________// - -template -inline std::ostream& -operator<<( std::ostream& ostr, print_helper_t const& ph ) -{ - print_log_value()( ostr, ph.m_t ); - - return ostr; -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** TOOL BOX Implementation ************** // -// ************************************************************************** // - -BOOST_TEST_DECL -bool check_impl( predicate_result const& pr, ::boost::unit_test::lazy_ostream const& assertion_descr, - const_string file_name, std::size_t line_num, - tool_level tl, check_type ct, - std::size_t num_args, ... ); - -//____________________________________________________________________________// -// This function adds level of indirection, but it makes sure we evaluate predicate -// arguments only once - -#ifndef BOOST_TEST_PROD -#define TEMPL_PARAMS( z, m, dummy ) , typename BOOST_JOIN( Arg, m ) - -#define FUNC_PARAMS( z, m, dummy ) \ - , BOOST_JOIN( Arg, m ) const& BOOST_JOIN( arg, m ) \ - , char const* BOOST_JOIN( BOOST_JOIN( arg, m ), _descr ) \ -/**/ - -#define PRED_PARAMS( z, m, dummy ) BOOST_PP_COMMA_IF( m ) BOOST_JOIN( arg, m ) - -#define ARG_INFO( z, m, dummy ) \ - , BOOST_JOIN( BOOST_JOIN( arg, m ), _descr ) \ - , &static_cast(unit_test::lazy_ostream::instance() \ - << ::boost::test_tools::tt_detail::print_helper( BOOST_JOIN( arg, m ) )) \ -/**/ - -#define IMPL_FRWD( z, n, dummy ) \ -template \ -inline bool \ -check_frwd( Pred P, unit_test::lazy_ostream const& assertion_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, _ ) ), \ - assertion_descr, file_name, line_num, tl, ct, \ - BOOST_PP_ADD( n, 1 ) \ - BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), ARG_INFO, _ ) \ - ); \ -} \ -/**/ - -#ifndef BOOST_TEST_MAX_PREDICATE_ARITY -#define BOOST_TEST_MAX_PREDICATE_ARITY 5 -#endif - -BOOST_PP_REPEAT( BOOST_TEST_MAX_PREDICATE_ARITY, IMPL_FRWD, _ ) - -#undef TEMPL_PARAMS -#undef FUNC_PARAMS -#undef PRED_INFO -#undef ARG_INFO -#undef IMPL_FRWD - -#endif - -//____________________________________________________________________________// - -template -predicate_result equal_impl( Left const& left, Right const& right ) -{ - return left == right; -} - -//____________________________________________________________________________// - -predicate_result BOOST_TEST_DECL equal_impl( char const* left, char const* right ); -inline predicate_result equal_impl( char* left, char const* right ) { return equal_impl( static_cast(left), static_cast(right) ); } -inline predicate_result equal_impl( char const* left, char* right ) { return equal_impl( static_cast(left), static_cast(right) ); } -inline predicate_result equal_impl( char* left, char* right ) { return equal_impl( static_cast(left), static_cast(right) ); } - -#if !defined( BOOST_NO_CWCHAR ) -predicate_result BOOST_TEST_DECL equal_impl( wchar_t const* left, wchar_t const* right ); -inline predicate_result equal_impl( wchar_t* left, wchar_t const* right ) { return equal_impl( static_cast(left), static_cast(right) ); } -inline predicate_result equal_impl( wchar_t const* left, wchar_t* right ) { return equal_impl( static_cast(left), static_cast(right) ); } -inline predicate_result equal_impl( wchar_t* left, wchar_t* right ) { return equal_impl( static_cast(left), static_cast(right) ); } -#endif - -//____________________________________________________________________________// - -struct equal_impl_frwd { - template - inline predicate_result - call_impl( Left const& left, Right const& right, mpl::false_ ) const - { - return equal_impl( left, right ); - } - - template - inline predicate_result - call_impl( Left const& left, Right const& right, mpl::true_ ) const - { - return (*this)( right, &left[0] ); - } - - template - inline predicate_result - operator()( Left const& left, Right const& right ) const - { - typedef typename is_array::type left_is_array; - return call_impl( left, right, left_is_array() ); - } -}; - -//____________________________________________________________________________// - -struct ne_impl { - template - predicate_result operator()( Left const& left, Right const& right ) - { - return !equal_impl_frwd()( left, right ); - } -}; - -//____________________________________________________________________________// - -struct lt_impl { - template - predicate_result operator()( Left const& left, Right const& right ) - { - return left < right; - } -}; - -//____________________________________________________________________________// - -struct le_impl { - template - predicate_result operator()( Left const& left, Right const& right ) - { - return left <= right; - } -}; - -//____________________________________________________________________________// - -struct gt_impl { - template - predicate_result operator()( Left const& left, Right const& right ) - { - return left > right; - } -}; - -//____________________________________________________________________________// - -struct ge_impl { - template - predicate_result operator()( Left const& left, Right const& right ) - { - return left >= right; - } -}; - -//____________________________________________________________________________// - -struct equal_coll_impl { - template - predicate_result operator()( Left left_begin, Left left_end, Right right_begin, Right right_end ) - { - predicate_result pr( true ); - std::size_t pos = 0; - - for( ; left_begin != left_end && right_begin != right_end; ++left_begin, ++right_begin, ++pos ) { - if( *left_begin != *right_begin ) { - pr = false; - pr.message() << "\nMismatch in a position " << pos << ": " << *left_begin << " != " << *right_begin; - } - } - - if( left_begin != left_end ) { - std::size_t r_size = pos; - while( left_begin != left_end ) { - ++pos; - ++left_begin; - } - - pr = false; - pr.message() << "\nCollections size mismatch: " << pos << " != " << r_size; - } - - if( right_begin != right_end ) { - std::size_t l_size = pos; - while( right_begin != right_end ) { - ++pos; - ++right_begin; - } - - pr = false; - pr.message() << "\nCollections size mismatch: " << l_size << " != " << pos; - } - - return pr; - } -}; - -//____________________________________________________________________________// - -struct bitwise_equal_impl { - template - predicate_result operator()( Left const& left, Right const& right ) - { - predicate_result pr( true ); - - std::size_t left_bit_size = sizeof(Left)*CHAR_BIT; - std::size_t right_bit_size = sizeof(Right)*CHAR_BIT; - - static Left const leftOne( 1 ); - static Right const rightOne( 1 ); - - std::size_t total_bits = left_bit_size < right_bit_size ? left_bit_size : right_bit_size; - - for( std::size_t counter = 0; counter < total_bits; ++counter ) { - if( ( left & ( leftOne << counter ) ) != ( right & ( rightOne << counter ) ) ) { - pr = false; - pr.message() << "\nMismatch in a position " << counter; - } - } - - if( left_bit_size != right_bit_size ) { - pr = false; - pr.message() << "\nOperands bit sizes mismatch: " << left_bit_size << " != " << right_bit_size; - } - - return pr; - } -}; - -//____________________________________________________________________________// - -bool BOOST_TEST_DECL is_defined_impl( const_string symbol_name, const_string symbol_value ); - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** context_frame ************** // -// ************************************************************************** // - -struct BOOST_TEST_DECL context_frame { - explicit context_frame( ::boost::unit_test::lazy_ostream const& context_descr ); - ~context_frame(); - - operator bool(); - -private: - int m_frame_id; -}; - -} // namespace tt_detail - -} // namespace test_tools - -namespace test_toolbox = test_tools; - -} // namespace boost - -//____________________________________________________________________________// +#include #include diff --git a/include/boost/test/floating_point_comparison.hpp b/include/boost/test/tools/floating_point_comparison.hpp similarity index 99% rename from include/boost/test/floating_point_comparison.hpp rename to include/boost/test/tools/floating_point_comparison.hpp index 9431ba1e..7eb47304 100644 --- a/include/boost/test/floating_point_comparison.hpp +++ b/include/boost/test/tools/floating_point_comparison.hpp @@ -17,7 +17,7 @@ // Boost.Test #include -#include +#include // Boost #include // for std::numeric_limits diff --git a/include/boost/test/tools/impl.hpp b/include/boost/test/tools/impl.hpp new file mode 100755 index 00000000..55014523 --- /dev/null +++ b/include/boost/test/tools/impl.hpp @@ -0,0 +1,488 @@ +// (C) Copyright Gennadiy Rozental 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/test for the library home page. +// +// File : $RCSfile$ +// +// Version : $Revision: 74248 $ +// +// Description : implementation of test tools +// *************************************************************************** + +#ifndef BOOST_TEST_TEST_TOOLS_IMPL_HPP_012705GER +#define BOOST_TEST_TEST_TOOLS_IMPL_HPP_012705GER + +// Boost.Test +#include +#ifndef BOOST_TEST_PROD +#include +#endif + +#include + +#include +#include +#include + +#include +#include +#include + +// Boost +#include + +#include +#include +#include + +#include + +// STL +#include // for std::size_t +#include +#include // for std::boolalpha +#include // for CHAR_BIT + +#ifdef BOOST_MSVC +# pragma warning(disable: 4127) // conditional expression is constant +#endif + +#include + +//____________________________________________________________________________// + +// ************************************************************************** // +// ************** TOOL BOX ************** // +// ************************************************************************** // + +namespace boost { + +namespace test_tools { + +typedef unit_test::const_string const_string; + +namespace { bool dummy_cond = false; } + +// ************************************************************************** // +// ************** print_log_value ************** // +// ************************************************************************** // + +template +struct print_log_value { + void operator()( std::ostream& ostr, T const& t ) + { + // avoid warning: 'boost::test_tools::::dummy_cond' defined but not used + if( ::boost::test_tools::dummy_cond ) {} + + typedef typename mpl::or_,is_function,is_abstract >::type cant_use_nl; + + set_precision( ostr, cant_use_nl() ); + + ostr << t; // by default print the value + } + + void set_precision( std::ostream& ostr, mpl::false_ ) + { + if( std::numeric_limits::is_specialized && std::numeric_limits::radix == 2 ) + ostr.precision( 2 + std::numeric_limits::digits * 301/1000 ); + } + + void set_precision( std::ostream&, mpl::true_ ) {} +}; + +//____________________________________________________________________________// + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +template +struct print_log_value< T[N] > { + void operator()( std::ostream& ostr, T const* t ) + { + ostr << t; + } +}; +#endif + +//____________________________________________________________________________// + +template<> +struct BOOST_TEST_DECL print_log_value { + void operator()( std::ostream& ostr, bool t ) + { + ostr << std::boolalpha << t; + } +}; + +//____________________________________________________________________________// + +template<> +struct BOOST_TEST_DECL print_log_value { + void operator()( std::ostream& ostr, char t ); +}; + +//____________________________________________________________________________// + +template<> +struct BOOST_TEST_DECL print_log_value { + void operator()( std::ostream& ostr, unsigned char t ); +}; + +//____________________________________________________________________________// + +template<> +struct BOOST_TEST_DECL print_log_value { + void operator()( std::ostream& ostr, char const* t ); +}; + +//____________________________________________________________________________// + +template<> +struct BOOST_TEST_DECL print_log_value { + void operator()( std::ostream& ostr, wchar_t const* t ); +}; + +//____________________________________________________________________________// + +namespace tt_detail { + +// ************************************************************************** // +// ************** tools classification ************** // +// ************************************************************************** // + +enum check_type { + CHECK_PRED, + CHECK_MSG, + CHECK_EQUAL, + CHECK_NE, + CHECK_LT, + CHECK_LE, + CHECK_GT, + CHECK_GE, + CHECK_CLOSE, + CHECK_CLOSE_FRACTION, + CHECK_SMALL, + CHECK_BITWISE_EQUAL, + CHECK_PRED_WITH_ARGS, + CHECK_EQUAL_COLL +}; + +enum tool_level { + WARN, CHECK, REQUIRE, PASS +}; + +// ************************************************************************** // +// ************** print_helper ************** // +// ************************************************************************** // +// Adds level of indirection to the output operation, allowing us to customize +// it for types that do not support operator << directly or for any other reason + +template +struct print_helper_t { + explicit print_helper_t( T const& t ) : m_t( t ) {} + + T const& m_t; +}; + +//____________________________________________________________________________// + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +// Borland suffers premature pointer decay passing arrays by reference +template +struct print_helper_t< T[N] > { + explicit print_helper_t( T const * t ) : m_t( t ) {} + + T const * m_t; +}; +#endif + +//____________________________________________________________________________// + +template +inline print_helper_t print_helper( T const& t ) +{ + return print_helper_t( t ); +} + +//____________________________________________________________________________// + +template +inline std::ostream& +operator<<( std::ostream& ostr, print_helper_t const& ph ) +{ + print_log_value()( ostr, ph.m_t ); + + return ostr; +} + +//____________________________________________________________________________// + +// ************************************************************************** // +// ************** TOOL BOX Implementation ************** // +// ************************************************************************** // + +BOOST_TEST_DECL +bool check_impl( predicate_result const& pr, ::boost::unit_test::lazy_ostream const& assertion_descr, + const_string file_name, std::size_t line_num, + tool_level tl, check_type ct, + std::size_t num_args, ... ); + +//____________________________________________________________________________// + +// This function adds level of indirection, but it makes sure we evaluate predicate +// arguments only once + +#ifndef BOOST_TEST_PROD +#define TEMPL_PARAMS( z, m, dummy ) , typename BOOST_JOIN( Arg, m ) + +#define FUNC_PARAMS( z, m, dummy ) \ + , BOOST_JOIN( Arg, m ) const& BOOST_JOIN( arg, m ) \ + , char const* BOOST_JOIN( BOOST_JOIN( arg, m ), _descr ) \ +/**/ + +#define PRED_PARAMS( z, m, dummy ) BOOST_PP_COMMA_IF( m ) BOOST_JOIN( arg, m ) + +#define ARG_INFO( z, m, dummy ) \ + , BOOST_JOIN( BOOST_JOIN( arg, m ), _descr ) \ + , &static_cast(unit_test::lazy_ostream::instance() \ + << ::boost::test_tools::tt_detail::print_helper( BOOST_JOIN( arg, m ) )) \ +/**/ + +#define IMPL_FRWD( z, n, dummy ) \ +template \ +inline bool \ +check_frwd( Pred P, unit_test::lazy_ostream const& assertion_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, _ ) ), \ + assertion_descr, file_name, line_num, tl, ct, \ + BOOST_PP_ADD( n, 1 ) \ + BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), ARG_INFO, _ ) \ + ); \ +} \ +/**/ + +#ifndef BOOST_TEST_MAX_PREDICATE_ARITY +#define BOOST_TEST_MAX_PREDICATE_ARITY 5 +#endif + +BOOST_PP_REPEAT( BOOST_TEST_MAX_PREDICATE_ARITY, IMPL_FRWD, _ ) + +#undef TEMPL_PARAMS +#undef FUNC_PARAMS +#undef PRED_INFO +#undef ARG_INFO +#undef IMPL_FRWD + +#endif + +//____________________________________________________________________________// + +template +predicate_result equal_impl( Left const& left, Right const& right ) +{ + return left == right; +} + +//____________________________________________________________________________// + +predicate_result BOOST_TEST_DECL equal_impl( char const* left, char const* right ); +inline predicate_result equal_impl( char* left, char const* right ) { return equal_impl( static_cast(left), static_cast(right) ); } +inline predicate_result equal_impl( char const* left, char* right ) { return equal_impl( static_cast(left), static_cast(right) ); } +inline predicate_result equal_impl( char* left, char* right ) { return equal_impl( static_cast(left), static_cast(right) ); } + +#if !defined( BOOST_NO_CWCHAR ) +predicate_result BOOST_TEST_DECL equal_impl( wchar_t const* left, wchar_t const* right ); +inline predicate_result equal_impl( wchar_t* left, wchar_t const* right ) { return equal_impl( static_cast(left), static_cast(right) ); } +inline predicate_result equal_impl( wchar_t const* left, wchar_t* right ) { return equal_impl( static_cast(left), static_cast(right) ); } +inline predicate_result equal_impl( wchar_t* left, wchar_t* right ) { return equal_impl( static_cast(left), static_cast(right) ); } +#endif + +//____________________________________________________________________________// + +struct equal_impl_frwd { + template + inline predicate_result + call_impl( Left const& left, Right const& right, mpl::false_ ) const + { + return equal_impl( left, right ); + } + + template + inline predicate_result + call_impl( Left const& left, Right const& right, mpl::true_ ) const + { + return (*this)( right, &left[0] ); + } + + template + inline predicate_result + operator()( Left const& left, Right const& right ) const + { + typedef typename is_array::type left_is_array; + return call_impl( left, right, left_is_array() ); + } +}; + +//____________________________________________________________________________// + +struct ne_impl { + template + predicate_result operator()( Left const& left, Right const& right ) + { + return !equal_impl_frwd()( left, right ); + } +}; + +//____________________________________________________________________________// + +struct lt_impl { + template + predicate_result operator()( Left const& left, Right const& right ) + { + return left < right; + } +}; + +//____________________________________________________________________________// + +struct le_impl { + template + predicate_result operator()( Left const& left, Right const& right ) + { + return left <= right; + } +}; + +//____________________________________________________________________________// + +struct gt_impl { + template + predicate_result operator()( Left const& left, Right const& right ) + { + return left > right; + } +}; + +//____________________________________________________________________________// + +struct ge_impl { + template + predicate_result operator()( Left const& left, Right const& right ) + { + return left >= right; + } +}; + +//____________________________________________________________________________// + +struct equal_coll_impl { + template + predicate_result operator()( Left left_begin, Left left_end, Right right_begin, Right right_end ) + { + predicate_result pr( true ); + std::size_t pos = 0; + + for( ; left_begin != left_end && right_begin != right_end; ++left_begin, ++right_begin, ++pos ) { + if( *left_begin != *right_begin ) { + pr = false; + pr.message() << "\nMismatch in a position " << pos << ": " << *left_begin << " != " << *right_begin; + } + } + + if( left_begin != left_end ) { + std::size_t r_size = pos; + while( left_begin != left_end ) { + ++pos; + ++left_begin; + } + + pr = false; + pr.message() << "\nCollections size mismatch: " << pos << " != " << r_size; + } + + if( right_begin != right_end ) { + std::size_t l_size = pos; + while( right_begin != right_end ) { + ++pos; + ++right_begin; + } + + pr = false; + pr.message() << "\nCollections size mismatch: " << l_size << " != " << pos; + } + + return pr; + } +}; + +//____________________________________________________________________________// + +struct bitwise_equal_impl { + template + predicate_result operator()( Left const& left, Right const& right ) + { + predicate_result pr( true ); + + std::size_t left_bit_size = sizeof(Left)*CHAR_BIT; + std::size_t right_bit_size = sizeof(Right)*CHAR_BIT; + + static Left const leftOne( 1 ); + static Right const rightOne( 1 ); + + std::size_t total_bits = left_bit_size < right_bit_size ? left_bit_size : right_bit_size; + + for( std::size_t counter = 0; counter < total_bits; ++counter ) { + if( ( left & ( leftOne << counter ) ) != ( right & ( rightOne << counter ) ) ) { + pr = false; + pr.message() << "\nMismatch in a position " << counter; + } + } + + if( left_bit_size != right_bit_size ) { + pr = false; + pr.message() << "\nOperands bit sizes mismatch: " << left_bit_size << " != " << right_bit_size; + } + + return pr; + } +}; + +//____________________________________________________________________________// + +bool BOOST_TEST_DECL is_defined_impl( const_string symbol_name, const_string symbol_value ); + +//____________________________________________________________________________// + +// ************************************************************************** // +// ************** context_frame ************** // +// ************************************************************************** // + +struct BOOST_TEST_DECL context_frame { + explicit context_frame( ::boost::unit_test::lazy_ostream const& context_descr ); + ~context_frame(); + + operator bool(); + +private: + // Data members + int m_frame_id; +}; + +} // namespace tt_detail + +} // namespace test_tools + +} // namespace boost + +//____________________________________________________________________________// + +#include + +#endif // BOOST_TEST_TEST_TOOLS_IMPL_HPP_012705GER diff --git a/include/boost/test/output_test_stream.hpp b/include/boost/test/tools/output_test_stream.hpp similarity index 98% rename from include/boost/test/output_test_stream.hpp rename to include/boost/test/tools/output_test_stream.hpp index 04623914..d3aa4a0f 100644 --- a/include/boost/test/output_test_stream.hpp +++ b/include/boost/test/tools/output_test_stream.hpp @@ -18,7 +18,7 @@ // Boost.Test #include #include -#include +#include // STL #include // for std::size_t diff --git a/include/boost/test/predicate_result.hpp b/include/boost/test/tools/predicate_result.hpp similarity index 100% rename from include/boost/test/predicate_result.hpp rename to include/boost/test/tools/predicate_result.hpp diff --git a/include/boost/test/prod_tools.hpp b/include/boost/test/tools/prod_tools.hpp similarity index 100% rename from include/boost/test/prod_tools.hpp rename to include/boost/test/tools/prod_tools.hpp diff --git a/include/boost/test/tree/decorators.hpp b/include/boost/test/tree/decorators.hpp new file mode 100755 index 00000000..f1a792a1 --- /dev/null +++ b/include/boost/test/tree/decorators.hpp @@ -0,0 +1,193 @@ +// (C) Copyright Gennadiy Rozental 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/test for the library home page. +// +// File : $RCSfile$ +// +// Version : $Revision: 62016 $ +// +// Description : defines decorators to be using with auto registered test units +// *************************************************************************** + +#ifndef BOOST_TEST_DECORATORS_HPP_091911GER +#define BOOST_TEST_DECORATORS_HPP_091911GER + +// Boost.Test +#include +#include + +#include + +// Boost +#include + +#include + +//____________________________________________________________________________// + +namespace boost { + +namespace unit_test { + +class test_unit; + +namespace decorator { + +// ************************************************************************** // +// ************** decorator::collector ************** // +// ************************************************************************** // + +class for_test_unit; +typedef boost::shared_ptr for_test_unit_ptr; + +class BOOST_TEST_DECL collector { +public: + explicit collector( for_test_unit const& ); + static collector*& instance(); + + void store_in( test_unit& tu ); + +private: + // Data members + for_test_unit_ptr m_tu_decorator; +}; + +// ************************************************************************** // +// ************** decorator::for_test_unit ************** // +// ************************************************************************** // + +class BOOST_TEST_DECL for_test_unit { +public: + virtual ~for_test_unit() {} + + // composition interface 1 + for_test_unit const& operator+() const { return *this; } + for_test_unit const& operator+( for_test_unit const& rhs ) const; + + // composition interface 2 + for_test_unit const& operator-() const { return *this; } + for_test_unit const& operator-( for_test_unit const& rhs ) const { return *this + rhs; } + + // composition interface 3 + for_test_unit const& operator*() const { return *this; } + for_test_unit const& operator*( for_test_unit const& rhs ) const { return *this + rhs; } + + // application interface + void apply( test_unit& tu ); + for_test_unit* clone() const; + +private: + friend class collector; + + // decorator::for_test_unit interface + virtual for_test_unit* do_clone() const = 0; + virtual void do_apply( test_unit& ) = 0; + + // Data members + mutable for_test_unit_ptr m_next; +}; + +// ************************************************************************** // +// ************** decorator::label ************** // +// ************************************************************************** // + +class BOOST_TEST_DECL label : public decorator::for_test_unit { +public: + explicit label( const_string l ) : m_label( l ) {} + +private: + // decorator::for_test_unit interface + virtual void do_apply( test_unit& tu ); + virtual for_test_unit* do_clone() const { return new label( m_label ); } + + // Data members + const_string m_label; +}; + +// ************************************************************************** // +// ************** decorator::expected_failures ************** // +// ************************************************************************** // + +class BOOST_TEST_DECL expected_failures : public decorator::for_test_unit { +public: + explicit expected_failures( counter_t ef ) : m_exp_fail( ef ) {} + +private: + // decorator::for_test_unit interface + virtual void do_apply( test_unit& tu ); + virtual for_test_unit* do_clone() const { return new expected_failures( m_exp_fail ); } + + // Data members + counter_t m_exp_fail; +}; + +// ************************************************************************** // +// ************** decorator::timeout ************** // +// ************************************************************************** // + +class BOOST_TEST_DECL timeout : public decorator::for_test_unit { +public: + explicit timeout( unsigned t ) : m_timeout( t ) {} + +private: + // decorator::for_test_unit interface + virtual void do_apply( test_unit& tu ); + virtual for_test_unit* do_clone() const { return new timeout( m_timeout ); } + + // Data members + unsigned m_timeout; +}; + +// ************************************************************************** // +// ************** decorator::description ************** // +// ************************************************************************** // + +class BOOST_TEST_DECL description : public decorator::for_test_unit { +public: + explicit description( const_string descr ) : m_description( descr ) {} + +private: + // decorator::for_test_unit interface + virtual void do_apply( test_unit& tu ); + virtual for_test_unit* do_clone() const { return new description( m_description ); } + + // Data members + const_string m_description; +}; + +// ************************************************************************** // +// ************** decorator::depends_on ************** // +// ************************************************************************** // + +class BOOST_TEST_DECL depends_on : public decorator::for_test_unit { +public: + explicit depends_on( const_string dependency ) : m_dependency( dependency ) {} + +private: + // decorator::for_test_unit interface + virtual void do_apply( test_unit& tu ); + virtual for_test_unit* do_clone() const { return new depends_on( m_dependency ); } + + // Data members + const_string m_dependency; +}; + +} // namespace decorator + +using decorator::label; +using decorator::expected_failures; +using decorator::timeout; +using decorator::description; +using decorator::depends_on; + +} // unit_test + +} // namespace boost + +#include + +#endif // BOOST_TEST_DECORATORS_HPP_091911GER + diff --git a/include/boost/test/test_observer.hpp b/include/boost/test/tree/observer.hpp similarity index 97% rename from include/boost/test/test_observer.hpp rename to include/boost/test/tree/observer.hpp index 09761ca2..a45a568b 100644 --- a/include/boost/test/test_observer.hpp +++ b/include/boost/test/tree/observer.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2005-2010. +// (C) Copyright Gennadiy Rozental 2005-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/test/unit_test.hpp b/include/boost/test/unit_test.hpp index 5257cc60..8056ce9b 100644 --- a/include/boost/test/unit_test.hpp +++ b/include/boost/test/unit_test.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. +// (C) Copyright Gennadiy Rozental 2001-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/test/unit_test_log.hpp b/include/boost/test/unit_test_log.hpp index 97af55d1..87e18433 100644 --- a/include/boost/test/unit_test_log.hpp +++ b/include/boost/test/unit_test_log.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. +// (C) Copyright Gennadiy Rozental 2001-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -18,7 +18,7 @@ #define BOOST_TEST_UNIT_TEST_LOG_HPP_071894GER // Boost.Test -#include +#include #include #include diff --git a/include/boost/test/unit_test_log_formatter.hpp b/include/boost/test/unit_test_log_formatter.hpp index 1262eb58..915d30cf 100644 --- a/include/boost/test/unit_test_log_formatter.hpp +++ b/include/boost/test/unit_test_log_formatter.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2003-2010. +// (C) Copyright Gennadiy Rozental 2003-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/test/unit_test_monitor.hpp b/include/boost/test/unit_test_monitor.hpp index 4353be9d..cbeb08dc 100644 --- a/include/boost/test/unit_test_monitor.hpp +++ b/include/boost/test/unit_test_monitor.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. +// (C) Copyright Gennadiy Rozental 2001-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -20,7 +20,6 @@ #include #include #include -#include #include diff --git a/include/boost/test/unit_test_suite.hpp b/include/boost/test/unit_test_suite.hpp index 178a2d18..2fa14d54 100644 --- a/include/boost/test/unit_test_suite.hpp +++ b/include/boost/test/unit_test_suite.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. +// (C) Copyright Gennadiy Rozental 2001-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -26,7 +26,7 @@ // ************************************************************************** // #define BOOST_TEST_CASE( test_function ) \ -boost::unit_test::make_test_case( boost::unit_test::callback0<>(test_function), BOOST_TEST_STRINGIZE( test_function ) ) +boost::unit_test::make_test_case( boost::function(test_function), BOOST_TEST_STRINGIZE( test_function ) ) #define BOOST_CLASS_TEST_CASE( test_function, tc_instance ) \ boost::unit_test::make_test_case((test_function), BOOST_TEST_STRINGIZE( test_function ), tc_instance ) @@ -43,7 +43,9 @@ boost::unit_test::make_test_case((test_function), BOOST_TEST_STRINGIZE( test_fun #define BOOST_AUTO_TEST_SUITE( suite_name ) \ namespace suite_name { \ -BOOST_AUTO_TU_REGISTRAR( suite_name )( BOOST_STRINGIZE( suite_name ) ); \ +BOOST_AUTO_TU_REGISTRAR( suite_name )( \ + BOOST_STRINGIZE( suite_name ), \ + boost::unit_test::decorator::collector::instance() ); \ /**/ // ************************************************************************** // @@ -67,20 +69,10 @@ BOOST_AUTO_TU_REGISTRAR( BOOST_JOIN( end_suite, __LINE__ ) )( 1 ); \ // ************************************************************************** // // ************** BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES ************** // // ************************************************************************** // +// deprecated; use decorator instead #define BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( test_name, n ) \ -struct BOOST_AUTO_TC_UNIQUE_ID( test_name ); \ - \ -static struct BOOST_JOIN( test_name, _exp_fail_num_spec ) \ -: boost::unit_test::ut_detail:: \ - auto_tc_exp_fail \ -{ \ - BOOST_JOIN( test_name, _exp_fail_num_spec )() \ - : boost::unit_test::ut_detail:: \ - auto_tc_exp_fail( n ) \ - {} \ -} BOOST_JOIN( test_name, _exp_fail_num_spec_inst ); \ - \ +BOOST_TEST_DECORATOR( boost::unit_test::expected_failures( n ) ) /**/ // ************************************************************************** // @@ -101,8 +93,7 @@ struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \ BOOST_AUTO_TU_REGISTRAR( test_name )( \ boost::unit_test::make_test_case( \ &BOOST_AUTO_TC_INVOKER( test_name ), #test_name ), \ - boost::unit_test::ut_detail::auto_tc_exp_fail< \ - BOOST_AUTO_TC_UNIQUE_ID( test_name )>::instance()->value() ); \ + boost::unit_test::decorator::collector::instance() ); \ \ void test_name::test_method() \ /**/ @@ -136,7 +127,8 @@ struct BOOST_AUTO_TC_INVOKER( test_name ) { \ BOOST_AUTO_TU_REGISTRAR( test_name )( \ boost::unit_test::ut_detail::template_test_case_gen< \ BOOST_AUTO_TC_INVOKER( test_name ),TL >( \ - BOOST_STRINGIZE( test_name ) ) ); \ + BOOST_STRINGIZE( test_name ) ), \ + boost::unit_test::decorator::collector::instance() ); \ \ template \ void test_name::test_method() \ @@ -153,29 +145,29 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, BOOST_AUTO_TEST_CASE // ************** BOOST_TEST_CASE_TEMPLATE ************** // // ************************************************************************** // -#define BOOST_TEST_CASE_TEMPLATE( name, typelist ) \ - boost::unit_test::ut_detail::template_test_case_gen( \ - BOOST_TEST_STRINGIZE( name ) ) \ +#define BOOST_TEST_CASE_TEMPLATE( name, typelist ) \ + boost::unit_test::ut_detail::template_test_case_gen(\ + BOOST_TEST_STRINGIZE( name ) ) \ /**/ // ************************************************************************** // // ************** BOOST_TEST_CASE_TEMPLATE_FUNCTION ************** // // ************************************************************************** // -#define BOOST_TEST_CASE_TEMPLATE_FUNCTION( name, type_name ) \ -template \ -void BOOST_JOIN( name, _impl )( boost::type* ); \ - \ -struct name { \ - template \ - static void run( boost::type* frwrd = 0 ) \ - { \ - BOOST_JOIN( name, _impl )( frwrd ); \ - } \ -}; \ - \ -template \ -void BOOST_JOIN( name, _impl )( boost::type* ) \ +#define BOOST_TEST_CASE_TEMPLATE_FUNCTION( name, type_name ) \ +template \ +void BOOST_JOIN( name, _impl )( boost::type* ); \ + \ +struct name { \ + template \ + static void run( boost::type* frwrd = 0 ) \ + { \ + BOOST_JOIN( name, _impl )( frwrd ); \ + } \ +}; \ + \ +template \ +void BOOST_JOIN( name, _impl )( boost::type* ) \ /**/ // ************************************************************************** // @@ -186,6 +178,15 @@ void BOOST_JOIN( name, _impl )( boost::type* ) \ static boost::unit_test::ut_detail::global_fixture_impl BOOST_JOIN( gf_, F ) ; \ /**/ +// ************************************************************************** // +// ************** BOOST_TEST_DECORATOR ************** // +// ************************************************************************** // + +#define BOOST_TEST_DECORATOR( D ) \ +static boost::unit_test::decorator::collector \ +BOOST_JOIN(decorator_collector,__LINE__)( D ); \ +/**/ + // ************************************************************************** // // ************** BOOST_AUTO_TEST_CASE_FIXTURE ************** // // ************************************************************************** // diff --git a/include/boost/test/unit_test_suite_impl.hpp b/include/boost/test/unit_test_suite_impl.hpp index e910b27b..8be379de 100644 --- a/include/boost/test/unit_test_suite_impl.hpp +++ b/include/boost/test/unit_test_suite_impl.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2001-2010. +// (C) Copyright Gennadiy Rozental 2001-2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -18,11 +18,13 @@ // Boost.Test #include #include -#include -#include #include #include -#include + +#include + +#include +#include // Boost #include @@ -30,6 +32,7 @@ #include #include #include +#include // STL #include // for typeid @@ -45,6 +48,13 @@ namespace boost { namespace unit_test { +// ************************************************************************** // +// ************** test_unit_fixture ************** // +// ************************************************************************** // + +struct test_unit_fixture { +}; + // ************************************************************************** // // ************** test_unit ************** // // ************************************************************************** // @@ -78,9 +88,12 @@ public: // Public r/w properties readwrite_property p_name; // name for this test unit + readwrite_property p_description; // description for this test unit readwrite_property p_timeout; // timeout for the test unit execution readwrite_property p_expected_failures; // number of expected failures in this test unit - mutable readwrite_property p_enabled; // enabled status for this unit + mutable readwrite_property p_enabled; // enabled/disabled status for this unit + + readwrite_property p_decorators; // automatically assigned decorators; execution is delayed till framework::init function void increase_exp_fail( unsigned num ); @@ -90,6 +103,7 @@ protected: private: // Data members std::list m_labels; + decorator::for_test_unit_ptr m_decorators; }; // ************************************************************************** // @@ -113,18 +127,16 @@ public: enum { type = tut_case }; // Constructor - test_case( const_string tc_name, callback0<> const& test_func ); + test_case( const_string tc_name, boost::function const& test_func ); - // Access methods - callback0<> const& test_func() const { return m_test_func; } + // Public property + typedef BOOST_READONLY_PROPERTY(boost::function,(test_case)) test_func; + + test_func p_test_func; private: friend class framework_impl; ~test_case() {} - - // BOOST_MSVC <= 1200 have problems with callback as property - // Data members - callback0<> m_test_func; }; // ************************************************************************** // @@ -181,8 +193,9 @@ public: class BOOST_TEST_DECL test_tree_visitor { public: // test tree visitor interface - virtual void visit( test_case const& ) {} - virtual bool test_suite_start( test_suite const& ) { return true; } + virtual bool visit( test_unit const& ) { return true; } + virtual void visit( test_case const& tc ) { visit( (test_unit const&)tc ); } + virtual bool test_suite_start(test_suite const& ts) { return visit( (test_unit const&)ts ); } virtual void test_suite_finish( test_suite const& ) {} protected: @@ -222,18 +235,18 @@ public: BOOST_READONLY_PROPERTY( counter_t, (test_case_counter)) p_count; private: // test tree visitor interface - virtual void visit( test_case const& ); + virtual void visit( test_case const& tc ) { if( tc.p_enabled ) ++p_count.value; } virtual bool test_suite_start( test_suite const& ts ) { return ts.p_enabled; } }; // ************************************************************************** // -// ************** test_being_aborted ************** // +// ************** test_being_aborted ************** // // ************************************************************************** // struct BOOST_TEST_DECL test_being_aborted {}; // ************************************************************************** // -// ************** object generators ************** // +// ************** user_tc_method_invoker ************** // // ************************************************************************** // namespace ut_detail { @@ -257,8 +270,12 @@ struct user_tc_method_invoker { //____________________________________________________________________________// +// ************************************************************************** // +// ************** make_test_case ************** // +// ************************************************************************** // + inline test_case* -make_test_case( callback0<> const& test_func, const_string tc_name ) +make_test_case( boost::function const& test_func, const_string tc_name ) { return new test_case( ut_detail::normalize_test_case_name( tc_name ), test_func ); } @@ -286,9 +303,9 @@ namespace ut_detail { struct BOOST_TEST_DECL auto_test_unit_registrar { // Constructors - auto_test_unit_registrar( test_case* tc, counter_t exp_fail ); - explicit auto_test_unit_registrar( const_string ts_name ); - explicit auto_test_unit_registrar( test_unit_generator const& tc_gen ); + auto_test_unit_registrar( test_case* tc, decorator::collector* decorators, counter_t exp_fail = 0 ); + explicit auto_test_unit_registrar( const_string ts_name, decorator::collector* decorators ); + explicit auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector* decorators ); explicit auto_test_unit_registrar( int ); private: @@ -297,33 +314,6 @@ private: //____________________________________________________________________________// -template -struct auto_tc_exp_fail { - auto_tc_exp_fail() : m_value( 0 ) {} - - explicit auto_tc_exp_fail( unsigned v ) - : m_value( v ) - { - instance() = this; - } - - static auto_tc_exp_fail*& instance() - { - static auto_tc_exp_fail inst; - static auto_tc_exp_fail* inst_ptr = &inst; - - return inst_ptr; - } - - unsigned value() const { return m_value; } - -private: - // Data members - unsigned m_value; -}; - -//____________________________________________________________________________// - } // namespace ut_detail // ************************************************************************** // diff --git a/include/boost/test/utils/basic_cstring/basic_cstring.hpp b/include/boost/test/utils/basic_cstring/basic_cstring.hpp index 32f22657..65a08fff 100644 --- a/include/boost/test/utils/basic_cstring/basic_cstring.hpp +++ b/include/boost/test/utils/basic_cstring/basic_cstring.hpp @@ -720,6 +720,28 @@ assign_op( std::basic_string& target, basic_cstring src, int ) //____________________________________________________________________________// +template +inline std::basic_string& +operator+=( std::basic_string& target, basic_cstring const& str ) +{ + target.append( str.begin(), str.end() ); + return target; +} + +//____________________________________________________________________________// + +template +inline std::basic_string +operator+( std::basic_string const& lhs, basic_cstring const& rhs ) +{ + std::basic_string res( lhs ); + + res.append( rhs.begin(), rhs.end() ); + return res; +} + +//____________________________________________________________________________// + } // namespace unit_test } // namespace boost diff --git a/include/boost/test/utils/callback.hpp b/include/boost/test/utils/callback.hpp deleted file mode 100644 index dea7641a..00000000 --- a/include/boost/test/utils/callback.hpp +++ /dev/null @@ -1,310 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2010. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : -// *************************************************************************** - -#ifndef BOOST_TEST_CALLBACK_020505GER -#define BOOST_TEST_CALLBACK_020505GER - -// Boost -#include -#include -#include - -#include - -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) || BOOST_WORKAROUND(BOOST_INTEL, <= 700) -# define BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR -#endif - -//____________________________________________________________________________// - -namespace boost { - -namespace unit_test { - -namespace ut_detail { - -struct unused {}; - -template -struct invoker { - template - R invoke( Functor& f ) { return f(); } - template - R invoke( Functor& f, T1 t1 ) { return f( t1 ); } - template - R invoke( Functor& f, T1 t1, T2 t2 ) { return f( t1, t2 ); } - template - R invoke( Functor& f, T1 t1, T2 t2, T3 t3 ) { return f( t1, t2, t3 ); } -}; - -//____________________________________________________________________________// - -template<> -struct invoker { - template - unused invoke( Functor& f ) { f(); return unused(); } - template - unused invoke( Functor& f, T1 t1 ) { f( t1 ); return unused(); } - template - unused invoke( Functor& f, T1 t1, T2 t2 ) { f( t1, t2 ); return unused(); } - template - unused invoke( Functor& f, T1 t1, T2 t2, T3 t3 ) { f( t1, t2, t3 ); return unused(); } -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -// ************************************************************************** // -// ************** unit_test::callback0 ************** // -// ************************************************************************** // - -namespace ut_detail { - -template -struct callback0_impl { - virtual ~callback0_impl() {} - - virtual R invoke() = 0; -}; - -//____________________________________________________________________________// - -template -struct callback0_impl_t : callback0_impl { - // Constructor - explicit callback0_impl_t( Functor f ) : m_f( f ) {} - - virtual R invoke() { return invoker().invoke( m_f ); } - -private: - // Data members - Functor m_f; -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -template -class callback0 { -public: - // Constructors - callback0() {} -#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR - callback0( callback0 const& rhs ) : m_impl( rhs.m_impl ) {} -#endif - - template - callback0( Functor f ) - : m_impl( new ut_detail::callback0_impl_t( f ) ) {} - - void operator=( callback0 const& rhs ) { m_impl = rhs.m_impl; } - - template - void operator=( Functor f ) { m_impl.reset( new ut_detail::callback0_impl_t( f ) ); } - - R operator()() const { return m_impl->invoke(); } - - bool operator!() const { return !m_impl; } - -private: - // Data members - boost::shared_ptr > m_impl; -}; - -// ************************************************************************** // -// ************** unit_test::callback1 ************** // -// ************************************************************************** // - -namespace ut_detail { - -template -struct callback1_impl { - virtual ~callback1_impl() {} - - virtual R invoke( T1 t1 ) = 0; -}; - -//____________________________________________________________________________// - -template -struct callback1_impl_t : callback1_impl { - // Constructor - explicit callback1_impl_t( Functor f ) : m_f( f ) {} - - virtual R invoke( T1 t1 ) { return invoker().invoke( m_f, t1 ); } - -private: - // Data members - Functor m_f; -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -template -class callback1 { -public: - // Constructors - callback1() {} -#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR - callback1( callback1 const& rhs ) : m_impl( rhs.m_impl ) {} -#endif - - template - callback1( Functor f ) - : m_impl( new ut_detail::callback1_impl_t( f ) ) {} - - void operator=( callback1 const& rhs ) { m_impl = rhs.m_impl; } - - template - void operator=( Functor f ) { m_impl.reset( new ut_detail::callback1_impl_t( f ) ); } - - R operator()( T1 t1 ) const { return m_impl->invoke( t1 ); } - - bool operator!() const { return !m_impl; } - -private: - // Data members - boost::shared_ptr > m_impl; -}; - -// ************************************************************************** // -// ************** unit_test::callback2 ************** // -// ************************************************************************** // - -namespace ut_detail { - -template -struct callback2_impl { - virtual ~callback2_impl() {} - - virtual R invoke( T1 t1, T2 t2 ) = 0; -}; - -//____________________________________________________________________________// - -template -struct callback2_impl_t : callback2_impl { - // Constructor - explicit callback2_impl_t( Functor f ) : m_f( f ) {} - - virtual R invoke( T1 t1, T2 t2 ) { return invoker().template invoke( m_f, t1, t2 ); } - -private: - // Data members - Functor m_f; -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -template -class callback2 { -public: - // Constructors - callback2() {} -#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR - callback2( callback2 const& rhs ) : m_impl( rhs.m_impl ) {} -#endif - - template - callback2( Functor f ) : m_impl( new ut_detail::callback2_impl_t( f ) ) {} - - void operator=( callback2 const& rhs ) { m_impl = rhs.m_impl; } - - template - void operator=( Functor f ) { m_impl.reset( new ut_detail::callback2_impl_t( f ) ); } - - R operator()( T1 t1, T2 t2 ) const { return m_impl->invoke( t1, t2 ); } - - bool operator!() const { return !m_impl; } - -private: - // Data members - boost::shared_ptr > m_impl; -}; - -// ************************************************************************** // -// ************** unit_test::callback3 ************** // -// ************************************************************************** // - -namespace ut_detail { - -template -struct callback3_impl { - virtual ~callback3_impl() {} - - virtual R invoke( T1 t1, T2 t2, T3 t3 ) = 0; -}; - -//____________________________________________________________________________// - -template -struct callback3_impl_t : callback3_impl { - // Constructor - explicit callback3_impl_t( Functor f ) : m_f( f ) {} - - virtual R invoke( T1 t1, T2 t2, T3 t3 ) { return invoker().invoke( m_f, t1, t2, t3 ); } - -private: - // Data members - Functor m_f; -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -template -class callback3 { -public: - // Constructors - callback3() {} -#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR - callback3( callback3 const& rhs ) : m_impl( rhs.m_impl ) {} -#endif - - template - callback3( Functor f ) - : m_impl( new ut_detail::callback3_impl_t( f ) ) {} - - void operator=( callback3 const& rhs ) { m_impl = rhs.m_impl; } - - template - void operator=( Functor f ) { m_impl.reset( new ut_detail::callback3_impl_t( f ) ); } - - R operator()( T1 t1, T2 t2, T3 t3 ) const { return m_impl->invoke( t1, t2, t3 ); } - - bool operator!() const { return !m_impl; } - -private: - // Data members - boost::shared_ptr > m_impl; -}; - -} // namespace unit_test - -} // namespace boost - -#undef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_CALLBACK_020505GER diff --git a/include/boost/test/utils/lazy_ostream.hpp b/include/boost/test/utils/lazy_ostream.hpp index 646c0714..d00fc1d7 100644 --- a/include/boost/test/utils/lazy_ostream.hpp +++ b/include/boost/test/utils/lazy_ostream.hpp @@ -79,10 +79,10 @@ private: //____________________________________________________________________________// template -inline lazy_ostream_impl +inline lazy_ostream_impl operator<<( lazy_ostream const& prev, T const& v ) { - return lazy_ostream_impl( prev, v ); + return lazy_ostream_impl( prev, v ); } //____________________________________________________________________________// @@ -103,7 +103,9 @@ template inline lazy_ostream_impl,R& (BOOST_TEST_CALL_DECL *)(S&)> operator<<( lazy_ostream_impl const& prev, R& (BOOST_TEST_CALL_DECL *man)(S&) ) { - return lazy_ostream_impl,R& (BOOST_TEST_CALL_DECL *)(S&)>( prev, man ); + typedef R& (BOOST_TEST_CALL_DECL * ManipType)(S&); + + return lazy_ostream_impl,ManipType>( prev, man ); } //____________________________________________________________________________// diff --git a/include/boost/test/utils/runtime/cla/argument_factory.hpp b/include/boost/test/utils/runtime/cla/argument_factory.hpp index c6dea965..51fb32f9 100644 --- a/include/boost/test/utils/runtime/cla/argument_factory.hpp +++ b/include/boost/test/utils/runtime/cla/argument_factory.hpp @@ -33,11 +33,9 @@ #include -// Boost.Test -#include - // Boost #include +#include namespace boost { @@ -112,9 +110,9 @@ struct typed_argument_factory : public argument_factory { // !! private? // Data members - unit_test::callback2 m_value_handler; - unit_test::callback2&> m_value_generator; - unit_test::callback2&> m_value_interpreter; + boost::function m_value_handler; + boost::function&)> m_value_generator; + boost::function&)> m_value_interpreter; }; //____________________________________________________________________________// diff --git a/include/boost/test/utils/runtime/env/environment.hpp b/include/boost/test/utils/runtime/env/environment.hpp index 792a7262..67934a48 100644 --- a/include/boost/test/utils/runtime/env/environment.hpp +++ b/include/boost/test/utils/runtime/env/environment.hpp @@ -29,9 +29,6 @@ #include #include -// Boost.Test -#include - // Boost #include