From a675db517fdefbc4c773270eae9d272a96da9dcf Mon Sep 17 00:00:00 2001 From: Gennadiy Rozental Date: Sat, 4 Jul 2009 06:36:59 +0000 Subject: [PATCH] Trunk version of Boost.Test finally being released [SVN r54633] --- build/Jamfile.v2 | 42 +- example/Jamfile.v2 | 4 + example/external_main_example_1.cpp | 43 ++ example/external_main_example_2.cpp | 40 ++ example/external_main_example_3.cpp | 40 ++ example/test_case_template_example.cpp | 3 +- include/boost/test/detail/enable_warnings.hpp | 6 +- include/boost/test/detail/global_typedef.hpp | 20 +- .../boost/test/detail/suppress_warnings.hpp | 6 +- .../test/detail/unit_test_parameters.hpp | 2 +- include/boost/test/detail/workaround.hpp | 3 + .../boost/test/floating_point_comparison.hpp | 67 ++- include/boost/test/framework.hpp | 6 +- include/boost/test/impl/debug.ipp | 4 +- include/boost/test/impl/exception_safety.ipp | 8 +- include/boost/test/impl/execution_monitor.ipp | 138 ++++-- include/boost/test/impl/framework.ipp | 33 +- include/boost/test/impl/interaction_based.ipp | 3 +- .../boost/test/impl/logged_expectations.ipp | 2 +- include/boost/test/impl/results_collector.ipp | 6 +- include/boost/test/impl/results_reporter.ipp | 2 + include/boost/test/impl/test_tools.ipp | 20 +- include/boost/test/impl/unit_test_main.ipp | 14 +- .../boost/test/impl/unit_test_parameters.ipp | 441 +++++++++++------- include/boost/test/impl/unit_test_suite.ipp | 14 +- include/boost/test/mock_object.hpp | 2 +- include/boost/test/parameterized_test.hpp | 2 +- include/boost/test/predicate_result.hpp | 5 + include/boost/test/test_case_template.hpp | 140 +----- include/boost/test/test_tools.hpp | 28 +- include/boost/test/unit_test_log.hpp | 4 +- include/boost/test/unit_test_suite.hpp | 32 +- include/boost/test/unit_test_suite_impl.hpp | 80 ++++ .../utils/basic_cstring/basic_cstring.hpp | 18 +- include/boost/test/utils/class_properties.hpp | 4 - include/boost/test/utils/fixed_mapping.hpp | 2 +- include/boost/test/utils/foreach.hpp | 2 +- .../test/utils/iterator/token_iterator.hpp | 2 +- include/boost/test/utils/named_params.hpp | 59 ++- include/boost/test/utils/runtime/argument.hpp | 11 +- .../utils/runtime/cla/argument_factory.hpp | 12 +- .../utils/runtime/cla/basic_parameter.hpp | 13 +- .../test/utils/runtime/cla/char_parameter.hpp | 2 +- .../test/utils/runtime/cla/char_parameter.ipp | 4 +- .../cla/detail/argument_value_usage.hpp | 4 +- .../utils/runtime/cla/dual_name_parameter.hpp | 16 +- .../test/utils/runtime/cla/id_policy.hpp | 36 +- .../test/utils/runtime/cla/id_policy.ipp | 30 +- .../runtime/cla/iface/argument_factory.hpp | 2 +- .../utils/runtime/cla/iface/id_policy.hpp | 11 +- .../boost/test/utils/runtime/cla/modifier.hpp | 12 +- .../utils/runtime/cla/named_parameter.ipp | 51 +- .../test/utils/runtime/cla/parameter.hpp | 8 +- .../boost/test/utils/runtime/cla/parser.hpp | 2 +- .../boost/test/utils/runtime/cla/parser.ipp | 9 +- .../runtime/cla/positional_parameter.hpp | 2 +- .../utils/runtime/cla/typed_parameter.hpp | 6 +- include/boost/test/utils/runtime/config.hpp | 12 +- .../test/utils/runtime/env/environment.hpp | 4 + include/boost/test/utils/runtime/env/fwd.hpp | 4 + .../boost/test/utils/runtime/env/variable.hpp | 10 + .../runtime/file/config_file_iterator.cpp | 7 +- test/Jamfile.v2 | 33 +- test/basic_cstring_test.cpp | 1 + test/test_files/errors_handling_test.pattern | 12 +- test/test_files/errors_handling_test.pattern2 | 12 +- test/test_files/test_fp_comparisons.pattern | 30 -- test/test_files/test_tools_test.pattern | 112 ++--- test/test_fp_comparisons.cpp | 9 + test/test_tools_test.cpp | 5 + test/token_iterator_test.cpp | 2 +- .../src/console_test_runner.cpp | 2 +- 72 files changed, 1153 insertions(+), 680 deletions(-) create mode 100644 example/external_main_example_1.cpp create mode 100644 example/external_main_example_2.cpp create mode 100644 example/external_main_example_3.cpp delete mode 100644 test/test_files/test_fp_comparisons.pattern diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 44016cd0..3653cd59 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -9,11 +9,13 @@ project boost/test : requirements shared:BOOST_TEST_DYN_LINK=1 msvc:on borland:-w-8080 - # Disable Warning about boost::noncopyable not being exported - shared,msvc:-wd4275 + # Disable Warning about boost::noncopyable not being exported + shared,msvc:-wd4275 + msvc:-wd4671 + msvc:-wd4673 + all : usage-requirements BOOST_TEST_NO_AUTO_LINK=1 - shared:BOOST_TEST_DYN_LINK=1 # Disable Warning about boost::noncopyable not being exported shared,msvc:-wd4275 ; @@ -66,12 +68,33 @@ UTF_SOURCES = xml_report_formatter ; -lib boost_prg_exec_monitor : $(PRG_EXEC_MON_SOURCES).cpp ; +lib boost_prg_exec_monitor + : # sources + $(PRG_EXEC_MON_SOURCES).cpp + : # requirements + : # default build + : # usage-requirements + shared:BOOST_TEST_DYN_LINK=1 + ; -lib boost_test_exec_monitor : $(TEST_EXEC_MON_SOURCES).cpp : static ; +lib boost_test_exec_monitor + : # sources + $(TEST_EXEC_MON_SOURCES).cpp + : # requirements + static + : # default build + : # usage-requirements + shared:BOOST_TEST_DYN_LINK=1 + ; -lib boost_unit_test_framework : $(UTF_SOURCES).cpp ; - +lib boost_unit_test_framework + : # sources + $(UTF_SOURCES).cpp + : # requirements + : # default build + : # usage-requirements + shared:BOOST_TEST_DYN_LINK=1 + ; alias minimal : : : : msvc:on @@ -81,8 +104,7 @@ alias included : : : : msvc:on ; - boost-install boost_prg_exec_monitor boost_test_exec_monitor - boost_unit_test_framework ; - \ No newline at end of file + boost_unit_test_framework ; + \ No newline at end of file diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index fee059b2..de45b02a 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -59,4 +59,8 @@ test-suite boost_test_examples [ run named_param_example.cpp ] [ run const_string_test.cpp ] + + [ run-fail external_main_example_1.cpp unit_test_framework ] + [ run-fail external_main_example_2.cpp unit_test_framework ] + [ run-fail external_main_example_3.cpp ] ; diff --git a/example/external_main_example_1.cpp b/example/external_main_example_1.cpp new file mode 100644 index 00000000..8792ed59 --- /dev/null +++ b/example/external_main_example_1.cpp @@ -0,0 +1,43 @@ +#ifndef BOOST_TEST_DYN_LINK +#define BOOST_TEST_DYN_LINK +#endif +#include +#include +using namespace boost::unit_test; + +//____________________________________________________________________________// + +void free_test_function( int i, int j ) +{ + BOOST_CHECK_EQUAL( i, j ); +} + +//____________________________________________________________________________// + +bool +init_function() +{ + framework::master_test_suite(). + add( BOOST_TEST_CASE( boost::bind( &free_test_function, 1, 1 ) ) ); + framework::master_test_suite(). + add( BOOST_TEST_CASE( boost::bind( &free_test_function, 1, 2 ) ) ); + framework::master_test_suite(). + add( BOOST_TEST_CASE( boost::bind( &free_test_function, 2, 1 ) ) ); + + // do your own initialization here + // if it successful return true + + // But, you CAN'T use testing tools here + + return true; +} + +//____________________________________________________________________________// + +int +main( int argc, char* argv[] ) +{ + return ::boost::unit_test::unit_test_main( &init_function, argc, argv ); +} + +//____________________________________________________________________________// diff --git a/example/external_main_example_2.cpp b/example/external_main_example_2.cpp new file mode 100644 index 00000000..d3fd7f3e --- /dev/null +++ b/example/external_main_example_2.cpp @@ -0,0 +1,40 @@ +#ifndef BOOST_TEST_DYN_LINK +#define BOOST_TEST_DYN_LINK +#endif +#include +using namespace boost::unit_test; + +//____________________________________________________________________________// + +BOOST_AUTO_TEST_SUITE( test_suite_1 ) + +BOOST_AUTO_TEST_CASE( test_case_1 ) +{ + BOOST_MESSAGE( "Testing is in progress" ); + + BOOST_CHECK( false ); +} + +BOOST_AUTO_TEST_SUITE_END() + +//____________________________________________________________________________// + +bool +init_function() +{ + // do your own initialization here + // if it successful return true + + // But, you CAN'T use testing tools here + return true; +} + +//____________________________________________________________________________// + +int +main( int argc, char* argv[] ) +{ + return ::boost::unit_test::unit_test_main( &init_function, argc, argv ); +} + +//____________________________________________________________________________// diff --git a/example/external_main_example_3.cpp b/example/external_main_example_3.cpp new file mode 100644 index 00000000..65948787 --- /dev/null +++ b/example/external_main_example_3.cpp @@ -0,0 +1,40 @@ +#define BOOST_TEST_NO_MAIN +#define BOOST_TEST_ALTERNATIVE_INIT_API +#include +using namespace boost::unit_test; + +//____________________________________________________________________________// + +BOOST_AUTO_TEST_SUITE( test_suite_1 ) + +BOOST_AUTO_TEST_CASE( test_case_1 ) +{ + BOOST_MESSAGE( "Testing is in progress" ); + + BOOST_CHECK( false ); +} + +BOOST_AUTO_TEST_SUITE_END() + +//____________________________________________________________________________// + +bool +init_function() +{ + // do your own initialization here + // if it successful return true + + // But, you CAN'T use testing tools here + return true; +} + +//____________________________________________________________________________// + +int +main( int argc, char* argv[] ) +{ + return ::boost::unit_test::unit_test_main( &init_function, argc, argv ); +} + +//____________________________________________________________________________// + diff --git a/example/test_case_template_example.cpp b/example/test_case_template_example.cpp index 51351351..66fcc8fd 100644 --- a/example/test_case_template_example.cpp +++ b/example/test_case_template_example.cpp @@ -10,8 +10,7 @@ # pragma warning(disable: C4345) #endif -#include -#include +#include using boost::unit_test::test_suite; // Boost.MPL diff --git a/include/boost/test/detail/enable_warnings.hpp b/include/boost/test/detail/enable_warnings.hpp index 94bc6c80..7c11ba23 100644 --- a/include/boost/test/detail/enable_warnings.hpp +++ b/include/boost/test/detail/enable_warnings.hpp @@ -13,8 +13,8 @@ // *************************************************************************** #ifdef BOOST_MSVC -# pragma warning(default: 4511) // copy constructor could not be generated -# pragma warning(default: 4512) // assignment operator could not be generated +# pragma warning(default: 4511) // copy constructor can't not be generated +# pragma warning(default: 4512) // assignment operator can't not be generated # pragma warning(default: 4100) // unreferenced formal parameter # pragma warning(default: 4996) // was declared deprecated # pragma warning(default: 4355) // 'this' : used in base member initializer list @@ -24,5 +24,7 @@ # pragma warning(default: 4290) // C++ exception specification ignored except to ... # pragma warning(default: 4180) // qualifier applied to function type has no meaning; ignored # pragma warning(default: 4275) // non dll-interface class ... used as base for dll-interface class ... +# pragma warning(default: 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data +# pragma warning(default: 4511) // 'class' : copy constructor could not be generated # pragma warning(pop) #endif diff --git a/include/boost/test/detail/global_typedef.hpp b/include/boost/test/detail/global_typedef.hpp index 4f81c50b..ad66f984 100644 --- a/include/boost/test/detail/global_typedef.hpp +++ b/include/boost/test/detail/global_typedef.hpp @@ -32,11 +32,11 @@ typedef unsigned long counter_t; //____________________________________________________________________________// -enum report_level { CONFIRMATION_REPORT, SHORT_REPORT, DETAILED_REPORT, NO_REPORT, INV_REPORT_LEVEL }; +enum report_level { INV_REPORT_LEVEL, CONFIRMATION_REPORT, SHORT_REPORT, DETAILED_REPORT, NO_REPORT }; //____________________________________________________________________________// -enum output_format { CLF /* compiler log format */, XML /* XML */ }; +enum output_format { INV_OF, CLF /* compiler log format */, XML /* XML */ }; //____________________________________________________________________________// @@ -45,6 +45,7 @@ enum test_unit_type { tut_case = 0x01, tut_suite = 0x10, tut_any = 0x11 }; //____________________________________________________________________________// typedef unsigned long test_unit_id; + const test_unit_id INV_TEST_UNIT_ID = 0xFFFFFFFF; const test_unit_id MAX_TEST_CASE_ID = 0xFFFFFFFE; const test_unit_id MIN_TEST_CASE_ID = 0x00010000; @@ -53,6 +54,8 @@ const test_unit_id MIN_TEST_SUITE_ID = 0x00000001; //____________________________________________________________________________// +namespace ut_detail { + inline test_unit_type test_id_2_unit_type( test_unit_id id ) { @@ -61,6 +64,19 @@ test_id_2_unit_type( test_unit_id id ) //____________________________________________________________________________// +// helper templates to prevent ODR violations +template +struct static_constant { + static T value; +}; + +template +T static_constant::value; + +//____________________________________________________________________________// + +} // namespace ut_detail + } // namespace unit_test } // namespace boost diff --git a/include/boost/test/detail/suppress_warnings.hpp b/include/boost/test/detail/suppress_warnings.hpp index 02db5165..d5c95266 100644 --- a/include/boost/test/detail/suppress_warnings.hpp +++ b/include/boost/test/detail/suppress_warnings.hpp @@ -14,8 +14,8 @@ #ifdef BOOST_MSVC # pragma warning(push) -# pragma warning(disable: 4511) // copy constructor could not be generated -# pragma warning(disable: 4512) // assignment operator could not be generated +# pragma warning(disable: 4511) // copy constructor can't not be generated +# pragma warning(disable: 4512) // assignment operator can't not be generated # pragma warning(disable: 4100) // unreferenced formal parameter # pragma warning(disable: 4996) // was declared deprecated # pragma warning(disable: 4355) // 'this' : used in base member initializer list @@ -25,5 +25,7 @@ # pragma warning(disable: 4290) // C++ exception specification ignored except to ... # pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored # pragma warning(disable: 4275) // non dll-interface class ... used as base for dll-interface class ... +# pragma warning(disable: 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data +# pragma warning(disable: 4511) // 'class' : copy constructor could not be generated #endif diff --git a/include/boost/test/detail/unit_test_parameters.hpp b/include/boost/test/detail/unit_test_parameters.hpp index b07a9124..2a0814e6 100644 --- a/include/boost/test/detail/unit_test_parameters.hpp +++ b/include/boost/test/detail/unit_test_parameters.hpp @@ -32,7 +32,7 @@ namespace unit_test { namespace runtime_config { -void BOOST_TEST_DECL init( int* argc, char** argv ); +void BOOST_TEST_DECL init( int& argc, char** argv ); unit_test::log_level BOOST_TEST_DECL log_level(); bool BOOST_TEST_DECL no_result_code(); diff --git a/include/boost/test/detail/workaround.hpp b/include/boost/test/detail/workaround.hpp index 05bf6e7d..a7c50c24 100644 --- a/include/boost/test/detail/workaround.hpp +++ b/include/boost/test/detail/workaround.hpp @@ -41,6 +41,9 @@ std::ptrdiff_t distance( T const& x_, T const& y_ ) return res; } + +//____________________________________________________________________________// + #else using std::distance; #endif diff --git a/include/boost/test/floating_point_comparison.hpp b/include/boost/test/floating_point_comparison.hpp index ef0f773c..8ec7eb41 100644 --- a/include/boost/test/floating_point_comparison.hpp +++ b/include/boost/test/floating_point_comparison.hpp @@ -15,9 +15,15 @@ #ifndef BOOST_TEST_FLOATING_POINT_COMPARISON_HPP_071894GER #define BOOST_TEST_FLOATING_POINT_COMPARISON_HPP_071894GER -#include // for std::numeric_limits - +// Boost.Test +#include #include +#include + +// Boost +#include // for std::numeric_limits +#include // for numeric::conversion_traits +#include #include @@ -79,12 +85,12 @@ inline FPT safe_fpt_division( FPT f1, FPT f2 ) { // Avoid overflow. - if( f2 < static_cast(1) && f1 > f2*fpt_limits::max_value() ) + if( (f2 < static_cast(1)) && (f1 > f2*fpt_limits::max_value()) ) return fpt_limits::max_value(); // Avoid underflow. - if( f1 == static_cast(0) || - f2 > static_cast(1) && f1 < f2*fpt_limits::min_value() ) + if( (f1 == static_cast(0)) || + ((f2 > static_cast(1)) && (f1 < f2*fpt_limits::min_value())) ) return static_cast(0); return f1/f2; @@ -166,28 +172,38 @@ public: floating_point_comparison_type fpc_type = FPC_STRONG ) : p_fraction_tolerance( tt_detail::fpt_abs( static_cast(0.01)*tolerance.m_value ) ) , p_strong_or_weak( fpc_type == FPC_STRONG ) + , m_report_modifier( 100. ) {} template explicit close_at_tolerance( fraction_tolerance_t tolerance, floating_point_comparison_type fpc_type = FPC_STRONG ) : p_fraction_tolerance( tt_detail::fpt_abs( tolerance.m_value ) ) , p_strong_or_weak( fpc_type == FPC_STRONG ) + , m_report_modifier( 1. ) {} - bool operator()( FPT left, FPT right ) const + predicate_result operator()( FPT left, FPT right ) const { FPT diff = tt_detail::fpt_abs( left - right ); FPT d1 = tt_detail::safe_fpt_division( diff, tt_detail::fpt_abs( right ) ); FPT d2 = tt_detail::safe_fpt_division( diff, tt_detail::fpt_abs( left ) ); - return p_strong_or_weak - ? (d1 <= p_fraction_tolerance.get() && d2 <= p_fraction_tolerance.get()) - : (d1 <= p_fraction_tolerance.get() || d2 <= p_fraction_tolerance.get()); + predicate_result res( p_strong_or_weak + ? (d1 <= p_fraction_tolerance.get() && d2 <= p_fraction_tolerance.get()) + : (d1 <= p_fraction_tolerance.get() || d2 <= p_fraction_tolerance.get()) ); + + if( !res ) + res.message() << (( d1 <= p_fraction_tolerance.get() ? d2 : d1 ) * m_report_modifier); + + return res; } // Public properties readonly_property p_fraction_tolerance; readonly_property p_strong_or_weak; +private: + // Data members + FPT m_report_modifier; }; //____________________________________________________________________________// @@ -200,20 +216,31 @@ struct BOOST_TEST_DECL check_is_close_t { // Public typedefs typedef bool result_type; - template - bool - operator()( FPT left, FPT right, percent_tolerance_t tolerance, - floating_point_comparison_type fpc_type = FPC_STRONG ) + template + predicate_result + operator()( FPT1 left, FPT2 right, percent_tolerance_t tolerance, + floating_point_comparison_type fpc_type = FPC_STRONG ) const { + // deduce "better" type from types of arguments being compared + // if one type is floating and the second integral we use floating type and + // value of integral type is promoted to the floating. The same for float and double + // But we don't want to compare two values of integral types using this tool. + typedef typename numeric::conversion_traits::supertype FPT; + BOOST_STATIC_ASSERT( !is_integral::value ); + close_at_tolerance pred( tolerance, fpc_type ); return pred( left, right ); } - template - bool - operator()( FPT left, FPT right, fraction_tolerance_t tolerance, - floating_point_comparison_type fpc_type = FPC_STRONG ) + template + predicate_result + operator()( FPT1 left, FPT2 right, fraction_tolerance_t tolerance, + floating_point_comparison_type fpc_type = FPC_STRONG ) const { + // same as in a comment above + typedef typename numeric::conversion_traits::supertype FPT; + BOOST_STATIC_ASSERT( !is_integral::value ); + close_at_tolerance pred( tolerance, fpc_type ); return pred( left, right ); @@ -221,7 +248,7 @@ struct BOOST_TEST_DECL check_is_close_t { }; namespace { -check_is_close_t check_is_close; +check_is_close_t const& check_is_close = unit_test::ut_detail::static_constant::value; } //____________________________________________________________________________// @@ -236,14 +263,14 @@ struct BOOST_TEST_DECL check_is_small_t { template bool - operator()( FPT fpv, FPT tolerance ) + operator()( FPT fpv, FPT tolerance ) const { return tt_detail::fpt_abs( fpv ) < tt_detail::fpt_abs( tolerance ); } }; namespace { -check_is_small_t check_is_small; +check_is_small_t const& check_is_small = unit_test::ut_detail::static_constant::value; } //____________________________________________________________________________// diff --git a/include/boost/test/framework.hpp b/include/boost/test/framework.hpp index 4390dcb6..7f6fd2ae 100644 --- a/include/boost/test/framework.hpp +++ b/include/boost/test/framework.hpp @@ -70,7 +70,7 @@ BOOST_TEST_DECL test_unit& get( test_unit_id, test_unit_type ); template UnitType& get( test_unit_id id ) { - return static_cast( get( id, (test_unit_type)UnitType::type ) ); + return static_cast( get( id, static_cast(UnitType::type) ) ); } // test initiation @@ -94,6 +94,10 @@ struct setup_error : std::runtime_error { setup_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {} }; +#define BOOST_TEST_SETUP_ASSERT( cond, msg ) if( cond ) {} else throw unit_test::framework::setup_error( msg ) + +struct nothing_to_test {}; // not really an error + } // namespace framework } // unit_test diff --git a/include/boost/test/impl/debug.ipp b/include/boost/test/impl/debug.ipp index fcca3265..19960518 100644 --- a/include/boost/test/impl/debug.ipp +++ b/include/boost/test/impl/debug.ipp @@ -834,8 +834,8 @@ attach_debugger( bool break_or_continue ) bool created = !!::CreateProcessA( NULL, // pointer to name of executable module; NULL - use the one in command line cmd_line, // pointer to command line string - NULL, // pointer to process security attributes; NULL - debugger's handle couldn't be inherited - NULL, // pointer to thread security attributes; NULL - debugger's handle couldn't be inherited + NULL, // pointer to process security attributes; NULL - debugger's handle can't be inherited + NULL, // pointer to thread security attributes; NULL - debugger's handle can't be inherited true, // debugger inherit opened handles 0, // priority flags; 0 - normal priority NULL, // pointer to new environment block; NULL - use this process environment diff --git a/include/boost/test/impl/exception_safety.ipp b/include/boost/test/impl/exception_safety.ipp index dbd6f675..7f0afcb4 100644 --- a/include/boost/test/impl/exception_safety.ipp +++ b/include/boost/test/impl/exception_safety.ipp @@ -166,7 +166,7 @@ exception_safety_tester::exception_safety_tester( const_string test_name ) , m_forced_exception_point( 1 ) , m_exec_path_point( 0 ) , m_exec_path_counter( 1 ) -, m_break_exec_path( (unsigned)-1 ) +, m_break_exec_path( static_cast(-1) ) , m_invairant_failed( false ) { framework::register_observer( *this ); @@ -447,7 +447,7 @@ format_execution_path( wrap_stringstream& formatter, ExecPathIt it, ExecPathIt e unsigned i; for( i = 0; i < std::min( it->m_alloc.size, 8 ); i++ ) { - unsigned char c = ((unsigned char*)it->m_alloc.ptr)[i]; + unsigned char c = static_cast(it->m_alloc.ptr)[i]; if( (std::isprint)( c ) ) formatter << c; else @@ -457,7 +457,7 @@ format_execution_path( wrap_stringstream& formatter, ExecPathIt it, ExecPathIt e formatter << "> "; for( i = 0; i < std::min( it->m_alloc.size, 8 ); i++ ) { - unsigned c = ((unsigned char*)it->m_alloc.ptr)[i]; + unsigned c = static_cast(it->m_alloc.ptr)[i]; formatter << std::hex << std::uppercase << c << ' '; } @@ -491,7 +491,7 @@ exception_safety_tester::report_error() if( m_invairant_failed ) formatter << " and "; - formatter << (unsigned int)m_memory_in_use.size() << " memory leak"; + formatter << static_cast(m_memory_in_use.size()) << " memory leak"; if( m_memory_in_use.size() > 1 ) formatter << 's'; } diff --git a/include/boost/test/impl/execution_monitor.ipp b/include/boost/test/impl/execution_monitor.ipp index eb183be2..dbf2443f 100644 --- a/include/boost/test/impl/execution_monitor.ipp +++ b/include/boost/test/impl/execution_monitor.ipp @@ -114,8 +114,16 @@ typedef void* uintptr_t; #endif # if !defined(NDEBUG) && defined(_MSC_VER) && !defined(UNDER_CE) -# define BOOST_TEST_USE_DEBUG_MS_CRT # include +# define BOOST_TEST_CRT_HOOK_TYPE _CRT_REPORT_HOOK +# define BOOST_TEST_CRT_ASSERT _CRT_ASSERT +# define BOOST_TEST_CRT_ERROR _CRT_ERROR +# define BOOST_TEST_CRT_SET_HOOK(H) _CrtSetReportHook(H) +# else +# define BOOST_TEST_CRT_HOOK_TYPE void* +# define BOOST_TEST_CRT_ASSERT 2 +# define BOOST_TEST_CRT_ERROR 1 +# define BOOST_TEST_CRT_SET_HOOK(H) (void*)(H) # endif # if !BOOST_WORKAROUND(_MSC_VER, >= 1400 ) || defined(UNDER_CE) @@ -144,6 +152,25 @@ namespace { void _set_se_translator( void* ) {} } # include # include +# if defined(__FreeBSD__) + +# ifndef SIGPOLL +# define SIGPOLL SIGIO +# endif + +# if (__FreeBSD_version < 70100) + +# define ILL_ILLADR 0 // ILL_RESAD_FAULT +# define ILL_PRVOPC ILL_PRIVIN_FAULT +# define ILL_ILLOPN 2 // ILL_RESOP_FAULT +# define ILL_COPROC ILL_FPOP_FAULT + +# define BOOST_TEST_LIMITED_SIGNAL_DETAILS +# define BOOST_TEST_IGNORE_SIGCHLD + +# endif +# endif + # if !defined(__CYGWIN__) && !defined(__QNXNTO__) # define BOOST_TEST_USE_ALT_STACK # endif @@ -200,7 +227,9 @@ report_error( execution_exception::error_code ec, char const* format, ... ) va_list args; va_start( args, format ); - BOOST_TEST_VSNPRINTF( buf, sizeof(buf), format, args ); + BOOST_TEST_VSNPRINTF( buf, sizeof(buf)-1, format, args ); + buf[sizeof(buf)-1] = 0; + va_end( args ); throw execution_exception( ec, buf ); @@ -290,11 +319,28 @@ system_signal_exception::report() const switch( m_sig_info->si_signo ) { case SIGILL: switch( m_sig_info->si_code ) { +#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS case ILL_ILLOPC: report_error( execution_exception::system_fatal_error, "signal: illegal opcode; address of failing instruction: 0x%08lx", m_sig_info->si_addr ); break; + case ILL_ILLTRP: + report_error( execution_exception::system_fatal_error, + "signal: illegal trap; address of failing instruction: 0x%08lx", + m_sig_info->si_addr ); + break; + case ILL_PRVREG: + report_error( execution_exception::system_fatal_error, + "signal: privileged register; address of failing instruction: 0x%08lx", + m_sig_info->si_addr ); + break; + case ILL_BADSTK: + report_error( execution_exception::system_fatal_error, + "signal: internal stack error; address of failing instruction: 0x%08lx", + m_sig_info->si_addr ); + break; +#endif case ILL_ILLOPN: report_error( execution_exception::system_fatal_error, "signal: illegal operand; address of failing instruction: 0x%08lx", @@ -305,30 +351,20 @@ system_signal_exception::report() const "signal: illegal addressing mode; address of failing instruction: 0x%08lx", m_sig_info->si_addr ); break; - case ILL_ILLTRP: - report_error( execution_exception::system_fatal_error, - "signal: illegal trap; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; case ILL_PRVOPC: report_error( execution_exception::system_fatal_error, "signal: privileged opcode; address of failing instruction: 0x%08lx", m_sig_info->si_addr ); break; - case ILL_PRVREG: - report_error( execution_exception::system_fatal_error, - "signal: privileged register; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; case ILL_COPROC: report_error( execution_exception::system_fatal_error, "signal: co-processor error; address of failing instruction: 0x%08lx", m_sig_info->si_addr ); break; - case ILL_BADSTK: - report_error( execution_exception::system_fatal_error, - "signal: internal stack error; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + default: + report_error( execution_exception::system_fatal_error, + "signal: SIGILL, si_code: %d (illegal instruction; address of failing instruction: 0x%08lx)", + m_sig_info->si_addr, m_sig_info->si_code ); break; } break; @@ -375,11 +411,17 @@ system_signal_exception::report() const "signal: subscript out of range; address of failing instruction: 0x%08lx", m_sig_info->si_addr ); break; + default: + report_error( execution_exception::system_error, + "signal: SIGFPE, si_code: %d (errnoneous arithmetic operations; address of failing instruction: 0x%08lx)", + m_sig_info->si_addr, m_sig_info->si_code ); + break; } break; case SIGSEGV: switch( m_sig_info->si_code ) { +#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS case SEGV_MAPERR: report_error( execution_exception::system_fatal_error, "memory access violation at address: 0x%08lx: no mapping at fault address", @@ -390,11 +432,18 @@ system_signal_exception::report() const "memory access violation at address: 0x%08lx: invalid permissions", m_sig_info->si_addr ); break; +#endif + default: + report_error( execution_exception::system_fatal_error, + "signal: SIGSEGV, si_code: %d (memory access violation at address: 0x%08lx)", + m_sig_info->si_addr, m_sig_info->si_code ); + break; } break; case SIGBUS: switch( m_sig_info->si_code ) { +#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS case BUS_ADRALN: report_error( execution_exception::system_fatal_error, "memory access violation at address: 0x%08lx: invalid address alignment", @@ -410,11 +459,18 @@ system_signal_exception::report() const "memory access violation at address: 0x%08lx: object specific hardware error", m_sig_info->si_addr ); break; +#endif + default: + report_error( execution_exception::system_fatal_error, + "signal: SIGSEGV, si_code: %d (memory access violation at address: 0x%08lx)", + m_sig_info->si_addr, m_sig_info->si_code ); + break; } break; case SIGCHLD: switch( m_sig_info->si_code ) { +#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS case CLD_EXITED: report_error( execution_exception::system_error, "child has exited; pid: %d; uid: %d; exit value: %d", @@ -445,6 +501,12 @@ system_signal_exception::report() const "stopped child had continued; pid: %d; uid: %d; exit value: %d", (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status ); break; +#endif + default: + report_error( execution_exception::system_error, + "signal: SIGCHLD, si_code: %d (child process has terminated; pid: %d; uid: %d; exit value: %d)", + (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status, m_sig_info->si_code ); + break; } break; @@ -452,6 +514,7 @@ system_signal_exception::report() const case SIGPOLL: switch( m_sig_info->si_code ) { +#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS case POLL_IN: report_error( execution_exception::system_error, "data input available; band event %d", @@ -484,6 +547,12 @@ system_signal_exception::report() const (int)m_sig_info->si_band ); break; #endif +#endif + default: + report_error( execution_exception::system_error, + "signal: SIGPOLL, si_code: %d (asynchronous I/O event occured; band event %d)", + (int)m_sig_info->si_band, m_sig_info->si_code ); + break; } break; @@ -520,7 +589,8 @@ class signal_action { typedef struct sigaction* sigaction_ptr; public: //Constructor - explicit signal_action( int sig, bool install, bool attach_dbg, char* alt_stack ); + signal_action(); + signal_action( int sig, bool install, bool attach_dbg, char* alt_stack ); ~signal_action(); private: @@ -533,6 +603,12 @@ private: //____________________________________________________________________________// +signal_action::signal_action() +: m_installed( false ) +{} + +//____________________________________________________________________________// + signal_action::signal_action( int sig, bool install, bool attach_dbg, char* alt_stack ) : m_sig( sig ) , m_installed( install ) @@ -609,9 +685,7 @@ private: signal_action m_SEGV_action; signal_action m_BUS_action; signal_action m_CHLD_action; -#ifdef BOOST_TEST_CATCH_SIGPOLL signal_action m_POLL_action; -#endif signal_action m_ABRT_action; signal_action m_ALRM_action; @@ -634,7 +708,9 @@ signal_handler::signal_handler( bool catch_system_errors, int timeout, bool atta , m_FPE_action ( SIGFPE , catch_system_errors, attach_dbg, alt_stack ) , m_SEGV_action( SIGSEGV, catch_system_errors, attach_dbg, alt_stack ) , m_BUS_action ( SIGBUS , catch_system_errors, attach_dbg, alt_stack ) +#ifndef BOOST_TEST_IGNORE_SIGCHLD , m_CHLD_action( SIGCHLD, catch_system_errors, attach_dbg, alt_stack ) +#endif #ifdef BOOST_TEST_CATCH_SIGPOLL , m_POLL_action( SIGPOLL, catch_system_errors, attach_dbg, alt_stack ) #endif @@ -695,7 +771,10 @@ extern "C" { static bool ignore_sigchild( siginfo_t* info ) { - return info->si_signo == SIGCHLD && info->si_code == CLD_EXITED + return info->si_signo == SIGCHLD +#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS + && info->si_code == CLD_EXITED +#endif #ifdef BOOST_TEST_IGNORE_NON_ZERO_CHILD_CODE ; #else @@ -807,7 +886,7 @@ private: static void seh_catch_preventer( unsigned int /* id */, _EXCEPTION_POINTERS* /* exps */ ) { - throw; + throw; } //____________________________________________________________________________// @@ -941,21 +1020,19 @@ system_signal_exception::report() const //____________________________________________________________________________// -#if defined(BOOST_TEST_USE_DEBUG_MS_CRT) - // ************************************************************************** // // ************** assert_reporting_function ************** // // ************************************************************************** // int BOOST_TEST_CALL_DECL -assert_reporting_function( int reportType, char* userMessage, int* retVal ) +assert_reporting_function( int reportType, char* userMessage, int* ) { switch( reportType ) { - case _CRT_ASSERT: + case BOOST_TEST_CRT_ASSERT: detail::report_error( execution_exception::user_error, userMessage ); return 1; // return value and retVal are not important since we never reach this line - case _CRT_ERROR: + case BOOST_TEST_CRT_ERROR: detail::report_error( execution_exception::system_error, userMessage ); return 1; // return value and retVal are not important since we never reach this line @@ -964,8 +1041,6 @@ assert_reporting_function( int reportType, char* userMessage, int* retVal ) } } // assert_reporting_function -#endif - //____________________________________________________________________________// void BOOST_TEST_CALL_DECL @@ -1015,6 +1090,7 @@ int execution_monitor::catch_signals( unit_test::callback0 const& F ) { _invalid_parameter_handler old_iph = _invalid_parameter_handler(); + BOOST_TEST_CRT_HOOK_TYPE old_crt_hook; if( !p_catch_system_errors ) _set_se_translator( &detail::seh_catch_preventer ); @@ -1022,9 +1098,7 @@ execution_monitor::catch_signals( unit_test::callback0 const& F ) if( !!p_detect_fp_exceptions ) detail::switch_fp_exceptions( true ); -#ifdef BOOST_TEST_USE_DEBUG_MS_CRT - _CrtSetReportHook( &detail::assert_reporting_function ); -#endif + old_crt_hook = BOOST_TEST_CRT_SET_HOOK( &detail::assert_reporting_function ); old_iph = _set_invalid_parameter_handler( reinterpret_cast<_invalid_parameter_handler>( &detail::invalid_param_handler ) ); @@ -1047,6 +1121,8 @@ execution_monitor::catch_signals( unit_test::callback0 const& F ) if( !!p_detect_fp_exceptions ) detail::switch_fp_exceptions( false ); + BOOST_TEST_CRT_SET_HOOK( old_crt_hook ); + _set_invalid_parameter_handler( old_iph ); } } diff --git a/include/boost/test/impl/framework.ipp b/include/boost/test/impl/framework.ipp index 7392407d..ed9919c7 100644 --- a/include/boost/test/impl/framework.ipp +++ b/include/boost/test/impl/framework.ipp @@ -127,10 +127,10 @@ public: test_unit_store::value_type const& tu = *m_test_units.begin(); // the delete will erase this element from map - if( test_id_2_unit_type( tu.second->p_id ) == tut_suite ) - delete (test_suite const*)tu.second; + if( ut_detail::test_id_2_unit_type( tu.second->p_id ) == tut_suite ) + delete static_cast(tu.second); else - delete (test_case const*)tu.second; + delete static_cast(tu.second); } } @@ -219,7 +219,11 @@ public: namespace { +#if defined(__CYGWIN__) +framework_impl& s_frk_impl() { static framework_impl* the_inst = 0; if(!the_inst) the_inst = new framework_impl; return *the_inst; } +#else framework_impl& s_frk_impl() { static framework_impl the_inst; return the_inst; } +#endif } // local namespace @@ -230,7 +234,7 @@ namespace framework { void init( init_unit_test_func init_func, int argc, char* argv[] ) { - runtime_config::init( &argc, argv ); + runtime_config::init( argc, argv ); // set the log level and format unit_test_log.set_threshold_level( runtime_config::log_level() ); @@ -282,13 +286,11 @@ is_initialized() void register_test_unit( test_case* tc ) { - if( tc->p_id != INV_TEST_UNIT_ID ) - throw setup_error( BOOST_TEST_L( "test case already registered" ) ); + BOOST_TEST_SETUP_ASSERT( tc->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test case already registered" ) ); test_unit_id new_id = s_frk_impl().m_next_test_case_id; - if( new_id == MAX_TEST_CASE_ID ) - throw setup_error( BOOST_TEST_L( "too many test cases" ) ); + BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_CASE_ID, BOOST_TEST_L( "too many test cases" ) ); typedef framework_impl::test_unit_store::value_type map_value_type; @@ -303,13 +305,11 @@ register_test_unit( test_case* tc ) void register_test_unit( test_suite* ts ) { - if( ts->p_id != INV_TEST_UNIT_ID ) - throw setup_error( BOOST_TEST_L( "test suite already registered" ) ); + BOOST_TEST_SETUP_ASSERT( ts->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test suite already registered" ) ); test_unit_id new_id = s_frk_impl().m_next_test_suite_id; - if( new_id == MAX_TEST_SUITE_ID ) - throw setup_error( BOOST_TEST_L( "too many test suites" ) ); + BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_SUITE_ID, BOOST_TEST_L( "too many test suites" ) ); typedef framework_impl::test_unit_store::value_type map_value_type; s_frk_impl().m_test_units.insert( map_value_type( new_id, ts ) ); @@ -401,10 +401,9 @@ run( test_unit_id id, bool continue_test ) test_case_counter tcc; traverse_test_tree( id, tcc ); - if( tcc.p_count == 0 ) - throw setup_error( runtime_config::test_to_run().is_empty() - ? BOOST_TEST_L( "test tree is empty" ) - : BOOST_TEST_L( "no test cases matching filter" ) ); + BOOST_TEST_SETUP_ASSERT( tcc.p_count != 0 , runtime_config::test_to_run().is_empty() + ? BOOST_TEST_L( "test tree is empty" ) + : BOOST_TEST_L( "no test cases matching filter" ) ); bool call_start_finish = !continue_test || !s_frk_impl().m_test_in_progress; bool was_in_progress = s_frk_impl().m_test_in_progress; @@ -428,7 +427,7 @@ run( test_unit_id id, bool continue_test ) case 0: break; case 1: { - unsigned int seed = (unsigned int)std::time( 0 ); + unsigned int seed = static_cast( std::time( 0 ) ); BOOST_TEST_MESSAGE( "Test cases order is shuffled using seed: " << seed ); std::srand( seed ); break; diff --git a/include/boost/test/impl/interaction_based.ipp b/include/boost/test/impl/interaction_based.ipp index 8df4ae86..ce289336 100644 --- a/include/boost/test/impl/interaction_based.ipp +++ b/include/boost/test/impl/interaction_based.ipp @@ -66,8 +66,7 @@ manager::instance_ptr( bool reset, manager* new_ptr ) if( reset ) { if( new_ptr ) { - if( ptr != &dummy ) - throw unit_test::framework::setup_error( BOOST_TEST_L( "Couldn't run two interation based test the same time" ) ); + BOOST_TEST_SETUP_ASSERT( ptr == &dummy, BOOST_TEST_L( "Can't run two interation based test the same time" ) ); ptr = new_ptr; } diff --git a/include/boost/test/impl/logged_expectations.ipp b/include/boost/test/impl/logged_expectations.ipp index be8a52f6..ff30628b 100644 --- a/include/boost/test/impl/logged_expectations.ipp +++ b/include/boost/test/impl/logged_expectations.ipp @@ -85,7 +85,7 @@ expectations_logger::expectations_logger( const_string log_file_name, bool test_ m_log_file.open( log_file_name.begin(), test_or_log ? std::ios::in : std::ios::out ); BOOST_REQUIRE_MESSAGE( m_log_file.is_open(), - "Couldn't open expectations log file " << log_file_name + "Can't open expectations log file " << log_file_name << " for " << ( m_test_or_log ? "reading" : "writing") ); if( m_test_or_log ) { diff --git a/include/boost/test/impl/results_collector.ipp b/include/boost/test/impl/results_collector.ipp index 64dd7546..2d07fcdb 100644 --- a/include/boost/test/impl/results_collector.ipp +++ b/include/boost/test/impl/results_collector.ipp @@ -215,9 +215,9 @@ results_collector_t::test_unit_finish( test_unit const& tu, unsigned long ) if( !num_failures_match ) BOOST_TEST_MESSAGE( "Test case " << tu.p_name << " has fewer failures than expected" ); - bool has_any_assertions = tr.p_aborted || (tr.p_assertions_failed != 0) || (tr.p_assertions_passed != 0); - if( !has_any_assertions ) - BOOST_TEST_MESSAGE( "Test case " << tu.p_name << " doesn't include any assertions" ); + bool run_any_assertions = tr.p_aborted || (tr.p_assertions_failed != 0) || (tr.p_assertions_passed != 0); + if( !run_any_assertions ) + BOOST_TEST_MESSAGE( "Test case " << tu.p_name << " did not run any assertions" ); } } diff --git a/include/boost/test/impl/results_reporter.ipp b/include/boost/test/impl/results_reporter.ipp index 3ff16fe5..e9ef2fa2 100644 --- a/include/boost/test/impl/results_reporter.ipp +++ b/include/boost/test/impl/results_reporter.ipp @@ -130,6 +130,8 @@ set_format( output_format rf ) case XML: set_format( new output::xml_report_formatter ); break; + default: + break; } } diff --git a/include/boost/test/impl/test_tools.ipp b/include/boost/test/impl/test_tools.ipp index 3ddb99fd..6f5d7e9e 100644 --- a/include/boost/test/impl/test_tools.ipp +++ b/include/boost/test/impl/test_tools.ipp @@ -60,7 +60,7 @@ namespace test_tools { void print_log_value::operator()( std::ostream& ostr, char t ) { - if( (std::isprint)( (unsigned char)t ) ) + if( (std::isprint)( static_cast(t) ) ) ostr << '\'' << t << '\''; else ostr << std::hex @@ -69,7 +69,7 @@ print_log_value::operator()( std::ostream& ostr, char t ) #else << "0x" #endif - << (int)t; + << static_cast(t); } //____________________________________________________________________________// @@ -84,7 +84,7 @@ print_log_value::operator()( std::ostream& ostr, unsigned char t #else << "0x" #endif - << (int)t; + << static_cast(t); } //____________________________________________________________________________// @@ -227,18 +227,16 @@ check_impl( predicate_result const& pr, lazy_ostream const& check_descr, unit_test_log << unit_test::log::begin( file_name, line_num ) << ll; - unit_test_log << "difference between " << arg1_descr << "{" << *arg1_val << "}" - << " and " << arg2_descr << "{" << *arg2_val << "}" - << ( tl == PASS ? " doesn't exceed " : " exceeds " ) + unit_test_log << "difference{" << pr.message() << (ct == CHECK_CLOSE ? "%" : "") + << "} between " << arg1_descr << "{" << *arg1_val + << "} and " << arg2_descr << "{" << *arg2_val + << ( tl == PASS ? "} doesn't exceed " : "} exceeds " ) << *toler_val; if( ct == CHECK_CLOSE ) unit_test_log << "%"; va_end( args ); - if( !pr.has_empty_message() ) - unit_test_log << ". " << pr.message(); - unit_test_log << unit_test::log::end(); break; } @@ -451,7 +449,7 @@ output_test_stream::output_test_stream( const_string pattern_file_name, bool mat m_pimpl->m_pattern.open( pattern_file_name.begin(), m ); BOOST_WARN_MESSAGE( m_pimpl->m_pattern.is_open(), - "Couldn't open pattern file " << pattern_file_name + "Can't open pattern file " << pattern_file_name << " for " << (match_or_save ? "reading" : "writing") ); } @@ -528,7 +526,7 @@ output_test_stream::match_pattern( bool flush_stream ) if( !m_pimpl->m_pattern.is_open() ) { result = false; - result.message() << "Pattern file could not be opened!"; + result.message() << "Pattern file can't be opened!"; } else { if( m_pimpl->m_match_or_save ) { diff --git a/include/boost/test/impl/unit_test_main.ipp b/include/boost/test/impl/unit_test_main.ipp index 7648e656..adedf351 100644 --- a/include/boost/test/impl/unit_test_main.ipp +++ b/include/boost/test/impl/unit_test_main.ipp @@ -23,7 +23,8 @@ #include -#if !defined(__BORLANDC__) && !BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) +#if !defined(__BORLANDC__) && !BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) && !BOOST_WORKAROUND( __SUNPRO_CC, < 0x5100 ) +#define BOOST_TEST_SUPPORT_RUN_BY_NAME #include #endif @@ -100,13 +101,13 @@ public: const_string m_value; }; // Constructor -#if defined(__BORLANDC__) || BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) +#ifndef BOOST_TEST_SUPPORT_RUN_BY_NAME explicit test_case_filter( const_string ) : m_depth( 0 ) {} #else - explicit test_case_filter( const_string tc_to_tun ) + explicit test_case_filter( const_string tc_to_run ) : m_depth( 0 ) { - string_token_iterator tit( tc_to_tun, (dropped_delimeters = "/", kept_delimeters = dt_none) ); + string_token_iterator tit( tc_to_run, (dropped_delimeters = "/", kept_delimeters = dt_none) ); while( tit != string_token_iterator() ) { m_filters.push_back( @@ -186,9 +187,12 @@ unit_test_main( init_unit_test_func init_func, int argc, char* argv[] ) results_reporter::make_report(); return runtime_config::no_result_code() - ? boost::exit_success + ? boost::exit_success : results_collector.results( framework::master_test_suite().p_id ).result_code(); } + catch( framework::nothing_to_test const& ) { + return boost::exit_success; + } catch( framework::internal_error const& ex ) { results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl; diff --git a/include/boost/test/impl/unit_test_parameters.ipp b/include/boost/test/impl/unit_test_parameters.ipp index e46b596a..e15fd61b 100644 --- a/include/boost/test/impl/unit_test_parameters.ipp +++ b/include/boost/test/impl/unit_test_parameters.ipp @@ -25,6 +25,22 @@ #include #include #include +#include + +// Boost.Runtime.Param +#include +#include + +namespace rt = boost::runtime; +namespace cla = rt::cla; + + +#ifndef UNDER_CE +#include + +namespace env = rt::env; +#endif + // Boost #include @@ -35,6 +51,7 @@ // STL #include #include +#include #include @@ -48,130 +65,14 @@ namespace boost { namespace unit_test { -namespace { - -// framework parameters and there corresponding command-line arguments -literal_string LOG_LEVEL = "BOOST_TEST_LOG_LEVEL"; -literal_string NO_RESULT_CODE = "BOOST_TEST_RESULT_CODE"; -literal_string REPORT_LEVEL = "BOOST_TEST_REPORT_LEVEL"; -literal_string TESTS_TO_RUN = "BOOST_TESTS_TO_RUN"; -literal_string SAVE_TEST_PATTERN = "BOOST_TEST_SAVE_PATTERN"; -literal_string BUILD_INFO = "BOOST_TEST_BUILD_INFO"; -literal_string SHOW_PROGRESS = "BOOST_TEST_SHOW_PROGRESS"; -literal_string CATCH_SYS_ERRORS = "BOOST_TEST_CATCH_SYSTEM_ERRORS"; -literal_string AUTO_START_DBG = "BOOST_TEST_AUTO_START_DBG"; -literal_string USE_ALT_STACK = "BOOST_TEST_USE_ALT_STACK"; -literal_string DETECT_FP_EXCEPT = "BOOST_TEST_DETECT_FP_EXCEPTIONS"; -literal_string REPORT_FORMAT = "BOOST_TEST_REPORT_FORMAT"; -literal_string LOG_FORMAT = "BOOST_TEST_LOG_FORMAT"; -literal_string OUTPUT_FORMAT = "BOOST_TEST_OUTPUT_FORMAT"; -literal_string DETECT_MEM_LEAK = "BOOST_TEST_DETECT_MEMORY_LEAK"; -literal_string RANDOM_SEED = "BOOST_TEST_RANDOM"; -literal_string BREAK_EXEC_PATH = "BOOST_TEST_BREAK_EXEC_PATH"; - -unit_test::log_level s_log_level; -bool s_no_result_code; -unit_test::report_level s_report_level; -const_string s_tests_to_run; -const_string s_exec_path_to_break; -bool s_save_pattern; -bool s_show_build_info; -bool s_show_progress; -bool s_catch_sys_errors; -bool s_auto_start_dbg; -bool s_use_alt_stack; -bool s_detect_fp_except; -output_format s_report_format; -output_format s_log_format; -long s_detect_mem_leaks; -unsigned int s_random_seed; - // ************************************************************************** // -// ************** runtime_config ************** // +// ************** input operations for unit_test's enums ************** // // ************************************************************************** // -const_string -retrieve_framework_parameter( const_string parameter_name, int* argc, char** argv ) +std::istream& +operator>>( std::istream& in, unit_test::log_level& ll ) { - static fixed_mapping parameter_2_cla_name_map( - LOG_LEVEL , "--log_level", - NO_RESULT_CODE , "--result_code", - REPORT_LEVEL , "--report_level", - TESTS_TO_RUN , "--run_test", - SAVE_TEST_PATTERN , "--save_pattern", - BUILD_INFO , "--build_info", - SHOW_PROGRESS , "--show_progress", - CATCH_SYS_ERRORS , "--catch_system_errors", - AUTO_START_DBG , "--auto_start_dbg", - USE_ALT_STACK , "--use_alt_stack", - DETECT_FP_EXCEPT , "--detect_fp_exceptions", - REPORT_FORMAT , "--report_format", - LOG_FORMAT , "--log_format", - OUTPUT_FORMAT , "--output_format", - DETECT_MEM_LEAK , "--detect_memory_leaks", - RANDOM_SEED , "--random", - BREAK_EXEC_PATH , "--break_exec_path", - - "" - ); - - // first try to find parameter among command line arguments if present - if( argc ) { - // locate corresponding cla name - const_string cla_name = parameter_2_cla_name_map[parameter_name]; - - if( !cla_name.is_empty() ) { - for( int i = 1; i < *argc; ++i ) { - if( cla_name == const_string( argv[i], cla_name.size() ) && argv[i][cla_name.size()] == '=' ) { - const_string result = argv[i] + cla_name.size() + 1; - - for( int j = i; j < *argc; ++j ) { - argv[j] = argv[j+1]; - } - --(*argc); - - return result; - } - } - } - } - - return std::getenv( parameter_name.begin() ); -} - -long interpret_long( const_string from ) -{ - bool negative = false; - long res = 0; - - if( first_char( from ) == '-' ) { - negative = true; - from.trim_left( 1 ); - } - - const_string::iterator it = from.begin(); - for( ;it != from.end(); ++it ) { - int d = *it - '0'; - - res = 10 * res + d; - } - - if( negative ) - res = -res; - - return res; -} - -} // local namespace - -//____________________________________________________________________________// - -namespace runtime_config { - -void -init( int* argc, char** argv ) -{ - fixed_mapping > log_level_name( + static fixed_mapping > log_level_name( "all" , log_successful_tests, "success" , log_successful_tests, "test_suite" , log_test_units, @@ -185,8 +86,22 @@ init( int* argc, char** argv ) "nothing" , log_nothing, invalid_log_level - ); + ); + std::string val; + in >> val; + + ll = log_level_name[val]; + BOOST_TEST_SETUP_ASSERT( ll != unit_test::invalid_log_level, "invalid log level " + val ); + + return in; +} + +//____________________________________________________________________________// + +std::istream& +operator>>( std::istream& in, unit_test::report_level& rl ) +{ fixed_mapping > report_level_name ( "confirm", CONFIRMATION_REPORT, "short", SHORT_REPORT, @@ -194,57 +109,221 @@ init( int* argc, char** argv ) "no", NO_REPORT, INV_REPORT_LEVEL - ); + ); - fixed_mapping > output_format_name ( - "HRF", CLF, - "CLF", CLF, - "XML", XML, + std::string val; + in >> val; - CLF - ); + rl = report_level_name[val]; + BOOST_TEST_SETUP_ASSERT( rl != INV_REPORT_LEVEL, "invalid report level " + val ); - s_no_result_code = retrieve_framework_parameter( NO_RESULT_CODE, argc, argv ) == "no"; - s_save_pattern = retrieve_framework_parameter( SAVE_TEST_PATTERN, argc, argv ) == "yes"; - s_show_build_info = retrieve_framework_parameter( BUILD_INFO, argc, argv ) == "yes"; - s_show_progress = retrieve_framework_parameter( SHOW_PROGRESS, argc, argv ) == "yes"; -#ifdef BOOST_TEST_DEFAULTS_TO_CORE_DUMP - s_catch_sys_errors = retrieve_framework_parameter( CATCH_SYS_ERRORS, argc, argv ) == "yes"; -#else - s_catch_sys_errors = retrieve_framework_parameter( CATCH_SYS_ERRORS, argc, argv ) != "no"; -#endif - s_use_alt_stack = retrieve_framework_parameter( USE_ALT_STACK, argc, argv ) != "no"; - s_detect_fp_except = retrieve_framework_parameter( DETECT_FP_EXCEPT, argc, argv ) == "yes"; - s_tests_to_run = retrieve_framework_parameter( TESTS_TO_RUN, argc, argv ); - s_exec_path_to_break= retrieve_framework_parameter( BREAK_EXEC_PATH, argc, argv ); + return in; +} - const_string rs_str = retrieve_framework_parameter( RANDOM_SEED, argc, argv ); - s_random_seed = rs_str.is_empty() ? 0 : lexical_cast( rs_str ); - - s_log_level = log_level_name[retrieve_framework_parameter( LOG_LEVEL, argc, argv )]; - s_report_level = report_level_name[retrieve_framework_parameter( REPORT_LEVEL, argc, argv )]; +//____________________________________________________________________________// - s_report_format = output_format_name[retrieve_framework_parameter( REPORT_FORMAT, argc, argv )]; - s_log_format = output_format_name[retrieve_framework_parameter( LOG_FORMAT, argc, argv )]; +std::istream& +operator>>( std::istream& in, unit_test::output_format& of ) +{ + fixed_mapping > output_format_name ( + "HRF", unit_test::CLF, + "CLF", unit_test::CLF, + "XML", unit_test::XML, - const_string output_format = retrieve_framework_parameter( OUTPUT_FORMAT, argc, argv ); - if( !output_format.is_empty() ) { - s_report_format = output_format_name[output_format]; - s_log_format = output_format_name[output_format]; + unit_test::INV_OF + ); + + std::string val; + in >> val; + + of = output_format_name[val]; + BOOST_TEST_SETUP_ASSERT( of != unit_test::INV_OF, "invalid output format " + val ); + + return in; +} + +//____________________________________________________________________________// + +// ************************************************************************** // +// ************** runtime_config ************** // +// ************************************************************************** // + +namespace runtime_config { + +namespace { + +// framework parameters and corresponding command-line arguments +std::string AUTO_START_DBG = "auto_start_dbg"; +std::string BREAK_EXEC_PATH = "break_exec_path"; +std::string BUILD_INFO = "build_info"; +std::string CATCH_SYS_ERRORS = "catch_system_errors"; +std::string DETECT_FP_EXCEPT = "detect_fp_exceptions"; +std::string DETECT_MEM_LEAKS = "detect_memory_leaks"; +std::string LOG_FORMAT = "log_format"; +std::string LOG_LEVEL = "log_level"; +std::string OUTPUT_FORMAT = "output_format"; +std::string RANDOM_SEED = "random"; +std::string REPORT_FORMAT = "report_format"; +std::string REPORT_LEVEL = "report_level"; +std::string RESULT_CODE = "result_code"; +std::string TESTS_TO_RUN = "run_test"; +std::string SAVE_TEST_PATTERN = "save_pattern"; +std::string SHOW_PROGRESS = "show_progress"; +std::string USE_ALT_STACK = "use_alt_stack"; + +fixed_mapping parameter_2_env_var( + AUTO_START_DBG , "BOOST_TEST_AUTO_START_DBG", + BREAK_EXEC_PATH , "BOOST_TEST_BREAK_EXEC_PATH", + BUILD_INFO , "BOOST_TEST_BUILD_INFO", + CATCH_SYS_ERRORS , "BOOST_TEST_CATCH_SYSTEM_ERRORS", + DETECT_FP_EXCEPT , "BOOST_TEST_DETECT_FP_EXCEPTIONS", + DETECT_MEM_LEAKS , "BOOST_TEST_DETECT_MEMORY_LEAK", + LOG_FORMAT , "BOOST_TEST_LOG_FORMAT", + LOG_LEVEL , "BOOST_TEST_LOG_LEVEL", + OUTPUT_FORMAT , "BOOST_TEST_OUTPUT_FORMAT", + RANDOM_SEED , "BOOST_TEST_RANDOM", + REPORT_FORMAT , "BOOST_TEST_REPORT_FORMAT", + REPORT_LEVEL , "BOOST_TEST_REPORT_LEVEL", + RESULT_CODE , "BOOST_TEST_RESULT_CODE", + TESTS_TO_RUN , "BOOST_TESTS_TO_RUN", + SAVE_TEST_PATTERN , "BOOST_TEST_SAVE_PATTERN", + SHOW_PROGRESS , "BOOST_TEST_SHOW_PROGRESS", + USE_ALT_STACK , "BOOST_TEST_USE_ALT_STACK", + + "" +); + +//____________________________________________________________________________// + +// storage for the CLAs +cla::parser s_cla_parser; +std::string s_empty; + +output_format s_report_format; +output_format s_log_format; + +//____________________________________________________________________________// + +template +T +retrieve_parameter( const_string parameter_name, cla::parser const& s_cla_parser, T const& default_value = T(), T const& optional_value = T() ) +{ + rt::const_argument_ptr arg = s_cla_parser[parameter_name]; + if( arg ) { + if( rtti::type_id() == rtti::type_id() || + !static_cast( arg->p_formal_parameter.get() ).p_optional_value ) + return s_cla_parser.get( parameter_name ); + + optional val = s_cla_parser.get >( parameter_name ); + if( val ) + return *val; + else + return optional_value; } - const_string ml_str = retrieve_framework_parameter( DETECT_MEM_LEAK, argc, argv ); - s_detect_mem_leaks = ml_str.is_empty() ? 1 : interpret_long( ml_str ); + boost::optional v; - const_string dbg = retrieve_framework_parameter( AUTO_START_DBG, argc, argv ); +#ifndef UNDER_CE + env::get( parameter_2_env_var[parameter_name], v ); +#endif - if( dbg.is_empty() || dbg == "no" ) - s_auto_start_dbg = false; - else { - s_auto_start_dbg = true; + if( v ) + return *v; + else + return default_value; +} - if( dbg != "yes" ) - debug::set_debugger( dbg ); +//____________________________________________________________________________// + +} // local namespace + +void +init( int& argc, char** argv ) +{ + using namespace cla; + + try { + s_cla_parser - cla::ignore_mismatch + << cla::dual_name_parameter( AUTO_START_DBG + "|d" ) + - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, + cla::description = "Automatically starts debugger if system level error (signal) occurs") + << cla::named_parameter( BREAK_EXEC_PATH ) + - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional, + cla::description = "For the exception safety testing allows to break at specific execution path") + << cla::dual_name_parameter( BUILD_INFO + "|i" ) + - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, + cla::description = "Shows library build information" ) + << cla::dual_name_parameter( CATCH_SYS_ERRORS + "|s" ) + - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, + cla::description = "Allows to switch between catching and ignoring system errors (signals)") + << cla::named_parameter( DETECT_FP_EXCEPT ) + - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional, + cla::description = "Allows to switch between catching and ignoring floating point exceptions") + << cla::named_parameter( DETECT_MEM_LEAKS ) + - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional, + cla::description = "Allows to switch between catching and ignoring memory leaks") + << cla::dual_name_parameter( LOG_FORMAT + "|f" ) + - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, + cla::description = "Specifies log format") + << cla::dual_name_parameter( LOG_LEVEL + "|l" ) + - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, + cla::description = "Specifies log level") + << cla::dual_name_parameter( OUTPUT_FORMAT + "|o" ) + - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, + cla::description = "Specifies output format (both log and report)") + << cla::dual_name_parameter( RANDOM_SEED + "|a" ) + - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,cla::optional_value, + cla::description = "Allows to switch between sequential and random order of test units execution.\n" + "Optionally allows to specify concrete seed for random number generator") + << cla::dual_name_parameter( REPORT_FORMAT + "|m" ) + - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, + cla::description = "Specifies report format") + << cla::dual_name_parameter(REPORT_LEVEL + "|r") + - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, + cla::description = "Specifies report level") + << cla::dual_name_parameter( RESULT_CODE + "|c" ) + - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, + cla::description = "Allows to disable test modules's result code generation") + << cla::dual_name_parameter( TESTS_TO_RUN + "|t" ) + - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, + cla::description = "Allows to filter which test units to run") + << cla::named_parameter( SAVE_TEST_PATTERN ) + - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional, + cla::description = "Allows to switch between saving and matching against test pattern file") + << cla::dual_name_parameter( SHOW_PROGRESS + "|p" ) + - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, + cla::description = "Turns on progress display") + << cla::named_parameter( USE_ALT_STACK ) + - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional, + cla::description = "Turns on/off usage of an alternative stack for signal handling") + + << cla::dual_name_parameter( "help|?" ) + - (cla::prefix = "--|-",cla::separator = "=",cla::guess_name,cla::optional, + cla::description = "this help message") + ; + + s_cla_parser.parse( argc, argv ); + + if( s_cla_parser["help"] ) { + s_cla_parser.help( std::cout ); + throw framework::nothing_to_test(); + } + + s_report_format = retrieve_parameter( REPORT_FORMAT, s_cla_parser, unit_test::CLF ); + s_log_format = retrieve_parameter( LOG_FORMAT, s_cla_parser, unit_test::CLF ); + + unit_test::output_format of = retrieve_parameter( OUTPUT_FORMAT, s_cla_parser, unit_test::INV_OF ); + + if( of != unit_test::INV_OF ) + s_report_format = s_log_format = of; + } + catch( rt::logic_error const& ex ) { + std::ostringstream err; + + err << "Fail to process runtime parameters: " << ex.msg() << std::endl; + s_cla_parser.usage( err ); + + throw framework::setup_error( err.str() ); } } @@ -253,7 +332,7 @@ init( int* argc, char** argv ) unit_test::log_level log_level() { - return s_log_level; + return retrieve_parameter( LOG_LEVEL, s_cla_parser, unit_test::log_all_errors ); } //____________________________________________________________________________// @@ -261,7 +340,7 @@ log_level() bool no_result_code() { - return s_no_result_code; + return !retrieve_parameter( RESULT_CODE, s_cla_parser, true ); } //____________________________________________________________________________// @@ -269,7 +348,7 @@ no_result_code() unit_test::report_level report_level() { - return s_report_level; + return retrieve_parameter( REPORT_LEVEL, s_cla_parser, unit_test::CONFIRMATION_REPORT ); } //____________________________________________________________________________// @@ -277,7 +356,9 @@ report_level() const_string test_to_run() { - return s_tests_to_run; + static std::string s_test_to_run = retrieve_parameter( TESTS_TO_RUN, s_cla_parser, s_empty ); + + return s_test_to_run; } //____________________________________________________________________________// @@ -285,7 +366,9 @@ test_to_run() const_string break_exec_path() { - return s_exec_path_to_break; + static std::string s_break_exec_path = retrieve_parameter( BREAK_EXEC_PATH, s_cla_parser, s_empty ); + + return s_break_exec_path; } //____________________________________________________________________________// @@ -293,7 +376,7 @@ break_exec_path() bool save_pattern() { - return s_save_pattern; + return retrieve_parameter( SAVE_TEST_PATTERN, s_cla_parser, false ); } //____________________________________________________________________________// @@ -301,7 +384,7 @@ save_pattern() bool show_progress() { - return s_show_progress; + return retrieve_parameter( SHOW_PROGRESS, s_cla_parser, false ); } //____________________________________________________________________________// @@ -309,7 +392,7 @@ show_progress() bool show_build_info() { - return s_show_build_info; + return retrieve_parameter( BUILD_INFO, s_cla_parser, false ); } //____________________________________________________________________________// @@ -317,7 +400,13 @@ show_build_info() bool catch_sys_errors() { - return s_catch_sys_errors; + return retrieve_parameter( CATCH_SYS_ERRORS, s_cla_parser, +#ifdef BOOST_TEST_DEFAULTS_TO_CORE_DUMP + false +#else + true +#endif + ); } //____________________________________________________________________________// @@ -325,7 +414,9 @@ catch_sys_errors() bool auto_start_dbg() { - return s_auto_start_dbg; + // !! set debugger as an option + return retrieve_parameter( AUTO_START_DBG, s_cla_parser, false ); +; } //____________________________________________________________________________// @@ -333,7 +424,7 @@ auto_start_dbg() bool use_alt_stack() { - return s_use_alt_stack; + return retrieve_parameter( USE_ALT_STACK, s_cla_parser, true ); } //____________________________________________________________________________// @@ -341,7 +432,7 @@ use_alt_stack() bool detect_fp_exceptions() { - return s_detect_fp_except; + return retrieve_parameter( DETECT_FP_EXCEPT, s_cla_parser, false ); } //____________________________________________________________________________// @@ -365,7 +456,7 @@ log_format() long detect_memory_leaks() { - return s_detect_mem_leaks; + return retrieve_parameter( DETECT_MEM_LEAKS, s_cla_parser, static_cast(1) ); } //____________________________________________________________________________// @@ -373,7 +464,7 @@ detect_memory_leaks() int random_seed() { - return s_random_seed; + return retrieve_parameter( RANDOM_SEED, s_cla_parser, 0, 1 ); } //____________________________________________________________________________// diff --git a/include/boost/test/impl/unit_test_suite.ipp b/include/boost/test/impl/unit_test_suite.ipp index aa23f0bc..32efc605 100644 --- a/include/boost/test/impl/unit_test_suite.ipp +++ b/include/boost/test/impl/unit_test_suite.ipp @@ -9,8 +9,8 @@ // // Version : $Revision$ // -// Description : privide core implementation for Unit Test Framework. -// Extensions could be provided in separate files +// Description : privides core implementation for Unit Test Framework. +// Extensions can be provided in separate files // *************************************************************************** #ifndef BOOST_TEST_UNIT_TEST_SUITE_IPP_012205GER @@ -104,7 +104,7 @@ test_unit::increase_exp_fail( unsigned num ) // ************************************************************************** // test_case::test_case( const_string name, callback0<> const& test_func ) -: test_unit( name, (test_unit_type)type ) +: test_unit( name, static_cast(type) ) , m_test_func( test_func ) { // !! weirdest MSVC BUG; try to remove this statement; looks like it eats first token of next statement @@ -123,7 +123,7 @@ test_case::test_case( const_string name, callback0<> const& test_func ) //____________________________________________________________________________// test_suite::test_suite( const_string name ) -: test_unit( name, (test_unit_type)type ) +: test_unit( name, static_cast(type) ) { framework::register_test_unit( this ); } @@ -161,7 +161,7 @@ test_suite::add( test_unit_generator const& gen, unsigned timeout ) void test_suite::remove( test_unit_id id ) { - std::vector::iterator it = std::find( m_members.begin(), m_members.begin(), id ); + std::vector::iterator it = std::find( m_members.begin(), m_members.end(), id ); if( it != m_members.end() ) m_members.erase( it ); @@ -173,7 +173,7 @@ test_unit_id test_suite::get( const_string tu_name ) const { BOOST_TEST_FOREACH( test_unit_id, id, m_members ) { - if( tu_name == framework::get( id, test_id_2_unit_type( id ) ).p_name.get() ) + if( tu_name == framework::get( id, ut_detail::test_id_2_unit_type( id ) ).p_name.get() ) return id; } @@ -228,7 +228,7 @@ traverse_test_tree( test_suite const& suite, test_tree_visitor& V ) void traverse_test_tree( test_unit_id id, test_tree_visitor& V ) { - if( test_id_2_unit_type( id ) == tut_case ) + if( ut_detail::test_id_2_unit_type( id ) == tut_case ) traverse_test_tree( framework::get( id ), V ); else traverse_test_tree( framework::get( id ), V ); diff --git a/include/boost/test/mock_object.hpp b/include/boost/test/mock_object.hpp index 1234bd3b..dbc4cb41 100644 --- a/include/boost/test/mock_object.hpp +++ b/include/boost/test/mock_object.hpp @@ -146,7 +146,7 @@ class mock_object : public Base { public: static mock_object& prototype() { - static mock_object p( (dummy*)0 ); + static mock_object p( reinterpret_cast(0) ); return p; } diff --git a/include/boost/test/parameterized_test.hpp b/include/boost/test/parameterized_test.hpp index 32550ad8..7654409a 100644 --- a/include/boost/test/parameterized_test.hpp +++ b/include/boost/test/parameterized_test.hpp @@ -82,7 +82,7 @@ public: , m_par_end( par_end ) {} - test_unit* next() const + virtual test_unit* next() const { if( m_par_begin == m_par_end ) return (test_unit*)0; diff --git a/include/boost/test/predicate_result.hpp b/include/boost/test/predicate_result.hpp index 8d873fd0..8ac18b75 100644 --- a/include/boost/test/predicate_result.hpp +++ b/include/boost/test/predicate_result.hpp @@ -41,6 +41,9 @@ namespace test_tools { class BOOST_TEST_DECL predicate_result { typedef unit_test::const_string const_string; + struct dummy { void nonnull() {}; }; + typedef void (dummy::*safe_bool)(); + public: // Constructor predicate_result( bool pv_ ) @@ -50,8 +53,10 @@ public: template predicate_result( BoolConvertable const& pv_ ) : p_predicate_value( !!pv_ ) {} + // Access methods bool operator!() const { return !p_predicate_value; } void operator=( bool pv_ ) { p_predicate_value.value = pv_; } + operator safe_bool() const { return !!p_predicate_value ? &dummy::nonnull : 0; } // Public properties BOOST_READONLY_PROPERTY( bool, (predicate_result) ) p_predicate_value; diff --git a/include/boost/test/test_case_template.hpp b/include/boost/test/test_case_template.hpp index 567afee1..8c64f1ce 100644 --- a/include/boost/test/test_case_template.hpp +++ b/include/boost/test/test_case_template.hpp @@ -9,143 +9,7 @@ // // Version : $Revision$ // -// Description : implements support for test cases templates instantiated with -// sequence of test types +// Description : deprecated // *************************************************************************** -#ifndef BOOST_TEST_TEST_CASE_TEMPLATE_HPP_071894GER -#define BOOST_TEST_TEST_CASE_TEMPLATE_HPP_071894GER - -// Boost -#include -#include -#include -#include - -// STL -#include - -#include - -//____________________________________________________________________________// - -#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_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* ) \ -/**/ - -//____________________________________________________________________________// - -namespace boost { - -namespace unit_test { - -namespace ut_detail { - -// ************************************************************************** // -// ************** test_case_template_invoker ************** // -// ************************************************************************** // - -template -class test_case_template_invoker { -public: - void operator()() { TestCaseTemplate::run( (boost::type*)0 ); } -}; - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** generate_test_case_4_type ************** // -// ************************************************************************** // - -template -struct generate_test_case_4_type { - explicit generate_test_case_4_type( const_string tc_name, Generator& G ) - : m_test_case_name( tc_name ) - , m_holder( G ) - {} - - template - void operator()( mpl::identity ) - { - std::string full_name; - assign_op( full_name, m_test_case_name, 0 ); - full_name += '<'; - full_name += typeid(TestType).name(); - if( boost::is_const::value ) - full_name += " const"; - full_name += '>'; - - m_holder.m_test_cases.push_back( - new test_case( full_name, test_case_template_invoker() ) ); - } - -private: - // Data members - const_string m_test_case_name; - Generator& m_holder; -}; - -// ************************************************************************** // -// ************** test_case_template ************** // -// ************************************************************************** // - -template -class template_test_case_gen : public test_unit_generator { -public: - // Constructor - template_test_case_gen( const_string tc_name ) - { - typedef generate_test_case_4_type, - TestCaseTemplate - > single_test_gen; - mpl::for_each >( single_test_gen( tc_name, *this ) ); - } - - test_unit* next() const - { - if( m_test_cases.empty() ) - return 0; - - test_unit* res = m_test_cases.front(); - m_test_cases.pop_front(); - - return res; - } - - // Data members - mutable std::list m_test_cases; -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -} // unit_test - -} // namespace boost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_TEST_CASE_TEMPLATE_HPP_071894GER - +#include diff --git a/include/boost/test/test_tools.hpp b/include/boost/test/test_tools.hpp index 75d37894..2800ac06 100644 --- a/include/boost/test/test_tools.hpp +++ b/include/boost/test/test_tools.hpp @@ -78,7 +78,7 @@ P, \ ::boost::unit_test::lazy_ostream::instance() << check_descr, \ BOOST_TEST_L(__FILE__), \ - (std::size_t)__LINE__, \ + static_cast(__LINE__), \ ::boost::test_tools::tt_detail::TL, \ ::boost::test_tools::tt_detail::CT \ /**/ @@ -306,7 +306,7 @@ namespace test_tools { typedef unit_test::const_string const_string; -namespace { bool const dummy_cond = false; } +namespace { bool dummy_cond = false; } // ************************************************************************** // // ************** print_log_value ************** // @@ -319,9 +319,9 @@ struct print_log_value { // 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 couldnt_use_nl; + typedef typename mpl::or_,is_function,is_abstract >::type cant_use_nl; - set_precision( ostr, couldnt_use_nl() ); + set_precision( ostr, cant_use_nl() ); ostr << t; // by default print the value } @@ -485,15 +485,15 @@ bool check_impl( predicate_result const& pr, ::boost::unit_test::lazy_ostream co #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 ) \ + , 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 ) \ - , &(const unit_test::lazy_ostream&)(unit_test::lazy_ostream::instance() \ + , 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 ) )) \ /**/ @@ -539,15 +539,15 @@ predicate_result equal_impl( Left const& left, Right const& 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( (char const*)left, (char const*)right ); } -inline predicate_result equal_impl( char const* left, char* right ) { return equal_impl( (char const*)left, (char const*)right ); } -inline predicate_result equal_impl( char* left, char* right ) { return 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( (wchar_t const*)left, (wchar_t const*)right ); } -inline predicate_result equal_impl( wchar_t const* left, wchar_t* right ) { return equal_impl( (wchar_t const*)left, (wchar_t const*)right ); } -inline predicate_result equal_impl( wchar_t* left, wchar_t* right ) { return 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 //____________________________________________________________________________// diff --git a/include/boost/test/unit_test_log.hpp b/include/boost/test/unit_test_log.hpp index 98006849..8d9eac6a 100644 --- a/include/boost/test/unit_test_log.hpp +++ b/include/boost/test/unit_test_log.hpp @@ -157,7 +157,7 @@ BOOST_TEST_SINGLETON_INST( unit_test_log ) #define BOOST_TEST_PASSPOINT() \ ::boost::unit_test::unit_test_log.set_checkpoint( \ BOOST_TEST_L(__FILE__), \ - (std::size_t)__LINE__ ) \ + static_cast(__LINE__) ) \ /**/ //____________________________________________________________________________// @@ -165,7 +165,7 @@ BOOST_TEST_SINGLETON_INST( unit_test_log ) #define BOOST_TEST_CHECKPOINT( M ) \ ::boost::unit_test::unit_test_log.set_checkpoint( \ BOOST_TEST_L(__FILE__), \ - (std::size_t)__LINE__, \ + static_cast(__LINE__), \ (::boost::wrap_stringstream().ref() << M).str() ) \ /**/ diff --git a/include/boost/test/unit_test_suite.hpp b/include/boost/test/unit_test_suite.hpp index 07026cb7..94f09297 100644 --- a/include/boost/test/unit_test_suite.hpp +++ b/include/boost/test/unit_test_suite.hpp @@ -17,7 +17,6 @@ // Boost.Test #include -#include #include //____________________________________________________________________________// @@ -143,6 +142,35 @@ template \ void test_name::test_method() \ /**/ +// ************************************************************************** // +// ************** BOOST_TEST_CASE_TEMPLATE ************** // +// ************************************************************************** // + +#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* ) \ +/**/ + // ************************************************************************** // // ************** BOOST_GLOBAL_FIXURE ************** // // ************************************************************************** // @@ -163,7 +191,7 @@ struct nil_t {}; } // unit_test } // namespace boost -// Intentionally is in global namespace, so that FIXURE_TEST_SUITE could reset it in user code. +// Intentionally is in global namespace, so that FIXURE_TEST_SUITE can reset it in user code. typedef ::boost::unit_test::ut_detail::nil_t 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 5713b97b..e3573dd9 100644 --- a/include/boost/test/unit_test_suite_impl.hpp +++ b/include/boost/test/unit_test_suite_impl.hpp @@ -26,8 +26,13 @@ // Boost #include +#include +#include +#include +#include // STL +#include // for typeid #include // for std::string #include // for std::list #include // for std::vector @@ -342,6 +347,81 @@ private: F* m_fixure; }; +// ************************************************************************** // +// ************** test_case_template_invoker ************** // +// ************************************************************************** // + +template +class test_case_template_invoker { +public: + void operator()() { TestCaseTemplate::run( (boost::type*)0 ); } +}; + +// ************************************************************************** // +// ************** generate_test_case_4_type ************** // +// ************************************************************************** // + +template +struct generate_test_case_4_type { + explicit generate_test_case_4_type( const_string tc_name, Generator& G ) + : m_test_case_name( tc_name ) + , m_holder( G ) + {} + + template + void operator()( mpl::identity ) + { + std::string full_name; + assign_op( full_name, m_test_case_name, 0 ); + full_name += '<'; + full_name += typeid(TestType).name(); + if( boost::is_const::value ) + full_name += " const"; + full_name += '>'; + + m_holder.m_test_cases.push_back( + new test_case( full_name, test_case_template_invoker() ) ); + } + +private: + // Data members + const_string m_test_case_name; + Generator& m_holder; +}; + +// ************************************************************************** // +// ************** test_case_template ************** // +// ************************************************************************** // + +template +class template_test_case_gen : public test_unit_generator { +public: + // Constructor + template_test_case_gen( const_string tc_name ) + { + typedef generate_test_case_4_type, + TestCaseTemplate + > single_test_gen; + mpl::for_each >( single_test_gen( tc_name, *this ) ); + } + + virtual test_unit* next() const + { + if( m_test_cases.empty() ) + return 0; + + test_unit* res = m_test_cases.front(); + m_test_cases.pop_front(); + + return res; + } + + // Data members + mutable std::list m_test_cases; +}; + +//____________________________________________________________________________// + } // namespace ut_detail } // unit_test diff --git a/include/boost/test/utils/basic_cstring/basic_cstring.hpp b/include/boost/test/utils/basic_cstring/basic_cstring.hpp index b071df51..7eb19d9b 100644 --- a/include/boost/test/utils/basic_cstring/basic_cstring.hpp +++ b/include/boost/test/utils/basic_cstring/basic_cstring.hpp @@ -57,7 +57,7 @@ public: // !! should also present reverse_iterator, const_reverse_iterator #if !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) - enum npos_type { npos = (size_type)-1 }; + enum npos_type { npos = static_cast(-1) }; #else // IBM/VisualAge version 6 is not able to handle enums larger than 4 bytes. // But size_type is 8 bytes in 64bit mode. @@ -218,7 +218,7 @@ inline typename basic_cstring::value_type basic_cstring::at( size_type index ) const { if( m_begin + index >= m_end ) - return (value_type)0; + return static_cast(0); return m_begin[index]; } @@ -306,7 +306,7 @@ basic_cstring::trim_left( basic_cstring exclusions ) iterator it; for( it = begin(); it != end(); ++it ) { - if( traits_type::find( exclusions.begin(), exclusions.size(), *it ) == (pointer)0 ) + if( traits_type::find( exclusions.begin(), exclusions.size(), *it ) == reinterpret_cast(0) ) break; } @@ -351,7 +351,7 @@ basic_cstring::trim_right( basic_cstring exclusions ) iterator it; for( it = end()-1; it != begin()-1; --it ) { - if( self_type::traits_type::find( exclusions.begin(), exclusions.size(), *it ) == (pointer)0 ) + if( self_type::traits_type::find( exclusions.begin(), exclusions.size(), *it ) == reinterpret_cast(0) ) break; } @@ -514,7 +514,7 @@ inline typename basic_cstring::size_type basic_cstring::find( basic_cstring str ) const { if( str.is_empty() || str.size() > size() ) - return (size_type)npos; + return static_cast(npos); const_iterator it = begin(); const_iterator last = end() - str.size() + 1; @@ -526,7 +526,7 @@ basic_cstring::find( basic_cstring str ) const ++it; } - return it == last ? (size_type)npos : it - begin(); + return it == last ? static_cast(npos) : it - begin(); } //____________________________________________________________________________// @@ -536,7 +536,7 @@ inline typename basic_cstring::size_type basic_cstring::rfind( basic_cstring str ) const { if( str.is_empty() || str.size() > size() ) - return (size_type)npos; + return static_cast(npos); const_iterator it = end() - str.size(); const_iterator last = begin()-1; @@ -687,7 +687,7 @@ first_char( basic_cstring source ) { typedef typename basic_cstring::value_type string_value_type; - return source.is_empty() ? (string_value_type)0 : *source.begin(); + return source.is_empty() ? static_cast(0) : *source.begin(); } //____________________________________________________________________________// @@ -702,7 +702,7 @@ last_char( basic_cstring source ) { typedef typename basic_cstring::value_type string_value_type; - return source.is_empty() ? (string_value_type)0 : *(source.end()-1); + return source.is_empty() ? static_cast(0) : *(source.end()-1); } //____________________________________________________________________________// diff --git a/include/boost/test/utils/class_properties.hpp b/include/boost/test/utils/class_properties.hpp index 33b0716a..d2070dc9 100644 --- a/include/boost/test/utils/class_properties.hpp +++ b/include/boost/test/utils/class_properties.hpp @@ -48,11 +48,7 @@ class class_property { protected: typedef typename call_traits::const_reference read_access_t; typedef typename call_traits::param_type write_param_t; -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)) - typedef typename add_pointer::type address_res_t; -#else typedef typename add_pointer::type>::type address_res_t; -#endif public: // Constructor class_property() : value( PropertyType() ) {} diff --git a/include/boost/test/utils/fixed_mapping.hpp b/include/boost/test/utils/fixed_mapping.hpp index cbf61560..e8139337 100644 --- a/include/boost/test/utils/fixed_mapping.hpp +++ b/include/boost/test/utils/fixed_mapping.hpp @@ -36,7 +36,7 @@ namespace boost { namespace unit_test { // configurable maximum fixed sized mapping size supported by this header. -// You could redefine it before inclusion of this file. +// You can redefine it before inclusion of this file. #ifndef MAX_MAP_SIZE #define MAX_MAP_SIZE 20 #endif diff --git a/include/boost/test/utils/foreach.hpp b/include/boost/test/utils/foreach.hpp index dc811247..da32ae30 100644 --- a/include/boost/test/utils/foreach.hpp +++ b/include/boost/test/utils/foreach.hpp @@ -11,7 +11,7 @@ // Version : $Revision$ // // Description : this is an abridged version of an excelent BOOST_FOREACH facility -// presented by Eric Niebler. I am so fond of it so I couldn't wait till it +// presented by Eric Niebler. I am so fond of it so I can't wait till it // going to be accepted into Boost. Also I need version with less number of dependencies // and more portable. This version doesn't support rvalues and will reeveluate it's // parameters, but should be good enough for my purposes. diff --git a/include/boost/test/utils/iterator/token_iterator.hpp b/include/boost/test/utils/iterator/token_iterator.hpp index d3505026..00150784 100644 --- a/include/boost/test/utils/iterator/token_iterator.hpp +++ b/include/boost/test/utils/iterator/token_iterator.hpp @@ -192,7 +192,7 @@ protected: : m_is_dropped( dt_isspace ) , m_is_kept( dt_ispunct ) , m_keep_empty_tokens( false ) - , m_tokens_left( (std::size_t)-1 ) + , m_tokens_left( static_cast(-1) ) , m_token_produced( false ) { } diff --git a/include/boost/test/utils/named_params.hpp b/include/boost/test/utils/named_params.hpp index b727f208..0a6277ce 100644 --- a/include/boost/test/utils/named_params.hpp +++ b/include/boost/test/utils/named_params.hpp @@ -23,6 +23,8 @@ #include #include +#include + #include //____________________________________________________________________________// @@ -64,9 +66,17 @@ report_access_to_invalid_parameter() struct nil { template +#if defined(__GNUC__) || defined(__HP_aCC) || defined(__EDG__) || defined(__SUNPRO_CC) operator T() const +#else + operator T const&() const +#endif { report_access_to_invalid_parameter(); static T* v = 0; return *v; } + template + T any_cast() const + { report_access_to_invalid_parameter(); static typename remove_reference::type* v = 0; return *v; } + template nil operator()( Arg1 const& ) { report_access_to_invalid_parameter(); return nil(); } @@ -82,6 +92,10 @@ struct nil { // Visitation support template void apply_to( Visitor& V ) const {} + + static nil& inst() { static nil s_inst; return s_inst; } +private: + nil() {} }; // ************************************************************************** // @@ -102,23 +116,31 @@ struct named_parameter_base { // ************************************************************************** // template -struct named_parameter_combine : Rest, named_parameter_base > { +struct named_parameter_combine +: Rest +, named_parameter_base > { typedef typename NP::ref_type res_type; typedef named_parameter_combine self_type; // Constructor named_parameter_combine( NP const& np, Rest const& r ) - : Rest( r ), m_param( np ) {} + : Rest( r ) + , m_param( np ) + {} // Access methods res_type operator[]( keyword kw ) const { return m_param[kw]; } res_type operator[]( keyword kw ) const { return m_param[kw]; } using Rest::operator[]; - bool has( keyword ) const { return true; } + bool has( keyword kw ) const { return m_param.has( kw ); } using Rest::has; -#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) + void erase( keyword kw ) const { m_param.erase( kw ); } + using Rest::erase; + +#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) || \ + BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0610)) template named_parameter_combine operator,( NP const& np ) const { return named_parameter_combine( np, *this ); } @@ -142,30 +164,42 @@ private: } // namespace nfp_detail // ************************************************************************** // -// ************** named_parameter_combine ************** // +// ************** named_parameter ************** // // ************************************************************************** // template struct named_parameter : nfp_detail::named_parameter_base > { + typedef nfp_detail::nil nil_t; typedef T data_type; typedef ReferenceType ref_type; typedef unique_id id; // Constructor - explicit named_parameter( ref_type v ) : m_value( v ) {} + explicit named_parameter( ref_type v ) + : m_value( v ) + , m_erased( false ) + {} + named_parameter( named_parameter const& np ) + : m_value( np.m_value ) + , m_erased( np.m_erased ) + {} // Access methods - ref_type operator[]( keyword ) const { return m_value; } - ref_type operator[]( keyword ) const { return m_value; } + ref_type operator[]( keyword ) const { return m_erased ? nil_t::inst().template any_cast() : m_value; } + ref_type operator[]( keyword ) const { return m_erased ? nil_t::inst().template any_cast() : m_value; } template - nfp_detail::nil operator[]( keyword ) const { return nfp_detail::nil(); } + nil_t operator[]( keyword ) const { return nil_t::inst(); } - bool has( keyword ) const { return true; } + bool has( keyword ) const { return !m_erased; } template bool has( keyword ) const { return false; } + void erase( keyword ) const { m_erased = true; } + template + void erase( keyword ) const {} + // Visitation support template void apply_to( Visitor& V ) const @@ -176,6 +210,7 @@ struct named_parameter private: // Data members ref_type m_value; + mutable bool m_erased; }; //____________________________________________________________________________// @@ -186,7 +221,7 @@ private: namespace nfp_detail { typedef named_parameter no_params_type; -} +} // namespace nfp_detail namespace { nfp_detail::no_params_type no_params( '\0' ); @@ -269,7 +304,7 @@ optionally_assign( T& target, Source const& src ) { using namespace unit_test; - assign_op( target, src, 0 ); + assign_op( target, src, static_cast(0) ); } //____________________________________________________________________________// diff --git a/include/boost/test/utils/runtime/argument.hpp b/include/boost/test/utils/runtime/argument.hpp index 2bf10adf..a2d229e6 100644 --- a/include/boost/test/utils/runtime/argument.hpp +++ b/include/boost/test/utils/runtime/argument.hpp @@ -35,10 +35,15 @@ namespace BOOST_RT_PARAM_NAMESPACE { // ************** runtime::argument ************** // // ************************************************************************** // +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable:4244) +#endif + class argument { public: // Constructor - argument( parameter const& p, rtti::id_t value_type ) + argument( parameter const& p, call_traits::param_type value_type ) : p_formal_parameter( p ) , p_value_type( value_type ) {} @@ -94,6 +99,10 @@ arg_value( argument& arg ) return static_cast&>( arg ).p_value.value; } +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + //____________________________________________________________________________// } // namespace BOOST_RT_PARAM_NAMESPACE diff --git a/include/boost/test/utils/runtime/cla/argument_factory.hpp b/include/boost/test/utils/runtime/cla/argument_factory.hpp index 13c30cca..ffa86cc7 100644 --- a/include/boost/test/utils/runtime/cla/argument_factory.hpp +++ b/include/boost/test/utils/runtime/cla/argument_factory.hpp @@ -147,16 +147,16 @@ typed_argument_factory::produce_using( parameter& p, argv_traverser& tr ) m_value_handler( p, *value ); if( !p.p_multiplicable ) - arg.reset( p.p_optional_value - ? (argument*)new typed_argument >( p, value ) - : (argument*)new typed_argument( p, *value ) ); + arg.reset( p.p_optional_value && (rtti::type_id() != rtti::type_id()) + ? static_cast(new typed_argument >( p, value )) + : static_cast(new typed_argument( p, *value )) ); else { typedef std::list > optional_list; if( !arg ) arg.reset( p.p_optional_value - ? (argument*)new typed_argument( p ) - : (argument*)new typed_argument >( p ) ); + ? static_cast(new typed_argument( p )) + : static_cast(new typed_argument >( p )) ); if( p.p_optional_value ) { optional_list& values = arg_value( *arg ); @@ -204,7 +204,7 @@ template inline void typed_argument_factory::argument_usage_info( format_stream& fs ) { - rt_cla_detail::argument_value_usage( fs, 0, (T*)0 ); + rt_cla_detail::argument_value_usage( fs, 0, reinterpret_cast(0) ); } //____________________________________________________________________________// diff --git a/include/boost/test/utils/runtime/cla/basic_parameter.hpp b/include/boost/test/utils/runtime/cla/basic_parameter.hpp index 43d12f5a..8b826bba 100644 --- a/include/boost/test/utils/runtime/cla/basic_parameter.hpp +++ b/include/boost/test/utils/runtime/cla/basic_parameter.hpp @@ -23,6 +23,9 @@ // Boost.Test #include +// Boost +#include + namespace boost { namespace BOOST_RT_PARAM_NAMESPACE { @@ -34,11 +37,12 @@ namespace cla { // ************************************************************************** // template -class basic_parameter : public typed_parameter { +class basic_parameter : private base_from_member, public typed_parameter { public: // Constructors explicit basic_parameter( cstring n ) - : typed_parameter( m_id_policy ) + : base_from_member() + , typed_parameter( base_from_member::member ) { this->accept_modifier( name = n ); } @@ -49,11 +53,8 @@ public: { typed_parameter::accept_modifier( m ); - m_id_policy.accept_modifier( m ); + base_from_member::member.accept_modifier( m ); } - -private: - IdPolicy m_id_policy; }; //____________________________________________________________________________// diff --git a/include/boost/test/utils/runtime/cla/char_parameter.hpp b/include/boost/test/utils/runtime/cla/char_parameter.hpp index c7040998..425c24f3 100644 --- a/include/boost/test/utils/runtime/cla/char_parameter.hpp +++ b/include/boost/test/utils/runtime/cla/char_parameter.hpp @@ -47,7 +47,7 @@ public: { basic_naming_policy::accept_modifier( m ); - BOOST_RT_PARAM_VALIDATE_LOGIC( m_name.size() <= 1, "Invalid parameter name " << m_name ); + BOOST_RT_PARAM_VALIDATE_LOGIC( p_name->size() <= 1, "Invalid parameter name " << p_name ); } }; diff --git a/include/boost/test/utils/runtime/cla/char_parameter.ipp b/include/boost/test/utils/runtime/cla/char_parameter.ipp index ab0375e6..db4d0c1e 100644 --- a/include/boost/test/utils/runtime/cla/char_parameter.ipp +++ b/include/boost/test/utils/runtime/cla/char_parameter.ipp @@ -34,7 +34,7 @@ BOOST_RT_PARAM_INLINE char_name_policy::char_name_policy() : basic_naming_policy( rtti::type_id() ) { - assign_op( m_prefix, BOOST_RT_PARAM_CSTRING_LITERAL( "-" ), 0 ); + assign_op( p_prefix.value, BOOST_RT_PARAM_CSTRING_LITERAL( "-" ), 0 ); } //____________________________________________________________________________// @@ -43,7 +43,7 @@ BOOST_RT_PARAM_INLINE bool char_name_policy::conflict_with( identification_policy const& id ) const { return id.p_type_id == p_type_id && - m_name == static_cast( id ).m_name; + p_name == static_cast( id ).p_name; } //____________________________________________________________________________// diff --git a/include/boost/test/utils/runtime/cla/detail/argument_value_usage.hpp b/include/boost/test/utils/runtime/cla/detail/argument_value_usage.hpp index d7f030f7..0d595956 100644 --- a/include/boost/test/utils/runtime/cla/detail/argument_value_usage.hpp +++ b/include/boost/test/utils/runtime/cla/detail/argument_value_usage.hpp @@ -27,7 +27,7 @@ #include // STL -// !! could we eliminate these includes? +// !! can we eliminate these includes? #include namespace boost { @@ -66,7 +66,7 @@ argument_value_usage( format_stream& fs, int, std::list* = 0 ) inline void argument_value_usage( format_stream& fs, int, bool* = 0 ) { - fs << BOOST_RT_PARAM_CSTRING_LITERAL( "[yes|y|no|n]" ); + fs << BOOST_RT_PARAM_CSTRING_LITERAL( "yes|y|no|n" ); } //____________________________________________________________________________// diff --git a/include/boost/test/utils/runtime/cla/dual_name_parameter.hpp b/include/boost/test/utils/runtime/cla/dual_name_parameter.hpp index a211d5d3..26ac657c 100644 --- a/include/boost/test/utils/runtime/cla/dual_name_parameter.hpp +++ b/include/boost/test/utils/runtime/cla/dual_name_parameter.hpp @@ -35,18 +35,26 @@ class dual_name_policy : public dual_id_policy void accept_modifier( Modifier const& m ) { - if( m.has( prefix ) ) + if( m.has( prefix ) ) { set_prefix( m[prefix] ); + m.erase( prefix ); + } - if( m.has( name ) ) + if( m.has( name ) ) { set_name( m[name] ); + m.erase( name ); + } - if( m.has( separator ) ) + if( m.has( separator ) ) { set_separator( m[separator] ); + m.erase( separator ); + } + + dual_id_policy::accept_modifier( m ); } private: void set_prefix( cstring ); diff --git a/include/boost/test/utils/runtime/cla/id_policy.hpp b/include/boost/test/utils/runtime/cla/id_policy.hpp index 515abf55..30d48f77 100644 --- a/include/boost/test/utils/runtime/cla/id_policy.hpp +++ b/include/boost/test/utils/runtime/cla/id_policy.hpp @@ -41,23 +41,28 @@ namespace cla { class basic_naming_policy : public identification_policy { public: + // Public properties + unit_test::readwrite_property p_prefix; + unit_test::readwrite_property p_name; + unit_test::readwrite_property p_separator; + // Policy interface - virtual bool responds_to( cstring name ) const { return m_name == name; } - virtual cstring id_2_report() const { return m_name; } + virtual bool responds_to( cstring name ) const { return p_name == name; } + virtual cstring id_2_report() const { return p_name.get(); } virtual void usage_info( format_stream& fs ) const; virtual bool matching( parameter const& p, argv_traverser& tr, bool primary ) const; - // Accept modifer + // Accept modifier template void accept_modifier( Modifier const& m ) { - nfp::optionally_assign( m_prefix, m, prefix ); - nfp::optionally_assign( m_name, m, name ); - nfp::optionally_assign( m_separator, m, separator ); + nfp::optionally_assign( p_prefix.value, m, prefix ); + nfp::optionally_assign( p_name.value, m, name ); + nfp::optionally_assign( p_separator.value, m, separator ); } protected: - explicit basic_naming_policy( rtti::id_t const& dyn_type ) + explicit basic_naming_policy( call_traits::param_type dyn_type ) : identification_policy( dyn_type ) {} BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~basic_naming_policy() {} @@ -65,12 +70,7 @@ protected: // Naming policy interface virtual bool match_prefix( argv_traverser& tr ) const; virtual bool match_name( argv_traverser& tr ) const; - virtual bool match_separator( argv_traverser& tr ) const; - - // Data members - dstring m_prefix; - dstring m_name; - dstring m_separator; + virtual bool match_separator( argv_traverser& tr, bool optional_value ) const; }; // ************************************************************************** // @@ -94,7 +94,7 @@ public: } virtual bool conflict_with( identification_policy const& id_p ) const { - return m_primary.conflict_with( id_p ) || m_secondary.conflict_with( id_p ); + return id_p.conflict_with( m_primary ) || id_p.conflict_with( m_secondary ); } virtual cstring id_2_report() const { @@ -113,6 +113,14 @@ public: return m_primary.matching( p, tr, primary ) || m_secondary.matching( p, tr, primary ); } + // Accept modifier + template + void accept_modifier( Modifier const& m ) + { + m_primary.accept_modifier( m ); + m_secondary.accept_modifier( m ); + } + protected: BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~dual_id_policy() {} diff --git a/include/boost/test/utils/runtime/cla/id_policy.ipp b/include/boost/test/utils/runtime/cla/id_policy.ipp index 7efafaa7..5498b9a8 100644 --- a/include/boost/test/utils/runtime/cla/id_policy.ipp +++ b/include/boost/test/utils/runtime/cla/id_policy.ipp @@ -19,6 +19,7 @@ #include #include +#include namespace boost { @@ -33,9 +34,9 @@ namespace cla { BOOST_RT_PARAM_INLINE void basic_naming_policy::usage_info( format_stream& fs ) const { - fs << m_prefix << m_name << m_separator; + fs << p_prefix << p_name << p_separator; - if( m_separator.empty() ) + if( p_separator->empty() ) fs << BOOST_RT_PARAM_LITERAL( ' ' ); } @@ -44,10 +45,10 @@ basic_naming_policy::usage_info( format_stream& fs ) const BOOST_RT_PARAM_INLINE bool basic_naming_policy::match_prefix( argv_traverser& tr ) const { - if( !tr.match_front( m_prefix ) ) + if( !tr.match_front( p_prefix.get() ) ) return false; - tr.trim( m_prefix.size() ); + tr.trim( p_prefix->size() ); return true; } @@ -56,29 +57,34 @@ basic_naming_policy::match_prefix( argv_traverser& tr ) const BOOST_RT_PARAM_INLINE bool basic_naming_policy::match_name( argv_traverser& tr ) const { - if( !tr.match_front( m_name ) ) + if( !tr.match_front( p_name.get() ) ) return false; - tr.trim( m_name.size() ); + tr.trim( p_name->size() ); return true; } //____________________________________________________________________________// BOOST_RT_PARAM_INLINE bool -basic_naming_policy::match_separator( argv_traverser& tr ) const +basic_naming_policy::match_separator( argv_traverser& tr, bool optional_value ) const { - if( m_separator.empty() ) { + if( p_separator->empty() ) { if( !tr.token().is_empty() ) return false; tr.trim( 1 ); } else { - if( !tr.match_front( m_separator ) ) + if( !tr.match_front( p_separator.get() ) ) { + // if parameter has optional value separator is optional as well + if( optional_value && ( tr.eoi() || tr.match_front( ' ' ) ) ) { + return true; + } return false; + } - tr.trim( m_separator.size() ); + tr.trim( p_separator->size() ); } return true; @@ -87,7 +93,7 @@ basic_naming_policy::match_separator( argv_traverser& tr ) const //____________________________________________________________________________// BOOST_RT_PARAM_INLINE bool -basic_naming_policy::matching( parameter const&, argv_traverser& tr, bool ) const +basic_naming_policy::matching( parameter const& p, argv_traverser& tr, bool ) const { if( !match_prefix( tr ) ) return false; @@ -95,7 +101,7 @@ basic_naming_policy::matching( parameter const&, argv_traverser& tr, bool ) cons if( !match_name( tr ) ) return false; - if( !match_separator( tr ) ) + if( !match_separator( tr, p.p_optional_value ) ) return false; return true; diff --git a/include/boost/test/utils/runtime/cla/iface/argument_factory.hpp b/include/boost/test/utils/runtime/cla/iface/argument_factory.hpp index 7287826c..03669e0c 100644 --- a/include/boost/test/utils/runtime/cla/iface/argument_factory.hpp +++ b/include/boost/test/utils/runtime/cla/iface/argument_factory.hpp @@ -30,7 +30,7 @@ namespace cla { // ************************************************************************** // // ************** argument_factory ************** // // ************************************************************************** // -// another name could be argument production policy +// another name can be argument production policy class argument_factory { public: diff --git a/include/boost/test/utils/runtime/cla/iface/id_policy.hpp b/include/boost/test/utils/runtime/cla/iface/id_policy.hpp index 93a8be96..9c1287e5 100644 --- a/include/boost/test/utils/runtime/cla/iface/id_policy.hpp +++ b/include/boost/test/utils/runtime/cla/iface/id_policy.hpp @@ -34,6 +34,11 @@ namespace cla { // ************** identification_policy ************** // // ************************************************************************** // +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable:4244) +#endif + class identification_policy { public: // Public properties @@ -49,12 +54,16 @@ public: protected: // Constructor - explicit identification_policy( rtti::id_t const& dyn_type ) + explicit identification_policy( call_traits::param_type dyn_type ) : p_type_id( dyn_type ) {} BOOST_TEST_PROTECTED_VIRTUAL ~identification_policy() {} }; +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + } // namespace cla } // namespace BOOST_RT_PARAM_NAMESPACE diff --git a/include/boost/test/utils/runtime/cla/modifier.hpp b/include/boost/test/utils/runtime/cla/modifier.hpp index c43d786c..08924e2f 100644 --- a/include/boost/test/utils/runtime/cla/modifier.hpp +++ b/include/boost/test/utils/runtime/cla/modifier.hpp @@ -34,17 +34,17 @@ namespace cla { namespace { nfp::typed_keyword optional_m; -nfp::named_parameter optional( true ); +nfp::named_parameter optional( true ); nfp::typed_keyword required_m; -nfp::named_parameter required( true ); +nfp::named_parameter required( true ); nfp::typed_keyword multiplicable_m; -nfp::named_parameter multiplicable( true ); +nfp::named_parameter multiplicable( true ); nfp::typed_keyword guess_name_m; -nfp::named_parameter guess_name( true ); +nfp::named_parameter guess_name( true ); nfp::typed_keyword ignore_mismatch_m; -nfp::named_parameter ignore_mismatch( true ); +nfp::named_parameter ignore_mismatch( true ); nfp::typed_keyword optional_value_m; -nfp::named_parameter optional_value( true ); +nfp::named_parameter optional_value( true ); nfp::typed_keyword input_separator; nfp::typed_keyword prefix; diff --git a/include/boost/test/utils/runtime/cla/named_parameter.ipp b/include/boost/test/utils/runtime/cla/named_parameter.ipp index 9fa40e74..e04348f5 100644 --- a/include/boost/test/utils/runtime/cla/named_parameter.ipp +++ b/include/boost/test/utils/runtime/cla/named_parameter.ipp @@ -39,7 +39,7 @@ string_name_policy::string_name_policy() : basic_naming_policy( rtti::type_id() ) , m_guess_name( false ) { - assign_op( m_prefix, BOOST_RT_PARAM_CSTRING_LITERAL( "-" ), 0 ); + assign_op( p_prefix.value, BOOST_RT_PARAM_CSTRING_LITERAL( "-" ), 0 ); } //____________________________________________________________________________// @@ -49,39 +49,53 @@ string_name_policy::responds_to( cstring name ) const { std::pair mm_pos; - mm_pos = unit_test::mismatch( name.begin(), name.end(), m_name.begin(), m_name.end() ); + mm_pos = unit_test::mismatch( name.begin(), name.end(), p_name->begin(), p_name->end() ); - return mm_pos.first == name.end() && (m_guess_name || (mm_pos.second == m_name.end()) ); + return mm_pos.first == name.end() && (m_guess_name || (mm_pos.second == p_name->end()) ); } //____________________________________________________________________________// +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable:4244) +#endif + BOOST_RT_PARAM_INLINE bool string_name_policy::conflict_with( identification_policy const& id ) const { if( id.p_type_id == p_type_id ) { string_name_policy const& snp = static_cast( id ); - if( m_name.empty() || snp.m_name.empty() ) + if( p_name->empty() || snp.p_name->empty() ) + return false; + + if( p_prefix != snp.p_prefix ) return false; std::pair mm_pos = - unit_test::mismatch( m_name.begin(), m_name.end(), snp.m_name.begin(), snp.m_name.end() ); + unit_test::mismatch( p_name->begin(), p_name->end(), snp.p_name->begin(), snp.p_name->end() ); - return mm_pos.first != m_name.begin() && // there is common substring - (m_guess_name || (mm_pos.first == m_name.end()) ) && // that match me - (snp.m_guess_name || (mm_pos.second == snp.m_name.end()) ); // and snp + return mm_pos.first != p_name->begin() && // there is common substring + ((m_guess_name && (mm_pos.second == snp.p_name->end()) ) || // that match other guy and I am guessing + (snp.m_guess_name && (mm_pos.first == p_name->end()) )); // or me and the other guy is } if( id.p_type_id == rtti::type_id() ) { char_name_policy const& cnp = static_cast( id ); - - return m_guess_name && unit_test::first_char( cstring( m_name ) ) == unit_test::first_char( cnp.id_2_report() ); + + return m_guess_name && + (p_prefix == cnp.p_prefix) && + unit_test::first_char( cstring( p_name ) ) == unit_test::first_char( cstring( cnp.p_name ) ); } return false; } +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + //____________________________________________________________________________// BOOST_RT_PARAM_INLINE bool @@ -89,18 +103,17 @@ string_name_policy::match_name( argv_traverser& tr ) const { if( !m_guess_name ) return basic_naming_policy::match_name( tr ); - else { - cstring in = tr.input(); - std::pair mm_pos; - - mm_pos = unit_test::mismatch( in.begin(), in.end(), m_name.begin(), m_name.end() ); + cstring in = tr.input(); - if( mm_pos.first == in.begin() ) - return false; + std::pair mm_pos; + + mm_pos = unit_test::mismatch( in.begin(), in.end(), p_name->begin(), p_name->end() ); - tr.trim( mm_pos.first - in.begin() ); - } + if( mm_pos.first == in.begin() ) + return false; + + tr.trim( mm_pos.first - in.begin() ); return true; } diff --git a/include/boost/test/utils/runtime/cla/parameter.hpp b/include/boost/test/utils/runtime/cla/parameter.hpp index 0caf0935..623617b5 100644 --- a/include/boost/test/utils/runtime/cla/parameter.hpp +++ b/include/boost/test/utils/runtime/cla/parameter.hpp @@ -42,10 +42,10 @@ namespace cla { class parameter : public BOOST_RT_PARAM_NAMESPACE::parameter { public: - parameter( identification_policy& ID, argument_factory& F ) + parameter( identification_policy& ID, argument_factory& F, bool optional_value = false ) : p_optional( false ) , p_multiplicable( false ) - , p_optional_value( false ) + , p_optional_value( optional_value ) , m_id_policy( ID ) , m_arg_factory( F ) {} @@ -89,7 +89,7 @@ public: { return (id_2_report() == p.id_2_report() && !id_2_report().is_empty()) || m_id_policy.conflict_with( p.m_id_policy ) || - p.m_id_policy.conflict_with( m_id_policy ); + ((m_id_policy.p_type_id != p.m_id_policy.p_type_id) && p.m_id_policy.conflict_with( m_id_policy )); } cstring id_2_report() const { return m_id_policy.id_2_report(); } void usage_info( format_stream& fs ) const @@ -113,7 +113,7 @@ public: // argument production based on different source void produce_argument( argv_traverser& tr ) { - m_id_policy.matching( *this, tr, true ); // !! could we save this position somehow + m_id_policy.matching( *this, tr, true ); // !! can we save this position somehow m_actual_argument = m_arg_factory.produce_using( *this, tr ); } void produce_argument( parser const& p ) diff --git a/include/boost/test/utils/runtime/cla/parser.hpp b/include/boost/test/utils/runtime/cla/parser.hpp index 91800abd..4b8dcf88 100644 --- a/include/boost/test/utils/runtime/cla/parser.hpp +++ b/include/boost/test/utils/runtime/cla/parser.hpp @@ -64,7 +64,7 @@ public: private: // Data members; parser& m_parser; - Modifier const& m_modifiers; + Modifier const& m_modifiers; }; } diff --git a/include/boost/test/utils/runtime/cla/parser.ipp b/include/boost/test/utils/runtime/cla/parser.ipp index 38fbee08..188d3031 100644 --- a/include/boost/test/utils/runtime/cla/parser.ipp +++ b/include/boost/test/utils/runtime/cla/parser.ipp @@ -83,8 +83,7 @@ BOOST_RT_PARAM_INLINE parser& parser::operator<<( parameter_ptr new_param ) { BOOST_TEST_FOREACH( parameter_ptr, old_param, m_parameters ) { - BOOST_RT_PARAM_VALIDATE_LOGIC( !old_param->conflict_with( *new_param ) && - !new_param->conflict_with( *old_param ), + BOOST_RT_PARAM_VALIDATE_LOGIC( !old_param->conflict_with( *new_param ), BOOST_RT_PARAM_LITERAL( "Definition of parameter " ) << new_param->id_2_report() << BOOST_RT_PARAM_LITERAL( " conflicts with defintion of parameter " ) << old_param->id_2_report() ); } @@ -103,7 +102,7 @@ parser::parse( int& argc, char_type** argv ) m_program_name.assign( argv[0] ); dstring::size_type pos = m_program_name.find_last_of( BOOST_RT_PARAM_LITERAL( "/\\" ) ); - if( pos != cstring::npos ) + if( pos != static_cast(cstring::npos) ) m_program_name.erase( 0, pos+1 ); } @@ -176,9 +175,7 @@ parser::operator[]( cstring string_id ) const } } - BOOST_RT_PARAM_VALIDATE_LOGIC( found_param, BOOST_RT_PARAM_LITERAL( "Unknown parameter: " ) << string_id ); - - return found_param->actual_argument(); + return found_param ? found_param->actual_argument() : argument_ptr(); } //____________________________________________________________________________// diff --git a/include/boost/test/utils/runtime/cla/positional_parameter.hpp b/include/boost/test/utils/runtime/cla/positional_parameter.hpp index c8a53cab..60da8456 100644 --- a/include/boost/test/utils/runtime/cla/positional_parameter.hpp +++ b/include/boost/test/utils/runtime/cla/positional_parameter.hpp @@ -27,7 +27,7 @@ namespace BOOST_RT_PARAM_NAMESPACE { namespace cla { // ************************************************************************** // -// ************** single_name_policy ************** // +// ************** trivial_id_policy ************** // // ************************************************************************** // class trivial_id_policy : public identification_policy { diff --git a/include/boost/test/utils/runtime/cla/typed_parameter.hpp b/include/boost/test/utils/runtime/cla/typed_parameter.hpp index ec0fe226..3d4c57b2 100644 --- a/include/boost/test/utils/runtime/cla/typed_parameter.hpp +++ b/include/boost/test/utils/runtime/cla/typed_parameter.hpp @@ -40,7 +40,9 @@ namespace cla { template class typed_parameter : public cla::parameter { public: - explicit typed_parameter( identification_policy& ID ) : cla::parameter( ID, m_arg_factory ) {} + explicit typed_parameter( identification_policy& ID ) + : cla::parameter( ID, m_arg_factory, rtti::type_id() == rtti::type_id() ) + {} // parameter properties modification template @@ -51,7 +53,7 @@ public: m_arg_factory.accept_modifier( m ); BOOST_RT_PARAM_VALIDATE_LOGIC( !p_optional || !m_arg_factory.m_value_generator, - BOOST_RT_PARAM_LITERAL( "couldn't define a value generator for optional parameter " ) << id_2_report() ); + BOOST_RT_PARAM_LITERAL( "can't define a value generator for optional parameter " ) << id_2_report() ); } private: diff --git a/include/boost/test/utils/runtime/config.hpp b/include/boost/test/utils/runtime/config.hpp index 65b05bd8..22563a3b 100644 --- a/include/boost/test/utils/runtime/config.hpp +++ b/include/boost/test/utils/runtime/config.hpp @@ -44,6 +44,10 @@ # endif #endif +#ifdef __SUNPRO_CC +extern int putenv(char*); +#endif + namespace boost { namespace BOOST_RT_PARAM_NAMESPACE { @@ -63,7 +67,8 @@ typedef std::ostream out_stream; typedef std::basic_ostream out_stream; #endif -#if defined(__COMO__) +#ifndef UNDER_CE +#if defined(__COMO__) && 0 inline void putenv_impl( cstring name, cstring value ) { @@ -85,11 +90,12 @@ putenv_impl( cstring name, cstring value ) putenv( const_cast( fs.str().c_str() ) ); } #endif +#endif #define BOOST_RT_PARAM_LITERAL( l ) l #define BOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( l, sizeof( l ) - 1 ) #define BOOST_RT_PARAM_GETENV getenv -#define BOOST_RT_PARAM_PUTENV putenv_impl +#define BOOST_RT_PARAM_PUTENV ::boost::BOOST_RT_PARAM_NAMESPACE::putenv_impl #define BOOST_RT_PARAM_EXCEPTION_INHERIT_STD //____________________________________________________________________________// @@ -103,6 +109,7 @@ typedef const unit_test::basic_cstring literal_cstring; typedef wrap_wstringstream format_stream; typedef std::wostream out_stream; +#ifndef UNDER_CE inline void putenv_impl( cstring name, cstring value ) { @@ -115,6 +122,7 @@ putenv_impl( cstring name, cstring value ) using namespace std; wputenv( const_cast( fs.str().c_str() ) ); } +#endif #define BOOST_RT_PARAM_LITERAL( l ) L ## l #define BOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( L ## l, sizeof( L ## l )/sizeof(wchar_t) - 1 ) diff --git a/include/boost/test/utils/runtime/env/environment.hpp b/include/boost/test/utils/runtime/env/environment.hpp index 7e327801..f3170ff5 100644 --- a/include/boost/test/utils/runtime/env/environment.hpp +++ b/include/boost/test/utils/runtime/env/environment.hpp @@ -15,6 +15,10 @@ #ifndef BOOST_RT_ENV_ENVIRONMENT_HPP_062604GER #define BOOST_RT_ENV_ENVIRONMENT_HPP_062604GER +#ifdef UNDER_CE +#error Windows CE does not support environment variables. +#endif + // Boost.Runtime.Parameter #include #include diff --git a/include/boost/test/utils/runtime/env/fwd.hpp b/include/boost/test/utils/runtime/env/fwd.hpp index ffee5a1e..dff5dfd2 100644 --- a/include/boost/test/utils/runtime/env/fwd.hpp +++ b/include/boost/test/utils/runtime/env/fwd.hpp @@ -15,6 +15,10 @@ #ifndef BOOST_RT_ENV_FWD_HPP_062604GER #define BOOST_RT_ENV_FWD_HPP_062604GER +#ifdef UNDER_CE +#error Windows CE does not support environment variables. +#endif + // Boost.Runtime.Parameter #include diff --git a/include/boost/test/utils/runtime/env/variable.hpp b/include/boost/test/utils/runtime/env/variable.hpp index 6a226eb5..53f15277 100644 --- a/include/boost/test/utils/runtime/env/variable.hpp +++ b/include/boost/test/utils/runtime/env/variable.hpp @@ -15,6 +15,10 @@ #ifndef BOOST_RT_ENV_VARIABLE_HPP_062604GER #define BOOST_RT_ENV_VARIABLE_HPP_062604GER +#ifdef UNDER_CE +#error Windows CE does not support environment variables. +#endif + // Boost.Runtime.Parameter #include #include @@ -100,7 +104,13 @@ public: // access methods T const& value() const { return variable_base::value(); } +#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) || \ + BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0593)) + template + void value( boost::optional& res ) const { variable_base::value( res ); } +#else using variable_base::value; +#endif // Value assignment template diff --git a/include/boost/test/utils/runtime/file/config_file_iterator.cpp b/include/boost/test/utils/runtime/file/config_file_iterator.cpp index 88f5a534..a81a0c83 100644 --- a/include/boost/test/utils/runtime/file/config_file_iterator.cpp +++ b/include/boost/test/utils/runtime/file/config_file_iterator.cpp @@ -18,7 +18,10 @@ #include #include +#ifndef UNDER_CE #include +#endif + // Boost #include @@ -155,7 +158,7 @@ include_level::include_level( cstring file_name, cstring path_separators, includ } } - BOOST_RT_PARAM_VALIDATE_LOGIC( m_stream.is_open(), BOOST_RT_PARAM_LITERAL( "couldn't open file " ) << file_name ); + BOOST_RT_PARAM_VALIDATE_LOGIC( m_stream.is_open(), BOOST_RT_PARAM_LITERAL( "can't open file " ) << file_name ); } //____________________________________________________________________________// @@ -352,7 +355,9 @@ config_file_iterator::Impl::get_macro_value( cstring macro_name, bool ignore_mis if( it == m_symbols_table.end() ) { boost::optional macro_value; // !! variable actually may have different type + #ifndef UNDER_CE env::get( macro_name, macro_value ); + #endif BOOST_RT_PARAM_VALIDATE_LOGIC( macro_value || ignore_missing || !m_detect_missing_macro, BOOST_RT_PARAM_LITERAL( "Unknown macro \"" ) << macro_name << BOOST_RT_PARAM_LITERAL( "\"" ) ); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index be0add5b..24665318 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -10,6 +10,27 @@ rule test-btl-lib ( test-rule : test-name : lib-name ? : pattern_file * : source { source_files ?= $(test-name).cpp ; + return [ $(test-rule) $(source_files) ../build//$(lib-name) $(extra-libs) + : #args + : $(pattern_file) + : #on + # Activating -pedantic finds more gotchas + # Unfortunately, this warns about the use of "long long" in gcc's own stdlib + # So deactivate those warnings again + gcc:-pedantic + gcc:-Wno-long-long + borland:-w-8080 + msvc-6.5:static + msvc-8.0:_SCL_SECURE_NO_DEPRECATE + all + : $(test-name) + ] ; +} + +rule test-btl-lib-mt ( test-rule : test-name : lib-name ? : pattern_file * : source_files * : extra-libs ? ) +{ + source_files ?= $(test-name).cpp ; + return [ $(test-rule) $(source_files) ../build//$(lib-name) $(extra-libs) : #args : $(pattern_file) @@ -23,6 +44,7 @@ rule test-btl-lib ( test-rule : test-name : lib-name ? : pattern_file * : source msvc-6.5:static msvc-8.0:_SCL_SECURE_NO_DEPRECATE BOOST_TEST_NO_AUTO_LINK=1 # requirements + multi : $(test-name) ] ; } @@ -34,7 +56,7 @@ test-suite "basics_test" ; test-suite "prg_exec_monitor_test" - : [ test-btl-lib run-fail : prg_exec_fail1 : boost_prg_exec_monitor/static ] + : [ test-btl-lib run-fail : prg_exec_fail1 : included ] [ test-btl-lib run-fail : prg_exec_fail2 : boost_prg_exec_monitor/static ] [ test-btl-lib run-fail : prg_exec_fail3 : boost_prg_exec_monitor/static ] [ test-btl-lib run-fail : prg_exec_fail4 : boost_prg_exec_monitor/static ] @@ -59,12 +81,15 @@ test-suite "unit_test_framework_test" [ test-btl-lib run : token_iterator_test : boost_unit_test_framework ] [ test-btl-lib run : boost_check_equal_str : boost_unit_test_framework ] [ test-btl-lib run : test_tree_management_test : boost_unit_test_framework ] - [ test-btl-lib run : sync_access_test : boost_unit_test_framework/static : : : /boost/thread//boost_thread ] + ; - ; +test-suite "multithreaded_test" + : + [ test-btl-lib-mt run : sync_access_test : boost_unit_test_framework/static : : : /boost/thread//boost_thread ] + ; # A target that runs all the tests alias test : basics_test prg_exec_monitor_test unit_test_framework_test ; # Only run tests when explicitly requested -# explicit test basics_test prg_exec_monitor_test unit_test_framework_test ; +# explicit test basics_test prg_exec_monitor_test unit_test_framework_test ; diff --git a/test/basic_cstring_test.cpp b/test/basic_cstring_test.cpp index cbecb8bc..3dd72147 100644 --- a/test/basic_cstring_test.cpp +++ b/test/basic_cstring_test.cpp @@ -14,6 +14,7 @@ #ifdef _MSC_VER #pragma warning(disable: 4996) +#pragma warning(disable: 4267) #endif // Boost.Test diff --git a/test/test_files/errors_handling_test.pattern b/test/test_files/errors_handling_test.pattern index 0b976a47..0432ff5c 100644 --- a/test/test_files/errors_handling_test.pattern +++ b/test/test_files/errors_handling_test.pattern @@ -11,7 +11,7 @@ log level: log_successful_tests; error type: user message; Entering test case "error_on_demand" message -Test case error_on_demand doesn't include any assertions +Test case error_on_demand did not run any assertions Leaving test case "error_on_demand" =========================== @@ -19,7 +19,7 @@ log level: log_successful_tests; error type: user warning; Entering test case "error_on_demand" 107: warning in "error_on_demand": warning -Test case error_on_demand doesn't include any assertions +Test case error_on_demand did not run any assertions Leaving test case "error_on_demand" =========================== @@ -72,7 +72,7 @@ log level: log_test_suites; error type: user message; Entering test case "error_on_demand" message -Test case error_on_demand doesn't include any assertions +Test case error_on_demand did not run any assertions Leaving test case "error_on_demand" =========================== @@ -80,7 +80,7 @@ log level: log_test_suites; error type: user warning; Entering test case "error_on_demand" 107: warning in "error_on_demand": warning -Test case error_on_demand doesn't include any assertions +Test case error_on_demand did not run any assertions Leaving test case "error_on_demand" =========================== @@ -130,13 +130,13 @@ log level: log_messages; error type: no error; log level: log_messages; error type: user message; message -Test case error_on_demand doesn't include any assertions +Test case error_on_demand did not run any assertions =========================== log level: log_messages; error type: user warning; 107: warning in "error_on_demand": warning -Test case error_on_demand doesn't include any assertions +Test case error_on_demand did not run any assertions =========================== log level: log_messages; error type: user non-fatal error; diff --git a/test/test_files/errors_handling_test.pattern2 b/test/test_files/errors_handling_test.pattern2 index 39a77c40..95117d0b 100644 --- a/test/test_files/errors_handling_test.pattern2 +++ b/test/test_files/errors_handling_test.pattern2 @@ -11,7 +11,7 @@ log level: log_successful_tests; error type: user message; Entering test case "error_on_demand" message -Test case error_on_demand doesn't include any assertions +Test case error_on_demand did not run any assertions Leaving test case "error_on_demand" =========================== @@ -19,7 +19,7 @@ log level: log_successful_tests; error type: user warning; Entering test case "error_on_demand" 107: warning in "error_on_demand": warning -Test case error_on_demand doesn't include any assertions +Test case error_on_demand did not run any assertions Leaving test case "error_on_demand" =========================== @@ -55,7 +55,7 @@ log level: log_test_suites; error type: user message; Entering test case "error_on_demand" message -Test case error_on_demand doesn't include any assertions +Test case error_on_demand did not run any assertions Leaving test case "error_on_demand" =========================== @@ -63,7 +63,7 @@ log level: log_test_suites; error type: user warning; Entering test case "error_on_demand" 107: warning in "error_on_demand": warning -Test case error_on_demand doesn't include any assertions +Test case error_on_demand did not run any assertions Leaving test case "error_on_demand" =========================== @@ -96,13 +96,13 @@ log level: log_messages; error type: no error; log level: log_messages; error type: user message; message -Test case error_on_demand doesn't include any assertions +Test case error_on_demand did not run any assertions =========================== log level: log_messages; error type: user warning; 107: warning in "error_on_demand": warning -Test case error_on_demand doesn't include any assertions +Test case error_on_demand did not run any assertions =========================== log level: log_messages; error type: user non-fatal error; diff --git a/test/test_files/test_fp_comparisons.pattern b/test/test_files/test_fp_comparisons.pattern deleted file mode 100644 index 2279139d..00000000 --- a/test/test_files/test_fp_comparisons.pattern +++ /dev/null @@ -1,30 +0,0 @@ -152: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0} and fp2{1e-20} exceeds 1e-05% -153: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0} and fp2{1e-30} exceeds 1e-05% -154: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0} and fp2{-1e-10} exceeds 0.1% -155: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0.123456} and fp2{0.123457} exceeds 0.0001% -159: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0.123456} and fp2{-0.123457} exceeds 0.001% -163: error in "test_BOOST_CHECK_CLOSE": difference between fp1{1.23456e-10} and fp2{1.23457e-11} exceeds 0.001% -164: error in "test_BOOST_CHECK_CLOSE": difference between fp1{1.111e-10} and fp2{1.112e-10} exceeds 0.08999% -165: error in "test_BOOST_CHECK_CLOSE": difference between fp1{1.112e-10} and fp2{1.111e-10} exceeds 0.08999% -170: error in "test_BOOST_CHECK_CLOSE": difference between fp1{1} and fp2{1.0002} exceeds 0.011% -152: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0} and fp2{1e-20} exceeds 1e-05% -153: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0} and fp2{1e-30} exceeds 1e-05% -154: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0} and fp2{-1e-10} exceeds 0.1% -155: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0.123456} and fp2{0.123457} exceeds 0.0001% -159: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0.123456} and fp2{-0.123457} exceeds 0.001% -163: error in "test_BOOST_CHECK_CLOSE": difference between fp1{1.23456e-10} and fp2{1.23457e-11} exceeds 0.001% -164: error in "test_BOOST_CHECK_CLOSE": difference between fp1{1.111e-10} and fp2{1.112e-10} exceeds 0.08999% -165: error in "test_BOOST_CHECK_CLOSE": difference between fp1{1.112e-10} and fp2{1.111e-10} exceeds 0.08999% -170: error in "test_BOOST_CHECK_CLOSE": difference between fp1{1} and fp2{1.0002} exceeds 0.011% -152: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0} and fp2{1e-20} exceeds 1e-05% -153: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0} and fp2{1e-30} exceeds 1e-05% -154: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0} and fp2{-1e-10} exceeds 0.1% -155: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0.123456} and fp2{0.123457} exceeds 0.0001% -159: error in "test_BOOST_CHECK_CLOSE": difference between fp1{0.123456} and fp2{-0.123457} exceeds 0.001% -163: error in "test_BOOST_CHECK_CLOSE": difference between fp1{1.23456e-10} and fp2{1.23457e-11} exceeds 0.001% -164: error in "test_BOOST_CHECK_CLOSE": difference between fp1{1.111e-10} and fp2{1.112e-10} exceeds 0.08999% -165: error in "test_BOOST_CHECK_CLOSE": difference between fp1{1.112e-10} and fp2{1.111e-10} exceeds 0.08999% -170: error in "test_BOOST_CHECK_CLOSE": difference between fp1{1} and fp2{1.0002} exceeds 0.011% -204: error in "test_CHECK_SMALL": absolute value of 1e-6{1e-06} exceeds 1e-07 -219: error in "test_close_at_tolerance": difference between fp1{1.00000001} and fp2{1.00000002} exceeds 1e-06% -226: error in "test_close_at_tolerance": check close_at_tolerance( epsilon )( fp1, fp2 ) failed for ( 1.23456e-10, 1.23457e-10 ) diff --git a/test/test_files/test_tools_test.pattern b/test/test_files/test_tools_test.pattern index 752a31d6..c7197c79 100644 --- a/test/test_files/test_tools_test.pattern +++ b/test/test_files/test_tools_test.pattern @@ -1,63 +1,63 @@ -131: warning in "test_BOOST_WARN": condition sizeof(int) == sizeof(short) is not satisfied -134: info: check sizeof(unsigned char) == sizeof(char) passed -156: error in "test_BOOST_CHECK": check false failed -157: error in "test_BOOST_CHECK": check 1==2 failed -158: error in "test_BOOST_CHECK": check i==1 failed -161: info: check i==2 passed -168: error in "test_BOOST_REQUIRE": not aborted -170: fatal error in "test_BOOST_REQUIRE": critical check false failed -174: fatal error in "test_BOOST_REQUIRE": critical check j > 5 failed -177: info: check j < 5 passed -177: error in "test_BOOST_REQUIRE": not aborted -191: info: check 'object size 33 is too small' passed -208: error in "test_BOOST_CHECK_MESSAGE": Well, may be that what I believe in -210: error in "test_BOOST_CHECK_MESSAGE": Checking predicate failed. Some explanation -213: info: check 'Could it fail?' passed -218: error in "test_BOOST_CHECK_MESSAGE": Comparing 1 and 2: some explanation -225: fatal error in "test_BOOST_REQUIRE_MESSAGE": Here we should stop -228: info: check 'That's OK' passed -228: error in "test_BOOST_REQUIRE_MESSAGE": not aborted -235: error in "test_BOOST_ERROR": Fail to miss an error -242: fatal error in "test_BOOST_FAIL": No! No! Show must go on. -258: error in "test_BOOST_CHECK_THROW": exception my_exception is expected -261: warning in "test_BOOST_CHECK_THROW": exception my_exception is expected -264: fatal error in "test_BOOST_CHECK_THROW": exception my_exception is expected -267: info: check 'exception my_exception is caught' passed -274: error in "test_BOOST_CHECK_EXCEPTION": incorrect exception my_exception is caught -277: info: check 'incorrect exception my_exception is caught' passed -287: error in "test_BOOST_CHECK_NO_THROW": exception thrown by throw my_exception() -333: error in "test_BOOST_CHECK_EQUAL": check i == j failed [1 != 2] -339: error in "test_BOOST_CHECK_EQUAL": check str1 == str2 failed [test1 != test12] -342: error in "test_BOOST_CHECK_EQUAL": check i+1 == j failed [4 != 2] -345: info: check str1 == str3+1 passed -354: fatal error in "test_BOOST_CHECK_EQUAL": critical check str1 == str2 failed [test != null string] -360: warning in "test_BOOST_CHECK_EQUAL": condition b1 == b2 is not satisfied [B(1) != B(2)] -366: error in "test_BOOST_CHECK_EQUAL": check c1 == c3 failed [C(0,100) != C(1,102)]. Index mismatch -367: error in "test_BOOST_CHECK_EQUAL": check c1 == c2 failed [C(0,100) != C(0,101)]. Id mismatch -371: error in "test_BOOST_CHECK_EQUAL": check ch1 == ch2 failed [0xfffffffe != 0xfffffffd] -382: error in "test_BOOST_CHECK_LOGICAL_EXPR": check ++i != j failed [2 == 2] -384: error in "test_BOOST_CHECK_LOGICAL_EXPR": check i < j failed [2 >= 2] -385: error in "test_BOOST_CHECK_LOGICAL_EXPR": check i > j failed [2 <= 2] -392: error in "test_BOOST_CHECK_LOGICAL_EXPR": check i <= j failed [3 > 2] -393: error in "test_BOOST_CHECK_LOGICAL_EXPR": check j >= i failed [2 < 3] -398: error in "test_BOOST_CHECK_LOGICAL_EXPR": check str1 != str2 failed [test1 == test1] -428: error in "test_BOOST_CHECK_PREDICATE": check is_even( i ) failed for ( 17 ) -431: error in "test_BOOST_CHECK_PREDICATE": check not_equal_to()( i, 17 ) failed for ( 17, 17 ) -437: warning in "test_BOOST_CHECK_PREDICATE": condition moo( 12, i, j ) is not satisfied for ( 12, 17, 15 ) -445: error in "test_BOOST_CHECK_PREDICATE": check compare_lists( l1, l2 ) failed for ( , ). Different sizes [2!=0] -456: error in "test_BOOST_REQUIRE_PREDICATE": not aborted -458: fatal error in "test_BOOST_REQUIRE_PREDICATE": critical check less_equal()( arg2, arg1 ) failed for ( 2, 1 ) -479: error in "test_BOOST_CHECK_EQUAL_COLLECTIONS": check { testlist.begin(), testlist.end() } == { pattern, pattern+7 } failed. +136: warning in "test_BOOST_WARN": condition sizeof(int) == sizeof(short) is not satisfied +139: info: check sizeof(unsigned char) == sizeof(char) passed +161: error in "test_BOOST_CHECK": check false failed +162: error in "test_BOOST_CHECK": check 1==2 failed +163: error in "test_BOOST_CHECK": check i==1 failed +166: info: check i==2 passed +173: error in "test_BOOST_REQUIRE": not aborted +175: fatal error in "test_BOOST_REQUIRE": critical check false failed +179: fatal error in "test_BOOST_REQUIRE": critical check j > 5 failed +182: info: check j < 5 passed +182: error in "test_BOOST_REQUIRE": not aborted +196: info: check 'object size 33 is too small' passed +213: error in "test_BOOST_CHECK_MESSAGE": Well, may be that what I believe in +215: error in "test_BOOST_CHECK_MESSAGE": Checking predicate failed. Some explanation +218: info: check 'Could it fail?' passed +223: error in "test_BOOST_CHECK_MESSAGE": Comparing 1 and 2: some explanation +230: fatal error in "test_BOOST_REQUIRE_MESSAGE": Here we should stop +233: info: check 'That's OK' passed +233: error in "test_BOOST_REQUIRE_MESSAGE": not aborted +240: error in "test_BOOST_ERROR": Fail to miss an error +247: fatal error in "test_BOOST_FAIL": No! No! Show must go on. +263: error in "test_BOOST_CHECK_THROW": exception my_exception is expected +266: warning in "test_BOOST_CHECK_THROW": exception my_exception is expected +269: fatal error in "test_BOOST_CHECK_THROW": exception my_exception is expected +272: info: check 'exception my_exception is caught' passed +279: error in "test_BOOST_CHECK_EXCEPTION": incorrect exception my_exception is caught +282: info: check 'incorrect exception my_exception is caught' passed +292: error in "test_BOOST_CHECK_NO_THROW": exception thrown by throw my_exception() +338: error in "test_BOOST_CHECK_EQUAL": check i == j failed [1 != 2] +344: error in "test_BOOST_CHECK_EQUAL": check str1 == str2 failed [test1 != test12] +347: error in "test_BOOST_CHECK_EQUAL": check i+1 == j failed [4 != 2] +350: info: check str1 == str3+1 passed +359: fatal error in "test_BOOST_CHECK_EQUAL": critical check str1 == str2 failed [test != null string] +365: warning in "test_BOOST_CHECK_EQUAL": condition b1 == b2 is not satisfied [B(1) != B(2)] +371: error in "test_BOOST_CHECK_EQUAL": check c1 == c3 failed [C(0,100) != C(1,102)]. Index mismatch +372: error in "test_BOOST_CHECK_EQUAL": check c1 == c2 failed [C(0,100) != C(0,101)]. Id mismatch +376: error in "test_BOOST_CHECK_EQUAL": check ch1 == ch2 failed [0xfffffffe != 0xfffffffd] +387: error in "test_BOOST_CHECK_LOGICAL_EXPR": check ++i != j failed [2 == 2] +389: error in "test_BOOST_CHECK_LOGICAL_EXPR": check i < j failed [2 >= 2] +390: error in "test_BOOST_CHECK_LOGICAL_EXPR": check i > j failed [2 <= 2] +397: error in "test_BOOST_CHECK_LOGICAL_EXPR": check i <= j failed [3 > 2] +398: error in "test_BOOST_CHECK_LOGICAL_EXPR": check j >= i failed [2 < 3] +403: error in "test_BOOST_CHECK_LOGICAL_EXPR": check str1 != str2 failed [test1 == test1] +433: error in "test_BOOST_CHECK_PREDICATE": check is_even( i ) failed for ( 17 ) +436: error in "test_BOOST_CHECK_PREDICATE": check not_equal_to()( i, 17 ) failed for ( 17, 17 ) +442: warning in "test_BOOST_CHECK_PREDICATE": condition moo( 12, i, j ) is not satisfied for ( 12, 17, 15 ) +450: error in "test_BOOST_CHECK_PREDICATE": check compare_lists( l1, l2 ) failed for ( , ). Different sizes [2!=0] +461: error in "test_BOOST_REQUIRE_PREDICATE": not aborted +463: fatal error in "test_BOOST_REQUIRE_PREDICATE": critical check less_equal()( arg2, arg1 ) failed for ( 2, 1 ) +484: error in "test_BOOST_CHECK_EQUAL_COLLECTIONS": check { testlist.begin(), testlist.end() } == { pattern, pattern+7 } failed. Mismatch in a position 2: 4 != 3 Mismatch in a position 5: 7 != 6 -480: error in "test_BOOST_CHECK_EQUAL_COLLECTIONS": check { testlist.begin(), testlist.end() } == { pattern, pattern+2 } failed. +485: error in "test_BOOST_CHECK_EQUAL_COLLECTIONS": check { testlist.begin(), testlist.end() } == { pattern, pattern+2 } failed. Collections size mismatch: 7 != 2 -489: error in "test_BOOST_CHECK_BITWISE_EQUAL": check (char)0x06 =.= (char)0x16 failed. +494: error in "test_BOOST_CHECK_BITWISE_EQUAL": check (char)0x06 =.= (char)0x16 failed. Mismatch in a position 4 -492: warning in "test_BOOST_CHECK_BITWISE_EQUAL": condition (char)0x26 =.= (char)0x04 is not satisfied. +497: warning in "test_BOOST_CHECK_BITWISE_EQUAL": condition (char)0x26 =.= (char)0x04 is not satisfied. Mismatch in a position 1 Mismatch in a position 5 -495: fatal error in "test_BOOST_CHECK_BITWISE_EQUAL": critical check (char)0x26 =.= (int)0x26 failed. +500: fatal error in "test_BOOST_CHECK_BITWISE_EQUAL": critical check (char)0x26 =.= (int)0x26 failed. Operands bit sizes mismatch: 8 != 32 still testing 1+1=2 @@ -66,6 +66,6 @@ struct A 0x14 20 0: fatal error in "test_BOOST_TEST_CHECKPOINT": C string: some error -530: last checkpoint: Going to do a silly things +535: last checkpoint: Going to do a silly things 0: fatal error in "test_BOOST_TEST_PASSPOINT": unknown type -541: last checkpoint +546: last checkpoint diff --git a/test/test_fp_comparisons.cpp b/test/test_fp_comparisons.cpp index fb95eee8..3557d542 100644 --- a/test/test_fp_comparisons.cpp +++ b/test/test_fp_comparisons.cpp @@ -133,6 +133,15 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( test_CHECK_CLOSE_FRACTION, FPT, test_types ) //____________________________________________________________________________// +BOOST_AUTO_TEST_CASE( test_type_mismatch ) +{ + BOOST_CHECK_CLOSE_FRACTION( 2, 2.1, 0.06 ); + BOOST_CHECK_CLOSE( 2.1, 2, 6 ); + BOOST_CHECK_CLOSE( 2.1, 2.f, 6 ); +} + +//____________________________________________________________________________// + BOOST_AUTO_TEST_CASE( test_CHECK_SMALL ) { BOOST_CHECK_SMALL( 1e-6, 1e-5 ); diff --git a/test/test_tools_test.cpp b/test/test_tools_test.cpp index 33589989..8e329da0 100644 --- a/test/test_tools_test.cpp +++ b/test/test_tools_test.cpp @@ -31,6 +31,11 @@ #include #include +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4702) // unreachable code +#endif + using namespace boost::unit_test; using namespace boost::test_tools; diff --git a/test/token_iterator_test.cpp b/test/token_iterator_test.cpp index 1116e127..71188567 100644 --- a/test/token_iterator_test.cpp +++ b/test/token_iterator_test.cpp @@ -153,7 +153,7 @@ void foo( Iter b, Iter e ) moo( utf::make_range_token_iterator( b, e, (utf::kept_delimeters = utf::dt_isspace, utf::dropped_delimeters = "2" )) ); } -inline char loo( char c ) { return (std::toupper)( c ); } +inline char loo( char c ) { return (char)(std::toupper)( c ); } BOOST_AUTO_TEST_CASE( test_make_range_token_iterator ) { diff --git a/tools/console_test_runner/src/console_test_runner.cpp b/tools/console_test_runner/src/console_test_runner.cpp index 7d0353b3..ca34bea9 100644 --- a/tools/console_test_runner/src/console_test_runner.cpp +++ b/tools/console_test_runner/src/console_test_runner.cpp @@ -154,7 +154,7 @@ bool load_test_lib() init_func = dyn_lib::locate_symbol( test_lib_handle, init_func_name ); if( !init_func ) - throw std::logic_error( std::string("Couldn't locate test initilization function ") + throw std::logic_error( std::string("Can't locate test initilization function ") .append( init_func_name ) .append( ": " ) .append( dyn_lib::error() ) );