diff options
Diffstat (limited to 'boost/test')
47 files changed, 256 insertions, 214 deletions
diff --git a/boost/test/data/monomorphic/delayed.hpp b/boost/test/data/monomorphic/delayed.hpp index eecf117a8d..43ab15e7e4 100644 --- a/boost/test/data/monomorphic/delayed.hpp +++ b/boost/test/data/monomorphic/delayed.hpp @@ -20,6 +20,7 @@ #include <boost/core/ref.hpp> #include <algorithm> +#include <memory> #include <boost/test/detail/suppress_warnings.hpp> diff --git a/boost/test/data/monomorphic/grid.hpp b/boost/test/data/monomorphic/grid.hpp index ee138df15d..d83531bf23 100644 --- a/boost/test/data/monomorphic/grid.hpp +++ b/boost/test/data/monomorphic/grid.hpp @@ -22,6 +22,7 @@ #include <boost/test/data/monomorphic/fwd.hpp> #include <boost/test/data/monomorphic/sample_merge.hpp> +#include <boost/core/enable_if.hpp> #include <boost/mpl/identity.hpp> #include <boost/test/detail/suppress_warnings.hpp> diff --git a/boost/test/data/monomorphic/initializer_list.hpp b/boost/test/data/monomorphic/initializer_list.hpp index 3f4a4df045..0a8a88ab0b 100644 --- a/boost/test/data/monomorphic/initializer_list.hpp +++ b/boost/test/data/monomorphic/initializer_list.hpp @@ -17,6 +17,9 @@ #include <boost/test/data/monomorphic/fwd.hpp> #include <boost/core/ignore_unused.hpp> + +#include <vector> + #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// diff --git a/boost/test/data/monomorphic/join.hpp b/boost/test/data/monomorphic/join.hpp index f817994dd3..4e6d52a208 100644 --- a/boost/test/data/monomorphic/join.hpp +++ b/boost/test/data/monomorphic/join.hpp @@ -16,6 +16,9 @@ #include <boost/test/data/config.hpp> #include <boost/test/data/monomorphic/fwd.hpp> +#include <boost/core/enable_if.hpp> +#include <boost/mpl/identity.hpp> + #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// @@ -40,22 +43,33 @@ class join { typedef typename dataset1_decay::iterator dataset1_iter; typedef typename dataset2_decay::iterator dataset2_iter; + + using iter1_ret = decltype(*std::declval<DataSet1>().begin()); + using iter2_ret = decltype(*std::declval<DataSet2>().begin()); + public: - typedef typename dataset1_decay::sample sample; enum { arity = dataset1_decay::arity }; + + using sample_t = typename std::conditional< + std::is_reference<iter1_ret>::value && std::is_reference<iter2_ret>::value && std::is_same<iter1_ret, iter2_ret>::value, + iter1_ret, + typename std::remove_reference<iter1_ret>::type + >::type + ; struct iterator { // Constructor - explicit iterator( dataset1_iter it1, dataset2_iter it2, data::size_t first_size ) + explicit iterator( dataset1_iter&& it1, dataset2_iter&& it2, data::size_t first_size ) : m_it1( std::move( it1 ) ) , m_it2( std::move( it2 ) ) , m_first_size( first_size ) {} // forward iterator interface - sample const& operator*() const { return m_first_size > 0 ? *m_it1 : *m_it2; } - void operator++() { if( m_first_size > 0 ) { --m_first_size; ++m_it1; } else ++m_it2; } + // The returned sample should be by value, as the operator* may return a temporary object + sample_t operator*() const { return m_first_size > 0 ? *m_it1 : *m_it2; } + void operator++() { if( m_first_size > 0 ) { --m_first_size; ++m_it1; } else ++m_it2; } private: // Data members diff --git a/boost/test/data/monomorphic/zip.hpp b/boost/test/data/monomorphic/zip.hpp index 04e390e9ac..9fda7cb521 100644 --- a/boost/test/data/monomorphic/zip.hpp +++ b/boost/test/data/monomorphic/zip.hpp @@ -20,6 +20,9 @@ #include <boost/test/data/monomorphic/fwd.hpp> #include <boost/test/data/monomorphic/sample_merge.hpp> +#include <boost/core/enable_if.hpp> +#include <boost/mpl/identity.hpp> + #include <boost/test/detail/suppress_warnings.hpp> @@ -70,8 +73,6 @@ public: dataset2_iter m_iter2; }; - typedef typename iterator::iterator_sample sample; - //! Constructor //! //! The datasets are moved and not copied. diff --git a/boost/test/data/test_case.hpp b/boost/test/data/test_case.hpp index eecbee9065..2b3e7e4c61 100644 --- a/boost/test/data/test_case.hpp +++ b/boost/test/data/test_case.hpp @@ -147,12 +147,12 @@ public: : m_dataset( ds ) , m_generated( false ) , m_tc_name( ut_detail::normalize_test_case_name( tc_name ) ) - , m_tc_file( tc_file ) + , m_tc_file( tc_file ) , m_tc_line( tc_line ) , m_tc_index( 0 ) {} #endif - + public: virtual test_unit* next() const { @@ -273,7 +273,7 @@ BOOST_AUTO_TU_REGISTRAR( BOOST_PP_CAT(test_name, case) )( \ BOOST_STRINGIZE( test_name ), \ __FILE__, __LINE__, \ boost::unit_test::data::ds_detail::seed{} ->* dataset ), \ - boost::unit_test::decorator::collector::instance() ); \ + boost::unit_test::decorator::collector_t::instance() ); \ \ BOOST_AUTO_TEST_SUITE_END() \ \ diff --git a/boost/test/detail/enable_warnings.hpp b/boost/test/detail/enable_warnings.hpp index 45afb31944..d61c7dc592 100644 --- a/boost/test/detail/enable_warnings.hpp +++ b/boost/test/detail/enable_warnings.hpp @@ -26,7 +26,7 @@ # pragma warning(pop) #endif -#if BOOST_CLANG +#if defined(BOOST_CLANG) && (BOOST_CLANG == 1) #pragma clang diagnostic pop #endif diff --git a/boost/test/detail/global_typedef.hpp b/boost/test/detail/global_typedef.hpp index aeede00e9c..ae932a4514 100644 --- a/boost/test/detail/global_typedef.hpp +++ b/boost/test/detail/global_typedef.hpp @@ -101,6 +101,40 @@ T static_constant<T>::value; //____________________________________________________________________________// +// helper defines for singletons. +// BOOST_TEST_SINGLETON_CONS should appear in the class body, +// BOOST_TEST_SINGLETON_CONS_IMPL should be in only one translation unit. The +// global instance should be declared by BOOST_TEST_SINGLETON_INST. + +#define BOOST_TEST_SINGLETON_CONS( type ) \ +public: \ + static type& instance(); \ +private: \ + BOOST_DELETED_FUNCTION(type(type const&)) \ + BOOST_DELETED_FUNCTION(type& operator=(type const&)) \ + BOOST_DEFAULTED_FUNCTION(type(), {}) \ + BOOST_DEFAULTED_FUNCTION(~type(), {}) \ +/**/ + +#define BOOST_TEST_SINGLETON_CONS_IMPL( type ) \ + type& type::instance() { \ + static type the_inst; return the_inst; \ + } \ +/**/ + +//____________________________________________________________________________// + +#if defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4 +#define BOOST_TEST_SINGLETON_INST( inst ) \ +static BOOST_JOIN( inst, _t)& inst = BOOST_JOIN (inst, _t)::instance(); + +#else + +#define BOOST_TEST_SINGLETON_INST( inst ) \ +namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); } + +#endif + } // namespace unit_test } // namespace boost diff --git a/boost/test/detail/suppress_warnings.hpp b/boost/test/detail/suppress_warnings.hpp index 4badf20758..4f8de3dd87 100644 --- a/boost/test/detail/suppress_warnings.hpp +++ b/boost/test/detail/suppress_warnings.hpp @@ -26,13 +26,15 @@ # pragma warning(disable: 4511) // 'class' : copy constructor could not be generated #endif -#if BOOST_CLANG +#if defined(BOOST_CLANG) && (BOOST_CLANG == 1) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wvariadic-macros" +# pragma clang diagnostic ignored "-Wmissing-declarations" #endif #if defined(BOOST_GCC) && (BOOST_GCC >= 4 * 10000 + 6 * 100) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wvariadic-macros" +# pragma GCC diagnostic ignored "-Wmissing-declarations" #endif diff --git a/boost/test/detail/throw_exception.hpp b/boost/test/detail/throw_exception.hpp index 3f2f4687d3..19b50ba49c 100644 --- a/boost/test/detail/throw_exception.hpp +++ b/boost/test/detail/throw_exception.hpp @@ -33,7 +33,7 @@ namespace ut_detail { template<typename E> BOOST_NORETURN inline void -throw_exception(E const& e) { abort(); } +throw_exception(E const& /*e*/) { abort(); } #define BOOST_TEST_I_TRY #define BOOST_TEST_I_CATCH( T, var ) for(T const& var = *(T*)0; false;) diff --git a/boost/test/execution_monitor.hpp b/boost/test/execution_monitor.hpp index eb3b21c6dc..bda732b980 100644 --- a/boost/test/execution_monitor.hpp +++ b/boost/test/execution_monitor.hpp @@ -237,7 +237,7 @@ protected: /// this class never allocates any memory and assumes that strings it refers to are either some constants or live in a some kind of persistent (preallocated) memory. // ************************************************************************** // -class BOOST_TEST_DECL execution_exception { +class BOOST_SYMBOL_VISIBLE execution_exception { typedef boost::unit_test::const_string const_string; public: /// These values are sometimes used as program return codes. diff --git a/boost/test/framework.hpp b/boost/test/framework.hpp index 099c02969b..2f446791aa 100644 --- a/boost/test/framework.hpp +++ b/boost/test/framework.hpp @@ -18,8 +18,6 @@ #include <boost/test/detail/fwd_decl.hpp> #include <boost/test/detail/throw_exception.hpp> -#include <boost/test/utils/trivial_singleton.hpp> - #include <boost/test/detail/suppress_warnings.hpp> // STL diff --git a/boost/test/impl/compiler_log_formatter.ipp b/boost/test/impl/compiler_log_formatter.ipp index aa0a0e229f..cd7de1fe76 100644 --- a/boost/test/impl/compiler_log_formatter.ipp +++ b/boost/test/impl/compiler_log_formatter.ipp @@ -182,30 +182,25 @@ compiler_log_formatter::log_entry_start( std::ostream& output, log_entry_data co switch( let ) { case BOOST_UTL_ET_INFO: print_prefix( output, entry_data.m_file_name, entry_data.m_line_num ); - if( m_color_output ) - output << setcolor( term_attr::BRIGHT, term_color::GREEN ); + output << setcolor( m_color_output, term_attr::BRIGHT, term_color::GREEN ); output << "info: "; break; case BOOST_UTL_ET_MESSAGE: - if( m_color_output ) - output << setcolor( term_attr::BRIGHT, term_color::CYAN ); + output << setcolor( m_color_output, term_attr::BRIGHT, term_color::CYAN ); break; case BOOST_UTL_ET_WARNING: print_prefix( output, entry_data.m_file_name, entry_data.m_line_num ); - if( m_color_output ) - output << setcolor( term_attr::BRIGHT, term_color::YELLOW ); + output << setcolor( m_color_output, term_attr::BRIGHT, term_color::YELLOW ); output << "warning: in \"" << test_phase_identifier() << "\": "; break; case BOOST_UTL_ET_ERROR: print_prefix( output, entry_data.m_file_name, entry_data.m_line_num ); - if( m_color_output ) - output << setcolor( term_attr::BRIGHT, term_color::RED ); + output << setcolor( m_color_output, term_attr::BRIGHT, term_color::RED ); output << "error: in \"" << test_phase_identifier() << "\": "; break; case BOOST_UTL_ET_FATAL_ERROR: print_prefix( output, entry_data.m_file_name, entry_data.m_line_num ); - if( m_color_output ) - output << setcolor( term_attr::UNDERLINE, term_color::RED ); + output << setcolor( m_color_output, term_attr::UNDERLINE, term_color::RED ); output << "fatal error: in \"" << test_phase_identifier() << "\": "; break; } @@ -233,7 +228,7 @@ void compiler_log_formatter::log_entry_finish( std::ostream& output ) { if( m_color_output ) - output << utils::setcolor(); + output << utils::setcolor(m_color_output); output << std::endl; } diff --git a/boost/test/impl/decorator.ipp b/boost/test/impl/decorator.ipp index 0cc562ee2f..e4bf11ee26 100644 --- a/boost/test/impl/decorator.ipp +++ b/boost/test/impl/decorator.ipp @@ -35,11 +35,15 @@ namespace unit_test { namespace decorator { // ************************************************************************** // -// ************** decorator::collector ************** // +// ************** decorator::collector_t ************** // // ************************************************************************** // -collector& -collector::operator*( base const& d ) +// singleton pattern +BOOST_TEST_SINGLETON_CONS_IMPL(collector_t) + + +collector_t& +collector_t::operator*( base const& d ) { m_tu_decorators.push_back( d.clone() ); @@ -49,7 +53,7 @@ collector::operator*( base const& d ) //____________________________________________________________________________// void -collector::store_in( test_unit& tu ) +collector_t::store_in( test_unit& tu ) { tu.p_decorators.value.insert( tu.p_decorators.value.end(), m_tu_decorators.begin(), m_tu_decorators.end() ); } @@ -57,7 +61,7 @@ collector::store_in( test_unit& tu ) //____________________________________________________________________________// void -collector::reset() +collector_t::reset() { m_tu_decorators.clear(); } @@ -65,7 +69,7 @@ collector::reset() //____________________________________________________________________________// std::vector<base_ptr> -collector::get_lazy_decorators() const +collector_t::get_lazy_decorators() const { return m_tu_decorators; } @@ -76,10 +80,10 @@ collector::get_lazy_decorators() const // ************** decorator::base ************** // // ************************************************************************** // -collector& +collector_t& base::operator*() const { - return collector::instance() * *this; + return collector_t::instance() * *this; } // ************************************************************************** // diff --git a/boost/test/impl/execution_monitor.ipp b/boost/test/impl/execution_monitor.ipp index 035bb958c1..9b7c5965b4 100644 --- a/boost/test/impl/execution_monitor.ipp +++ b/boost/test/impl/execution_monitor.ipp @@ -35,6 +35,7 @@ #ifndef BOOST_NO_EXCEPTIONS #include <boost/exception/get_error_info.hpp> // for get_error_info #include <boost/exception/current_exception_cast.hpp> // for current_exception_cast +#include <boost/exception/diagnostic_information.hpp> #endif // STL @@ -1227,6 +1228,16 @@ execution_monitor::execute( boost::function<int ()> const& F ) { detail::report_error( execution_exception::cpp_exception_error, "std::string: %s", ex.c_str() ); } + // boost::exception (before std::exception, with extended diagnostic) + catch( boost::exception const& ex ) + { detail::report_error( execution_exception::cpp_exception_error, + &ex, +#if defined(BOOST_NO_TYPEID) || defined(BOOST_NO_RTTI) + "unknown boost::exception" ); } +#else + boost::diagnostic_information(ex).c_str() ); } +#endif + // std:: exceptions #if defined(BOOST_NO_TYPEID) || defined(BOOST_NO_RTTI) #define CATCH_AND_REPORT_STD_EXCEPTION( ex_name ) \ @@ -1267,15 +1278,6 @@ execution_monitor::execute( boost::function<int ()> const& F ) CATCH_AND_REPORT_STD_EXCEPTION( std::exception ) #undef CATCH_AND_REPORT_STD_EXCEPTION - catch( boost::exception const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - &ex, -#if defined(BOOST_NO_TYPEID) || defined(BOOST_NO_RTTI) - "unknown boost::exception" ); } -#else - typeid(ex).name() ); } -#endif - // system errors catch( system_error const& ex ) { detail::report_error( execution_exception::cpp_exception_error, diff --git a/boost/test/impl/framework.ipp b/boost/test/impl/framework.ipp index ddb0144d27..60ba4accfe 100644 --- a/boost/test/impl/framework.ipp +++ b/boost/test/impl/framework.ipp @@ -1178,6 +1178,7 @@ finalize_setup_phase( test_unit_id master_tu_id ) master_tu_id = master_test_suite().p_id; // 10. Apply all decorators to the auto test units + // 10. checks for consistency (duplicate names, etc) class apply_decorators : public test_tree_visitor { private: // test_tree_visitor interface @@ -1185,6 +1186,7 @@ finalize_setup_phase( test_unit_id master_tu_id ) virtual bool test_suite_start( test_suite const& ts) { const_cast<test_suite&>(ts).generate(); + const_cast<test_suite&>(ts).check_for_duplicate_test_cases(); return test_tree_visitor::test_suite_start(ts); } diff --git a/boost/test/impl/progress_monitor.ipp b/boost/test/impl/progress_monitor.ipp index 34149745cf..998aa26b28 100644 --- a/boost/test/impl/progress_monitor.ipp +++ b/boost/test/impl/progress_monitor.ipp @@ -52,7 +52,7 @@ struct progress_display { << "\n|----|----|----|----|----|----|----|----|----|----|" << std::endl; - if( !m_expected_count ) + if( !m_expected_count ) m_expected_count = 1; // prevent divide by zero } @@ -63,7 +63,7 @@ struct progress_display { // use of floating point ensures that both large and small counts // work correctly. static_cast<>() is also used several places - // to suppress spurious compiler warnings. + // to suppress spurious compiler warnings. unsigned int tics_needed = static_cast<unsigned int>( (static_cast<double>(m_count)/m_expected_count)*50.0 ); @@ -121,6 +121,10 @@ progress_monitor_impl& s_pm_impl() { static progress_monitor_impl the_inst; retu //____________________________________________________________________________// +BOOST_TEST_SINGLETON_CONS_IMPL(progress_monitor_t) + +//____________________________________________________________________________// + void progress_monitor_t::test_start( counter_t test_cases_amount ) { diff --git a/boost/test/impl/results_collector.ipp b/boost/test/impl/results_collector.ipp index ea5050937b..cfc34cf793 100644 --- a/boost/test/impl/results_collector.ipp +++ b/boost/test/impl/results_collector.ipp @@ -139,6 +139,10 @@ results_collector_impl& s_rc_impl() { static results_collector_impl the_inst; re //____________________________________________________________________________// +BOOST_TEST_SINGLETON_CONS_IMPL( results_collector_t ) + +//____________________________________________________________________________// + void results_collector_t::test_start( counter_t ) { diff --git a/boost/test/impl/test_framework_init_observer.ipp b/boost/test/impl/test_framework_init_observer.ipp index 89f854aaed..a44382eed5 100644 --- a/boost/test/impl/test_framework_init_observer.ipp +++ b/boost/test/impl/test_framework_init_observer.ipp @@ -45,6 +45,14 @@ test_init_observer_check& s_tioc_impl() { static test_init_observer_check the_in } // local namespace + +//____________________________________________________________________________// + +// singleton pattern +BOOST_TEST_SINGLETON_CONS_IMPL(framework_init_observer_t) + +//____________________________________________________________________________// + void framework_init_observer_t::clear() { diff --git a/boost/test/impl/test_tree.ipp b/boost/test/impl/test_tree.ipp index cb48be4a99..722b4815b2 100644 --- a/boost/test/impl/test_tree.ipp +++ b/boost/test/impl/test_tree.ipp @@ -36,6 +36,7 @@ // STL #include <algorithm> #include <vector> +#include <set> #include <boost/test/detail/suppress_warnings.hpp> @@ -241,14 +242,6 @@ test_suite::test_suite( const_string module_name ) void test_suite::add( test_unit* tu, counter_t expected_failures, unsigned timeout ) { - // check for clashing names #12597 - for( test_unit_id_list::const_iterator it(m_children.begin()), ite(m_children.end()); - it < ite; - ++it) { - BOOST_TEST_SETUP_ASSERT( tu->p_name != framework::get(*it, TUT_ANY).p_name, - "test unit with name '" + tu->p_name.value + std::string("' registered multiple times") ); - } - tu->p_timeout.value = timeout; m_children.push_back( tu->p_id ); @@ -274,7 +267,7 @@ test_suite::add( test_unit_generator const& gen, unsigned timeout ) //____________________________________________________________________________// void -test_suite::add( test_unit_generator const& gen, decorator::collector& decorators ) +test_suite::add( test_unit_generator const& gen, decorator::collector_t& decorators ) { test_unit* tu; while((tu = gen.next()) != 0) { @@ -284,14 +277,18 @@ test_suite::add( test_unit_generator const& gen, decorator::collector& decorator decorators.reset(); } +//____________________________________________________________________________// + void -test_suite::add( boost::shared_ptr<test_unit_generator> gen_ptr, decorator::collector& decorators ) +test_suite::add( boost::shared_ptr<test_unit_generator> gen_ptr, decorator::collector_t& decorators ) { std::pair<boost::shared_ptr<test_unit_generator>, std::vector<decorator::base_ptr> > tmp_p(gen_ptr, decorators.get_lazy_decorators() ); m_generators.push_back(tmp_p); decorators.reset(); } +//____________________________________________________________________________// + void test_suite::generate( ) { @@ -320,6 +317,27 @@ test_suite::generate( ) #endif } +//____________________________________________________________________________// + +void +test_suite::check_for_duplicate_test_cases() { + // check for clashing names #12597 + std::set<std::string> names; + for( test_unit_id_list::const_iterator it(m_children.begin()), ite(m_children.end()); + it < ite; + ++it) { + std::string name = framework::get(*it, TUT_ANY).p_name; + std::pair<std::set<std::string>::iterator, bool> ret = names.insert(name); + BOOST_TEST_SETUP_ASSERT(ret.second, + "test unit with name '" + + name + + std::string("' registered multiple times in the test suite '") + + this->p_name.value + + "'"); + } + + return; +} //____________________________________________________________________________// @@ -453,7 +471,7 @@ normalize_test_case_name( const_string name ) // ************** auto_test_unit_registrar ************** // // ************************************************************************** // -auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, decorator::collector& decorators, counter_t exp_fail ) +auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, decorator::collector_t& decorators, counter_t exp_fail ) { framework::current_auto_test_suite().add( tc, exp_fail ); @@ -463,7 +481,7 @@ auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, decorator::co //____________________________________________________________________________// -auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name, const_string ts_file, std::size_t ts_line, decorator::collector& decorators ) +auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name, const_string ts_file, std::size_t ts_line, decorator::collector_t& decorators ) { test_unit_id id = framework::current_auto_test_suite().get( ts_name ); @@ -486,14 +504,14 @@ auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name, const_ //____________________________________________________________________________// -auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector& decorators ) +auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector_t& decorators ) { framework::current_auto_test_suite().add( tc_gen, decorators ); } //____________________________________________________________________________// -auto_test_unit_registrar::auto_test_unit_registrar( boost::shared_ptr<test_unit_generator> tc_gen, decorator::collector& decorators ) +auto_test_unit_registrar::auto_test_unit_registrar( boost::shared_ptr<test_unit_generator> tc_gen, decorator::collector_t& decorators ) { framework::current_auto_test_suite().add( tc_gen, decorators ); } diff --git a/boost/test/impl/unit_test_log.ipp b/boost/test/impl/unit_test_log.ipp index 2a6c0f4bc6..40b54be223 100644 --- a/boost/test/impl/unit_test_log.ipp +++ b/boost/test/impl/unit_test_log.ipp @@ -159,6 +159,10 @@ unit_test_log_impl& s_log_impl() { static unit_test_log_impl the_inst; return th //____________________________________________________________________________// +BOOST_TEST_SINGLETON_CONS_IMPL( unit_test_log_t ) + +//____________________________________________________________________________// + void unit_test_log_t::test_start( counter_t test_cases_amount ) { diff --git a/boost/test/impl/unit_test_monitor.ipp b/boost/test/impl/unit_test_monitor.ipp index cfb41a239c..70e78513b6 100644 --- a/boost/test/impl/unit_test_monitor.ipp +++ b/boost/test/impl/unit_test_monitor.ipp @@ -29,6 +29,9 @@ namespace boost { namespace unit_test { +// singleton pattern +BOOST_TEST_SINGLETON_CONS_IMPL(unit_test_monitor_t) + // ************************************************************************** // // ************** unit_test_monitor ************** // // ************************************************************************** // diff --git a/boost/test/progress_monitor.hpp b/boost/test/progress_monitor.hpp index 2f661f5825..49c0b01497 100644 --- a/boost/test/progress_monitor.hpp +++ b/boost/test/progress_monitor.hpp @@ -14,7 +14,6 @@ // Boost.Test #include <boost/test/tree/observer.hpp> -#include <boost/test/utils/trivial_singleton.hpp> // STL #include <iosfwd> // for std::ostream& @@ -31,7 +30,7 @@ namespace unit_test { // ************************************************************************** // /// This class implements test observer interface and updates test progress as test units finish or get aborted -class BOOST_TEST_DECL progress_monitor_t : public test_observer, public singleton<progress_monitor_t> { +class BOOST_TEST_DECL progress_monitor_t : public test_observer { public: /// @name Test observer interface /// @{ @@ -49,7 +48,7 @@ public: void set_stream( std::ostream& ); /// @} -private: + /// Singleton pattern BOOST_TEST_SINGLETON_CONS( progress_monitor_t ) }; // progress_monitor_t diff --git a/boost/test/results_collector.hpp b/boost/test/results_collector.hpp index 75a0e551cd..8e8a6202ed 100644 --- a/boost/test/results_collector.hpp +++ b/boost/test/results_collector.hpp @@ -21,7 +21,6 @@ #include <boost/test/detail/global_typedef.hpp> #include <boost/test/detail/fwd_decl.hpp> -#include <boost/test/utils/trivial_singleton.hpp> #include <boost/test/utils/class_properties.hpp> #include <boost/test/detail/suppress_warnings.hpp> @@ -84,7 +83,7 @@ public: /// For test suites, this indicates if the test suite itself has been marked as /// skipped, and not if the test suite contains any skipped test. bool skipped() const; - + /// Returns true if the test unit was aborted (hard failure) bool aborted() const; @@ -115,7 +114,7 @@ public: /// of the test tree. /// /// @see boost::unit_test::test_observer -class BOOST_TEST_DECL results_collector_t : public test_observer, public singleton<results_collector_t> { +class BOOST_TEST_DECL results_collector_t : public test_observer { public: virtual void test_start( counter_t ); @@ -135,7 +134,7 @@ public: /// @param[in] tu_id id of a test unit test_results const& results( test_unit_id tu_id ) const; -private: + /// Singleton pattern BOOST_TEST_SINGLETON_CONS( results_collector_t ) }; diff --git a/boost/test/test_framework_init_observer.hpp b/boost/test/test_framework_init_observer.hpp index cdf5ef5edd..8bf0bb9947 100644 --- a/boost/test/test_framework_init_observer.hpp +++ b/boost/test/test_framework_init_observer.hpp @@ -18,8 +18,6 @@ #include <boost/test/detail/global_typedef.hpp> #include <boost/test/detail/fwd_decl.hpp> -#include <boost/test/utils/trivial_singleton.hpp> - #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// @@ -33,7 +31,7 @@ namespace unit_test { /// This class collects the state of the init/termination of the unit test framework. /// /// @see boost::unit_test::test_observer -class BOOST_TEST_DECL framework_init_observer_t : public test_observer, public singleton<framework_init_observer_t> { +class BOOST_TEST_DECL framework_init_observer_t : public test_observer { public: virtual void test_start( counter_t ); @@ -49,7 +47,7 @@ public: /// Indicates if a failure has been recorded so far bool has_failed( ) const; -private: + /// Singleton pattern BOOST_TEST_SINGLETON_CONS( framework_init_observer_t ) }; diff --git a/boost/test/tools/assertion.hpp b/boost/test/tools/assertion.hpp index cca2f52beb..2a7d96ebb1 100644 --- a/boost/test/tools/assertion.hpp +++ b/boost/test/tools/assertion.hpp @@ -277,7 +277,7 @@ public: } void report( std::ostream& ostr ) const { - ostr << tt_detail::print_helper( m_value ); + ostr << tt_detail::print_helper( value() ); } // Mutating operators @@ -309,8 +309,11 @@ public: private: template<typename U> - static void format_message( wrap_stringstream& ostr, U const& v ) { ostr << "[(bool)" << v << " is false]"; } - static void format_message( wrap_stringstream& /*ostr*/, bool /*v*/ ) {} + static void format_message( wrap_stringstream& ostr, U const& v ) + { + ostr << "['" << tt_detail::print_helper(v) << "' evaluates to false]"; + } + static void format_message( wrap_stringstream& /*ostr*/, bool /*v*/ ) {} static void format_message( wrap_stringstream& /*ostr*/, assertion_result const& /*v*/ ) {} // Data members diff --git a/boost/test/tools/collection_comparison_op.hpp b/boost/test/tools/collection_comparison_op.hpp index 864103fb4a..ff3b376131 100644 --- a/boost/test/tools/collection_comparison_op.hpp +++ b/boost/test/tools/collection_comparison_op.hpp @@ -20,6 +20,7 @@ // Boost #include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> #include <boost/utility/enable_if.hpp> #include <boost/type_traits/decay.hpp> diff --git a/boost/test/tools/detail/print_helper.hpp b/boost/test/tools/detail/print_helper.hpp index 2c6a3b5e80..232fad1509 100644 --- a/boost/test/tools/detail/print_helper.hpp +++ b/boost/test/tools/detail/print_helper.hpp @@ -28,6 +28,8 @@ #include <boost/type_traits/is_abstract.hpp> #include <boost/type_traits/has_left_shift.hpp> +#include <ios> +#include <iostream> #include <limits> #if !defined(BOOST_NO_CXX11_NULLPTR) diff --git a/boost/test/tools/floating_point_comparison.hpp b/boost/test/tools/floating_point_comparison.hpp index d704a41092..810840e345 100644 --- a/boost/test/tools/floating_point_comparison.hpp +++ b/boost/test/tools/floating_point_comparison.hpp @@ -197,9 +197,11 @@ fraction_tolerance( percent_tolerance_t<FPT> tolerance ) /*!@brief Predicate for comparing floating point numbers * * This predicate is used to compare floating point numbers. In addition the comparison produces maximum - * related differnce, which can be used to generate detailed error message + * related difference, which can be used to generate detailed error message * The methods for comparing floating points are detailed in the documentation. The method is chosen * by the @ref boost::math::fpc::strength given at construction. + * + * This predicate is not suitable for comparing to 0 or to infinity. */ template<typename FPT> class close_at_tolerance { diff --git a/boost/test/tools/fpc_op.hpp b/boost/test/tools/fpc_op.hpp index b879d218f2..c84820bdba 100644 --- a/boost/test/tools/fpc_op.hpp +++ b/boost/test/tools/fpc_op.hpp @@ -170,7 +170,11 @@ public: \ static assertion_result \ eval( Lhs const& lhs, Rhs const& rhs ) \ { \ - if( fpc_tolerance<FPT>() == FPT(0) ) \ + if( fpc_tolerance<FPT>() == FPT(0) \ + || (std::numeric_limits<Lhs>::has_infinity \ + && (lhs == std::numeric_limits<Lhs>::infinity())) \ + || (std::numeric_limits<Rhs>::has_infinity \ + && (rhs == std::numeric_limits<Rhs>::infinity()))) \ { \ return eval_direct( lhs, rhs ); \ } \ diff --git a/boost/test/tree/auto_registration.hpp b/boost/test/tree/auto_registration.hpp index 98bc2924fd..e9510be292 100644 --- a/boost/test/tree/auto_registration.hpp +++ b/boost/test/tree/auto_registration.hpp @@ -37,10 +37,10 @@ namespace ut_detail { struct BOOST_TEST_DECL auto_test_unit_registrar { // Constructors - auto_test_unit_registrar( test_case* tc, decorator::collector& decorators, counter_t exp_fail = 0 ); - explicit auto_test_unit_registrar( const_string ts_name, const_string ts_file, std::size_t ts_line, decorator::collector& decorators ); - explicit auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector& decorators ); - explicit auto_test_unit_registrar( boost::shared_ptr<test_unit_generator> tc_gen, decorator::collector& decorators ); + auto_test_unit_registrar( test_case* tc, decorator::collector_t& decorators, counter_t exp_fail = 0 ); + explicit auto_test_unit_registrar( const_string ts_name, const_string ts_file, std::size_t ts_line, decorator::collector_t& decorators ); + explicit auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector_t& decorators ); + explicit auto_test_unit_registrar( boost::shared_ptr<test_unit_generator> tc_gen, decorator::collector_t& decorators ); explicit auto_test_unit_registrar( int ); }; diff --git a/boost/test/tree/decorator.hpp b/boost/test/tree/decorator.hpp index f891a27765..6537152538 100644 --- a/boost/test/tree/decorator.hpp +++ b/boost/test/tree/decorator.hpp @@ -22,9 +22,7 @@ #include <boost/test/tree/fixture.hpp> #include <boost/test/tools/assertion_result.hpp> - #include <boost/test/utils/basic_cstring/basic_cstring.hpp> -#include <boost/test/utils/trivial_singleton.hpp> // Boost #include <boost/shared_ptr.hpp> @@ -46,37 +44,40 @@ class test_unit; namespace decorator { // ************************************************************************** // -// ************** decorator::collector ************** // +// ************** decorator::collector_t ************** // // ************************************************************************** // class base; typedef boost::shared_ptr<base> base_ptr; -class BOOST_TEST_DECL collector : public singleton<collector> { +class BOOST_TEST_DECL collector_t { + public: - collector& operator*( base const& d ); + collector_t& operator*( base const& d ); void store_in( test_unit& tu ); void reset(); - + std::vector<base_ptr> get_lazy_decorators() const; -private: - BOOST_TEST_SINGLETON_CONS( collector ) + // singleton pattern + BOOST_TEST_SINGLETON_CONS( collector_t ) + private: // Data members std::vector<base_ptr> m_tu_decorators; }; + // ************************************************************************** // -// ************** decorator::base ************** // +// ************** decorator::base ************** // // ************************************************************************** // class BOOST_TEST_DECL base { public: // composition interface - collector& operator*() const; + collector_t& operator*() const; // application interface virtual void apply( test_unit& tu ) = 0; diff --git a/boost/test/tree/test_case_template.hpp b/boost/test/tree/test_case_template.hpp index f588e12e9f..e862980220 100644 --- a/boost/test/tree/test_case_template.hpp +++ b/boost/test/tree/test_case_template.hpp @@ -17,6 +17,7 @@ #include <boost/test/detail/global_typedef.hpp> #include <boost/test/detail/fwd_decl.hpp> #include <boost/test/detail/workaround.hpp> +#include <boost/test/tree/test_unit.hpp> #include <boost/test/utils/class_properties.hpp> diff --git a/boost/test/tree/test_unit.hpp b/boost/test/tree/test_unit.hpp index 1441bdc7dd..48033af897 100644 --- a/boost/test/tree/test_unit.hpp +++ b/boost/test/tree/test_unit.hpp @@ -176,10 +176,10 @@ public: void add( test_unit_generator const& gen, unsigned timeout = 0 ); /// @overload - void add( test_unit_generator const& gen, decorator::collector& decorators ); + void add( test_unit_generator const& gen, decorator::collector_t& decorators ); /// @overload - void add( boost::shared_ptr<test_unit_generator> gen_ptr, decorator::collector& decorators ); + void add( boost::shared_ptr<test_unit_generator> gen_ptr, decorator::collector_t& decorators ); //! Removes a test from the test suite. void remove( test_unit_id id ); @@ -187,6 +187,10 @@ public: //! Generates all the delayed test_units from the generators void generate( ); + //! Check for duplicates name in test cases + //! + //! Raises a setup_error if there are duplicates + void check_for_duplicate_test_cases(); // access methods test_unit_id get( const_string tu_name ) const; diff --git a/boost/test/unit_test_log.hpp b/boost/test/unit_test_log.hpp index 6944ffa79a..d65a728747 100644 --- a/boost/test/unit_test_log.hpp +++ b/boost/test/unit_test_log.hpp @@ -22,7 +22,6 @@ #include <boost/test/detail/fwd_decl.hpp> #include <boost/test/utils/wrap_stringstream.hpp> -#include <boost/test/utils/trivial_singleton.hpp> #include <boost/test/utils/lazy_ostream.hpp> // Boost @@ -109,7 +108,7 @@ private: /// @see /// - boost::unit_test::test_observer /// - boost::unit_test::unit_test_log_formatter -class BOOST_TEST_DECL unit_test_log_t : public test_observer, public singleton<unit_test_log_t> { +class BOOST_TEST_DECL unit_test_log_t : public test_observer { public: // test_observer interface implementation virtual void test_start( counter_t test_cases_amount ); @@ -221,6 +220,7 @@ private: void log_entry_context( log_level l ); void clear_entry_context(); + // Singleton BOOST_TEST_SINGLETON_CONS( unit_test_log_t ) }; // unit_test_log_t diff --git a/boost/test/unit_test_monitor.hpp b/boost/test/unit_test_monitor.hpp index 4402b79e73..b056051caf 100644 --- a/boost/test/unit_test_monitor.hpp +++ b/boost/test/unit_test_monitor.hpp @@ -17,7 +17,6 @@ // Boost.Test #include <boost/test/execution_monitor.hpp> #include <boost/test/detail/fwd_decl.hpp> -#include <boost/test/utils/trivial_singleton.hpp> #include <boost/test/detail/suppress_warnings.hpp> @@ -30,7 +29,7 @@ namespace unit_test { // ************** unit_test_monitor ************** // // ************************************************************************** // -class BOOST_TEST_DECL unit_test_monitor_t : public singleton<unit_test_monitor_t>, public execution_monitor { +class BOOST_TEST_DECL unit_test_monitor_t :public execution_monitor { public: enum error_level { test_ok = 0, @@ -48,7 +47,7 @@ public: // monitor method error_level execute_and_translate( boost::function<void ()> const& func, unsigned timeout = 0 ); -private: + // singleton pattern BOOST_TEST_SINGLETON_CONS( unit_test_monitor_t ) }; diff --git a/boost/test/unit_test_suite.hpp b/boost/test/unit_test_suite.hpp index 13ff804b44..698362e588 100644 --- a/boost/test/unit_test_suite.hpp +++ b/boost/test/unit_test_suite.hpp @@ -32,10 +32,12 @@ // ************** Non-auto (explicit) test case interface ************** // // ************************************************************************** // -#define BOOST_TEST_CASE( test_function ) \ +#define BOOST_TEST_CASE_NAME( test_function, test_name ) \ boost::unit_test::make_test_case( boost::function<void ()>(test_function), \ - BOOST_TEST_STRINGIZE( test_function ), \ + test_name , \ __FILE__, __LINE__ ) +#define BOOST_TEST_CASE( test_function ) \ +BOOST_TEST_CASE_NAME(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 ), \ @@ -63,7 +65,7 @@ BOOST_AUTO_TU_REGISTRAR( suite_name )( \ #define BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name ) \ BOOST_AUTO_TEST_SUITE_WITH_DECOR( \ suite_name, \ - boost::unit_test::decorator::collector::instance() ) \ + boost::unit_test::decorator::collector_t::instance() ) \ /**/ #if BOOST_PP_VARIADICS @@ -167,7 +169,7 @@ void test_name::test_method() \ #define BOOST_FIXTURE_TEST_CASE_NO_DECOR( test_name, F ) \ BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, F, \ - boost::unit_test::decorator::collector::instance() ) \ + boost::unit_test::decorator::collector_t::instance() ) \ /**/ #if BOOST_PP_VARIADICS @@ -246,7 +248,7 @@ 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 ), __FILE__, __LINE__ ), \ - boost::unit_test::decorator::collector::instance() ); \ + boost::unit_test::decorator::collector_t::instance() ); \ \ template<typename type_name> \ void test_name<type_name>::test_method() \ @@ -319,7 +321,7 @@ static boost::unit_test::ut_detail::global_fixture_impl<F> BOOST_JOIN( gf_, F ) // ************************************************************************** // #define BOOST_TEST_DECORATOR( D ) \ -static boost::unit_test::decorator::collector const& \ +static boost::unit_test::decorator::collector_t const& \ BOOST_TEST_APPEND_UNIQUE_ID(decorator_collector) = D; \ /**/ @@ -343,7 +345,7 @@ typedef ::boost::unit_test::ut_detail::nil_t BOOST_AUTO_TEST_CASE_FIXTURE; // ************************************************************************** // // Facility for having a unique name based on __LINE__ and __COUNTER__ (later if available) -#if defined(__COUNTER__) +#if defined(__COUNTER__) #define BOOST_TEST_INTERNAL_HAS_COUNTER #endif diff --git a/boost/test/utils/is_forward_iterable.hpp b/boost/test/utils/is_forward_iterable.hpp index 1c9108054b..d6d8dd8a85 100644 --- a/boost/test/utils/is_forward_iterable.hpp +++ b/boost/test/utils/is_forward_iterable.hpp @@ -17,7 +17,7 @@ defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) // this feature works with VC2012 upd 5 while BOOST_NO_CXX11_TRAILING_RESULT_TYPES is defined - #if !defined(BOOST_MSVC) || BOOST_MSVC_FULL_VER < 170061030 /* VC2012 upd 5 */ + #if !defined(BOOST_MSVC) || BOOST_MSVC_FULL_VER < 170061232 /* VC2012 upd 5 */ #define BOOST_TEST_FWD_ITERABLE_CXX03 #endif #endif @@ -204,7 +204,7 @@ struct bt_iterator_traits< T, true >{ BOOST_STATIC_ASSERT((is_forward_iterable<T>::value)); #if defined(BOOST_TEST_FWD_ITERABLE_CXX03) || \ - (defined(BOOST_MSVC) && (BOOST_MSVC_FULL_VER <= 170061030)) + (defined(BOOST_MSVC) && (BOOST_MSVC_FULL_VER <= 170061232)) typedef typename T::const_iterator const_iterator; typedef typename std::iterator_traits<const_iterator>::value_type value_type; #else @@ -224,7 +224,7 @@ struct bt_iterator_traits< T, true >{ } #if defined(BOOST_TEST_FWD_ITERABLE_CXX03) || \ - (defined(BOOST_MSVC) && (BOOST_MSVC_FULL_VER <= 170061030)) + (defined(BOOST_MSVC) && (BOOST_MSVC_FULL_VER <= 170061232)) static std::size_t size(T const& container) { return container.size(); diff --git a/boost/test/utils/runtime/argument_factory.hpp b/boost/test/utils/runtime/argument_factory.hpp index f3448f8cc4..e281cf93f7 100644 --- a/boost/test/utils/runtime/argument_factory.hpp +++ b/boost/test/utils/runtime/argument_factory.hpp @@ -18,6 +18,7 @@ // Boost.Test Runtime parameters #include <boost/test/utils/runtime/errors.hpp> #include <boost/test/utils/runtime/argument.hpp> +#include <boost/test/utils/runtime/modifier.hpp> // Boost.Test #include <boost/test/utils/basic_cstring/io.hpp> diff --git a/boost/test/utils/runtime/cla/argv_traverser.hpp b/boost/test/utils/runtime/cla/argv_traverser.hpp index 10fb67bde4..d65c88e920 100644 --- a/boost/test/utils/runtime/cla/argv_traverser.hpp +++ b/boost/test/utils/runtime/cla/argv_traverser.hpp @@ -17,6 +17,7 @@ // Boost.Test Runtime parameters #include <boost/test/utils/runtime/fwd.hpp> +#include <cstring> #include <boost/test/detail/suppress_warnings.hpp> diff --git a/boost/test/utils/runtime/cla/parser.hpp b/boost/test/utils/runtime/cla/parser.hpp index de8943884b..bd3df7090c 100644 --- a/boost/test/utils/runtime/cla/parser.hpp +++ b/boost/test/utils/runtime/cla/parser.hpp @@ -314,7 +314,7 @@ public: << BOOST_VERSION % 100 ; ostr << " with "; #if defined(BOOST_TEST_INCLUDED) - ostr << "single header inclusion of"; + ostr << "header-only inclusion of"; #elif defined(BOOST_TEST_DYN_LINK) ostr << "dynamic linking to"; #else diff --git a/boost/test/utils/runtime/errors.hpp b/boost/test/utils/runtime/errors.hpp index 5b263d21c5..056a823e33 100644 --- a/boost/test/utils/runtime/errors.hpp +++ b/boost/test/utils/runtime/errors.hpp @@ -37,7 +37,7 @@ namespace runtime { // ************** runtime::param_error ************** // // ************************************************************************** // -class param_error : public std::exception { +class BOOST_SYMBOL_VISIBLE param_error : public std::exception { public: ~param_error() BOOST_NOEXCEPT_OR_NOTHROW {} @@ -55,7 +55,7 @@ protected: //____________________________________________________________________________// -class init_error : public param_error { +class BOOST_SYMBOL_VISIBLE init_error : public param_error { protected: explicit init_error( cstring param_name ) : param_error( param_name ) {} ~init_error() BOOST_NOEXCEPT_OR_NOTHROW {} @@ -70,7 +70,7 @@ protected: //____________________________________________________________________________// template<typename Derived, typename Base> -class specific_param_error : public Base { +class BOOST_SYMBOL_VISIBLE specific_param_error : public Base { protected: explicit specific_param_error( cstring param_name ) : Base( param_name ) {} ~specific_param_error() BOOST_NOEXCEPT_OR_NOTHROW {} @@ -155,7 +155,7 @@ SPECIFIC_EX_TYPE( missing_req_arg, input_error ); #undef SPECIFIC_EX_TYPE -class ambiguous_param : public specific_param_error<ambiguous_param, input_error> { +class BOOST_SYMBOL_VISIBLE ambiguous_param : public specific_param_error<ambiguous_param, input_error> { public: #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES explicit ambiguous_param( std::vector<cstring>&& amb_candidates ) diff --git a/boost/test/utils/runtime/modifier.hpp b/boost/test/utils/runtime/modifier.hpp index f4f5a42baa..78c8817e7c 100644 --- a/boost/test/utils/runtime/modifier.hpp +++ b/boost/test/utils/runtime/modifier.hpp @@ -20,6 +20,7 @@ // Boost.Test #include <boost/test/utils/named_params.hpp> +#include <boost/test/detail/global_typedef.hpp> #include <boost/test/detail/suppress_warnings.hpp> diff --git a/boost/test/utils/runtime/parameter.hpp b/boost/test/utils/runtime/parameter.hpp index 420b60264d..01e5457bfe 100644 --- a/boost/test/utils/runtime/parameter.hpp +++ b/boost/test/utils/runtime/parameter.hpp @@ -27,7 +27,7 @@ #include <boost/test/utils/setcolor.hpp> // Boost -#include <boost/function/function2.hpp> +#include <boost/function.hpp> #include <boost/algorithm/cxx11/all_of.hpp> // STL diff --git a/boost/test/utils/setcolor.hpp b/boost/test/utils/setcolor.hpp index 91b068ae6f..915c9962a3 100644 --- a/boost/test/utils/setcolor.hpp +++ b/boost/test/utils/setcolor.hpp @@ -77,9 +77,11 @@ struct term_color { enum _ { class setcolor { public: // Constructor - explicit setcolor( term_attr::_ attr = term_attr::NORMAL, + explicit setcolor( bool is_color_output = false, + term_attr::_ attr = term_attr::NORMAL, term_color::_ fg = term_color::ORIGINAL, term_color::_ bg = term_color::ORIGINAL ) + : m_is_color_output(is_color_output) { m_command_size = std::sprintf( m_control_command, "%c[%d;%d;%dm", 0x1B, attr, fg + 30, bg + 40 ); } @@ -87,7 +89,7 @@ public: friend std::ostream& operator<<( std::ostream& os, setcolor const& sc ) { - if (&os == &std::cout || &os == &std::cerr) { + if (sc.m_is_color_output && (&os == &std::cout || &os == &std::cerr)) { return os.write( sc.m_control_command, sc.m_command_size ); } return os; @@ -95,6 +97,7 @@ public: private: // Data members + bool m_is_color_output; char m_control_command[13]; int m_command_size; }; @@ -105,6 +108,9 @@ class setcolor { protected: void set_console_color(std::ostream& os, WORD *attributes = NULL) const { + if (!m_is_color_output) { + return; + } DWORD console_type; if (&os == &std::cout) { console_type = STD_OUTPUT_HANDLE; @@ -127,9 +133,7 @@ protected: CONSOLE_SCREEN_BUFFER_INFO consoleInfo; GetConsoleScreenBufferInfo(hConsole, &consoleInfo); - //if(!has_written_console_ext) { - saved_attributes = consoleInfo.wAttributes; - //} + saved_attributes = consoleInfo.wAttributes; WORD fg_attr = 0; switch(m_fg) @@ -201,20 +205,19 @@ protected: break; } - SetConsoleTextAttribute(hConsole, fg_attr | bg_attr | text_attr); - - //has_written_console_ext = true; + SetConsoleTextAttribute(hConsole, fg_attr | bg_attr | text_attr); return; } public: // Constructor explicit setcolor( + bool is_color_output = false, term_attr::_ attr = term_attr::NORMAL, term_color::_ fg = term_color::ORIGINAL, term_color::_ bg = term_color::ORIGINAL ) - : /*has_written_console_ext(false) - , */m_attr(attr) + : m_is_color_output(is_color_output) + , m_attr(attr) , m_fg(fg) , m_bg(bg) {} @@ -227,6 +230,7 @@ public: } private: + bool m_is_color_output; term_attr::_ m_attr; term_color::_ m_fg; term_color::_ m_bg; @@ -234,7 +238,6 @@ private: protected: // Data members mutable WORD saved_attributes; - //mutable bool has_written_console_ext; }; #endif @@ -246,24 +249,27 @@ protected: struct scope_setcolor { scope_setcolor() : m_os( 0 ) {} - explicit scope_setcolor( std::ostream& os, + explicit scope_setcolor( bool is_color_output, + std::ostream& os, term_attr::_ attr = term_attr::NORMAL, term_color::_ fg = term_color::ORIGINAL, term_color::_ bg = term_color::ORIGINAL ) : m_os( &os ) + , m_is_color_output( is_color_output ) { - os << setcolor( attr, fg, bg ); + os << setcolor( is_color_output, attr, fg, bg ); } ~scope_setcolor() { if( m_os ) - *m_os << setcolor(); + *m_os << setcolor( m_is_color_output ); } private: scope_setcolor(const scope_setcolor& r); scope_setcolor& operator=(const scope_setcolor& r); // Data members std::ostream* m_os; + bool m_is_color_output; }; #else @@ -271,13 +277,13 @@ private: struct scope_setcolor : setcolor { scope_setcolor() : m_os( 0 ) {} explicit scope_setcolor( + bool is_color_output, std::ostream& os, term_attr::_ attr = term_attr::NORMAL, term_color::_ fg = term_color::ORIGINAL, term_color::_ bg = term_color::ORIGINAL ) - : - setcolor(attr, fg, bg), - m_os( &os ) + : setcolor(is_color_output, attr, fg, bg) + , m_os( &os ) { os << *this; } @@ -298,12 +304,9 @@ private: #endif -#define BOOST_TEST_SCOPE_SETCOLOR( is_color_output, os, attr, color ) \ - utils::scope_setcolor const sc( \ - os, \ - is_color_output ? utils::attr : utils::term_attr::NORMAL, \ - is_color_output ? utils::color : utils::term_color::ORIGINAL);\ - ut_detail::ignore_unused_variable_warning( sc ) \ +#define BOOST_TEST_SCOPE_SETCOLOR( is_color_output, os, attr, color ) \ + utils::scope_setcolor const sc(is_color_output, os, utils::attr, utils::color); \ + ut_detail::ignore_unused_variable_warning( sc ) \ /**/ } // namespace utils diff --git a/boost/test/utils/trivial_singleton.hpp b/boost/test/utils/trivial_singleton.hpp deleted file mode 100644 index ac612b6393..0000000000 --- a/boost/test/utils/trivial_singleton.hpp +++ /dev/null @@ -1,79 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001. -// 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 : simple helpers for creating cusom output manipulators -// *************************************************************************** - -#ifndef BOOST_TEST_UTILS_TRIVIAL_SIGNLETON_HPP -#define BOOST_TEST_UTILS_TRIVIAL_SIGNLETON_HPP - -// Boost.Test -#include <boost/config.hpp> -#include <boost/detail/workaround.hpp> - -// Boost -#include <boost/test/detail/suppress_warnings.hpp> - -//____________________________________________________________________________// - -namespace boost { -namespace unit_test { - -// ************************************************************************** // -// ************** singleton ************** // -// ************************************************************************** // - -template<typename Derived> -class singleton { -public: - static Derived& instance() { static Derived the_inst; return the_inst; } - - BOOST_DELETED_FUNCTION(singleton(singleton const&)) - BOOST_DELETED_FUNCTION(singleton& operator=(singleton const&)) - -protected: - BOOST_DEFAULTED_FUNCTION(singleton(), {}) - BOOST_DEFAULTED_FUNCTION(~singleton(), {}) -}; - -//____________________________________________________________________________// - -#define BOOST_TEST_SINGLETON_CONS( type ) \ -friend class boost::unit_test::singleton<type>; \ -type() {} \ -/**/ - -#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) - -#define BOOST_TEST_SINGLETON_INST( inst ) \ -template class unit_test::singleton< BOOST_JOIN( inst, _t ) > ; \ -namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); } - -#elif defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4 -#define BOOST_TEST_SINGLETON_INST( inst ) \ -static BOOST_JOIN( inst, _t)& inst = BOOST_JOIN (inst, _t)::instance(); - -#else - -#define BOOST_TEST_SINGLETON_INST( inst ) \ -namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); } - -#endif - -//____________________________________________________________________________// - -} // namespace unit_test -} // namespace boost - - -#include <boost/test/detail/enable_warnings.hpp> - -#endif // BOOST_TEST_UTILS_TRIVIAL_SIGNLETON_HPP diff --git a/boost/test/utils/xml_printer.hpp b/boost/test/utils/xml_printer.hpp index ffaf8fcc05..7892f9c4ce 100644 --- a/boost/test/utils/xml_printer.hpp +++ b/boost/test/utils/xml_printer.hpp @@ -16,6 +16,7 @@ #define BOOST_TEST_UTILS_XML_PRINTER_HPP // Boost.Test +#include <boost/test/detail/global_typedef.hpp> #include <boost/test/utils/basic_cstring/basic_cstring.hpp> #include <boost/test/utils/custom_manip.hpp> #include <boost/test/utils/foreach.hpp> @@ -26,6 +27,7 @@ // STL #include <iostream> +#include <map> #include <boost/test/detail/suppress_warnings.hpp> |