summaryrefslogtreecommitdiff
path: root/boost/test
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-09-13 11:05:34 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-09-13 11:06:28 +0900
commit34bd32e225e2a8a94104489b31c42e5801cc1f4a (patch)
treed021b579a0c190354819974e1eaf0baa54b551f3 /boost/test
parentf763a99a501650eff2c60288aa6f10ef916d769e (diff)
downloadboost-34bd32e225e2a8a94104489b31c42e5801cc1f4a.tar.gz
boost-34bd32e225e2a8a94104489b31c42e5801cc1f4a.tar.bz2
boost-34bd32e225e2a8a94104489b31c42e5801cc1f4a.zip
Imported Upstream version 1.63.0upstream/1.63.0
Change-Id: Iac85556a04b7e58d63ba636dedb0986e3555714a Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/test')
-rw-r--r--boost/test/execution_monitor.hpp40
-rw-r--r--boost/test/impl/compiler_log_formatter.ipp4
-rw-r--r--boost/test/impl/execution_monitor.ipp49
-rw-r--r--boost/test/impl/framework.ipp248
-rw-r--r--boost/test/impl/test_tree.ipp3
-rw-r--r--boost/test/impl/unit_test_parameters.ipp18
-rw-r--r--boost/test/included/unit_test.hpp3
-rw-r--r--boost/test/tools/collection_comparison_op.hpp51
-rw-r--r--boost/test/tools/cstring_comparison_op.hpp20
-rw-r--r--boost/test/tools/fpc_op.hpp6
-rw-r--r--boost/test/tree/test_case_template.hpp17
-rw-r--r--boost/test/unit_test_log_formatter.hpp6
-rw-r--r--boost/test/unit_test_parameters.hpp2
-rw-r--r--boost/test/utils/is_cstring.hpp31
-rw-r--r--boost/test/utils/is_forward_iterable.hpp5
-rw-r--r--boost/test/utils/iterator/token_iterator.hpp8
-rw-r--r--boost/test/utils/runtime/cla/parser.hpp33
-rw-r--r--boost/test/utils/runtime/parameter.hpp2
18 files changed, 361 insertions, 185 deletions
diff --git a/boost/test/execution_monitor.hpp b/boost/test/execution_monitor.hpp
index 3a203d15f9..f53348abe1 100644
--- a/boost/test/execution_monitor.hpp
+++ b/boost/test/execution_monitor.hpp
@@ -489,7 +489,7 @@ namespace fpe {
enum masks {
BOOST_FPE_OFF = 0,
-#ifdef BOOST_SEH_BASED_SIGNAL_HANDLING
+#ifdef BOOST_SEH_BASED_SIGNAL_HANDLING /* *** */
BOOST_FPE_DIVBYZERO = EM_ZERODIVIDE,
BOOST_FPE_INEXACT = EM_INEXACT,
BOOST_FPE_INVALID = EM_INVALID,
@@ -497,17 +497,49 @@ enum masks {
BOOST_FPE_UNDERFLOW = EM_UNDERFLOW|EM_DENORMAL,
BOOST_FPE_ALL = MCW_EM,
-#elif defined(BOOST_NO_FENV_H) || defined(BOOST_CLANG)
- BOOST_FPE_ALL = 1,
-#else
+
+#elif defined(BOOST_NO_FENV_H) || defined(BOOST_CLANG) /* *** */
+ BOOST_FPE_ALL = BOOST_FPE_OFF,
+
+#else /* *** */
+
+#if defined(FE_DIVBYZERO)
BOOST_FPE_DIVBYZERO = FE_DIVBYZERO,
+#else
+ BOOST_FPE_DIVBYZERO = BOOST_FPE_OFF,
+#endif
+
+#if defined(FE_INEXACT)
BOOST_FPE_INEXACT = FE_INEXACT,
+#else
+ BOOST_FPE_INEXACT = BOOST_FPE_OFF,
+#endif
+
+#if defined(FE_INVALID)
BOOST_FPE_INVALID = FE_INVALID,
+#else
+ BOOST_FPE_INVALID = BOOST_FPE_OFF,
+#endif
+
+#if defined(FE_OVERFLOW)
BOOST_FPE_OVERFLOW = FE_OVERFLOW,
+#else
+ BOOST_FPE_OVERFLOW = BOOST_FPE_OFF,
+#endif
+
+#if defined(FE_UNDERFLOW)
BOOST_FPE_UNDERFLOW = FE_UNDERFLOW,
+#else
+ BOOST_FPE_UNDERFLOW = BOOST_FPE_OFF,
+#endif
+#if defined(FE_ALL_EXCEPT)
BOOST_FPE_ALL = FE_ALL_EXCEPT,
+#else
+ BOOST_FPE_ALL = BOOST_FPE_OFF,
#endif
+
+#endif /* *** */
BOOST_FPE_INV = BOOST_FPE_ALL+1
};
diff --git a/boost/test/impl/compiler_log_formatter.ipp b/boost/test/impl/compiler_log_formatter.ipp
index c5aa6afe93..8c76788109 100644
--- a/boost/test/impl/compiler_log_formatter.ipp
+++ b/boost/test/impl/compiler_log_formatter.ipp
@@ -146,7 +146,7 @@ compiler_log_formatter::log_exception_start( std::ostream& output, log_checkpoin
print_prefix( output, loc.m_file_name, loc.m_line_num );
{
- BOOST_TEST_SCOPE_SETCOLOR( m_color_output, output, term_attr::BLINK, term_color::RED );
+ BOOST_TEST_SCOPE_SETCOLOR( m_color_output, output, term_attr::UNDERLINE, term_color::RED );
output << "fatal error: in \"" << (loc.m_function.is_empty() ? test_phase_identifier() : loc.m_function ) << "\": "
<< ex.what();
@@ -205,7 +205,7 @@ compiler_log_formatter::log_entry_start( std::ostream& output, log_entry_data co
case BOOST_UTL_ET_FATAL_ERROR:
print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
if( m_color_output )
- output << setcolor( term_attr::BLINK, term_color::RED );
+ output << setcolor( term_attr::UNDERLINE, term_color::RED );
output << "fatal error: in \"" << test_phase_identifier() << "\": ";
break;
}
diff --git a/boost/test/impl/execution_monitor.ipp b/boost/test/impl/execution_monitor.ipp
index ce6c6c7eb9..3ddcf67137 100644
--- a/boost/test/impl/execution_monitor.ipp
+++ b/boost/test/impl/execution_monitor.ipp
@@ -6,19 +6,16 @@
// See http://www.boost.org/libs/test for the library home page.
//
-// File : $RCSfile$
-//
-// Version : $Revision$
-//
-// Description : provides execution monitor implementation for all supported
-// configurations, including Microsoft structured exception based, unix signals
-// based and special workarounds for borland
-//
-// Note that when testing requirements or user wishes preclude use of this
-// file as a separate compilation unit, it may be included as a header file.
-//
-// Header dependencies are deliberately restricted to reduce coupling to other
-// boost libraries.
+/// @file
+/// Provides execution monitor implementation for all supported
+/// configurations, including Microsoft structured exception based, unix signals
+/// based and special workarounds for borland
+///
+/// Note that when testing requirements or user wishes preclude use of this
+/// file as a separate compilation unit, it may be included as a header file.
+///
+/// Header dependencies are deliberately restricted to reduce coupling to other
+/// boost libraries.
// ***************************************************************************
#ifndef BOOST_TEST_EXECUTION_MONITOR_IPP_012205GER
@@ -291,20 +288,20 @@ struct fpe_except_guard {
: m_detect_fpe( detect_fpe )
{
// prepare fp exceptions control
- m_previosly_enabled = fpe::disable( fpe::BOOST_FPE_ALL );
- if( m_previosly_enabled != fpe::BOOST_FPE_INV && detect_fpe != fpe::BOOST_FPE_OFF )
+ m_previously_enabled = fpe::disable( fpe::BOOST_FPE_ALL );
+ if( m_previously_enabled != fpe::BOOST_FPE_INV && detect_fpe != fpe::BOOST_FPE_OFF )
fpe::enable( detect_fpe );
}
~fpe_except_guard()
{
if( m_detect_fpe != fpe::BOOST_FPE_OFF )
fpe::disable( m_detect_fpe );
- if( m_previosly_enabled != fpe::BOOST_FPE_INV )
- fpe::enable( m_previosly_enabled );
+ if( m_previously_enabled != fpe::BOOST_FPE_INV )
+ fpe::enable( m_previously_enabled );
}
unsigned m_detect_fpe;
- unsigned m_previosly_enabled;
+ unsigned m_previously_enabled;
};
@@ -1360,7 +1357,7 @@ enable( unsigned mask )
#if defined(UNDER_CE)
/* Not Implemented in Windows CE */
- return 0;
+ return BOOST_FPE_OFF;
#elif defined(BOOST_SEH_BASED_SIGNAL_HANDLING)
_clearfp();
@@ -1378,13 +1375,16 @@ enable( unsigned mask )
#endif
return ~old_cw & BOOST_FPE_ALL;
-#elif defined(__GLIBC__) && defined(__USE_GNU) && !defined(BOOST_CLANG) && !defined(BOOST_NO_FENV_H)
+#elif defined(__GLIBC__) && defined(__USE_GNU)
+ if (BOOST_FPE_ALL == BOOST_FPE_OFF)
+ /* Not Implemented */
+ return BOOST_FPE_OFF;
feclearexcept(BOOST_FPE_ALL);
int res = feenableexcept( mask );
return res == -1 ? (unsigned)BOOST_FPE_INV : (unsigned)res;
#else
/* Not Implemented */
- return 0;
+ return BOOST_FPE_OFF;
#endif
}
@@ -1397,7 +1397,7 @@ disable( unsigned mask )
#if defined(UNDER_CE)
/* Not Implemented in Windows CE */
- return 0;
+ return BOOST_FPE_INV;
#elif defined(BOOST_SEH_BASED_SIGNAL_HANDLING)
_clearfp();
@@ -1415,7 +1415,10 @@ disable( unsigned mask )
#endif
return ~old_cw & BOOST_FPE_ALL;
-#elif defined(__GLIBC__) && defined(__USE_GNU) && !defined(BOOST_CLANG) && !defined(BOOST_NO_FENV_H)
+#elif defined(__GLIBC__) && defined(__USE_GNU)
+ if (BOOST_FPE_ALL == BOOST_FPE_OFF)
+ /* Not Implemented */
+ return BOOST_FPE_INV;
feclearexcept(BOOST_FPE_ALL);
int res = fedisableexcept( mask );
return res == -1 ? (unsigned)BOOST_FPE_INV : (unsigned)res;
diff --git a/boost/test/impl/framework.ipp b/boost/test/impl/framework.ipp
index a513c612e1..298dde92ea 100644
--- a/boost/test/impl/framework.ipp
+++ b/boost/test/impl/framework.ipp
@@ -844,145 +844,161 @@ setup_loggers()
BOOST_TEST_I_TRY {
-
-
#ifdef BOOST_TEST_SUPPORT_TOKEN_ITERATOR
- bool has_combined_logger = runtime_config::has( runtime_config::COMBINED_LOGGER )
- && !runtime_config::get< std::vector<std::string> >( runtime_config::COMBINED_LOGGER ).empty();
+ bool has_combined_logger = runtime_config::has( runtime_config::COMBINED_LOGGER )
+ && !runtime_config::get< std::vector<std::string> >( runtime_config::COMBINED_LOGGER ).empty();
#else
- bool has_combined_logger = false;
+ bool has_combined_logger = false;
#endif
- if( !has_combined_logger ) {
- unit_test_log.set_threshold_level( runtime_config::get<log_level>( runtime_config::LOG_LEVEL ) );
- const output_format format = runtime_config::get<output_format>( runtime_config::LOG_FORMAT );
- unit_test_log.set_format( format );
-
- runtime_config::stream_holder& stream_logger = s_frk_state().m_log_sinks[format];
- if( runtime_config::has( runtime_config::LOG_SINK ) )
- stream_logger.setup( runtime_config::get<const_string>( runtime_config::LOG_SINK ) );
- unit_test_log.set_stream( stream_logger.ref() );
- }
- else
- {
-
- const std::vector<std::string>& v_output_format = runtime_config::get< std::vector<std::string> >( runtime_config::COMBINED_LOGGER ) ;
-
- static const std::pair<const char*, log_level> all_log_levels[] = {
- std::make_pair( "all" , log_successful_tests ),
- std::make_pair( "success" , log_successful_tests ),
- std::make_pair( "test_suite" , log_test_units ),
- std::make_pair( "unit_scope" , log_test_units ),
- std::make_pair( "message" , log_messages ),
- std::make_pair( "warning" , log_warnings ),
- std::make_pair( "error" , log_all_errors ),
- std::make_pair( "cpp_exception" , log_cpp_exception_errors ),
- std::make_pair( "system_error" , log_system_errors ),
- std::make_pair( "fatal_error" , log_fatal_errors ),
- std::make_pair( "nothing" , log_nothing )
- };
-
- static const std::pair<const char*, output_format> all_formats[] = {
- std::make_pair( "HRF" , OF_CLF ),
- std::make_pair( "CLF" , OF_CLF ),
- std::make_pair( "XML" , OF_XML ),
- std::make_pair( "JUNIT", OF_JUNIT )
- };
-
-
- bool is_first = true;
+ if( !has_combined_logger ) {
+ unit_test_log.set_threshold_level( runtime_config::get<log_level>( runtime_config::LOG_LEVEL ) );
+ const output_format format = runtime_config::get<output_format>( runtime_config::LOG_FORMAT );
+ unit_test_log.set_format( format );
- BOOST_TEST_FOREACH( const_string, current_multi_config, v_output_format ) {
+ runtime_config::stream_holder& stream_logger = s_frk_state().m_log_sinks[format];
+ if( runtime_config::has( runtime_config::LOG_SINK ) )
+ stream_logger.setup( runtime_config::get<std::string>( runtime_config::LOG_SINK ) );
+ unit_test_log.set_stream( stream_logger.ref() );
+ }
+ else
+ {
-#ifdef BOOST_TEST_SUPPORT_TOKEN_ITERATOR
- utils::string_token_iterator current_config( current_multi_config, (utils::dropped_delimeters = ":",
- utils::kept_delimeters = utils::dt_none) );
+ const std::vector<std::string>& v_output_format = runtime_config::get< std::vector<std::string> >( runtime_config::COMBINED_LOGGER ) ;
+
+ static const std::pair<const char*, log_level> all_log_levels[] = {
+ std::make_pair( "all" , log_successful_tests ),
+ std::make_pair( "success" , log_successful_tests ),
+ std::make_pair( "test_suite" , log_test_units ),
+ std::make_pair( "unit_scope" , log_test_units ),
+ std::make_pair( "message" , log_messages ),
+ std::make_pair( "warning" , log_warnings ),
+ std::make_pair( "error" , log_all_errors ),
+ std::make_pair( "cpp_exception" , log_cpp_exception_errors ),
+ std::make_pair( "system_error" , log_system_errors ),
+ std::make_pair( "fatal_error" , log_fatal_errors ),
+ std::make_pair( "nothing" , log_nothing )
+ };
+
+ static const std::pair<const char*, output_format> all_formats[] = {
+ std::make_pair( "HRF" , OF_CLF ),
+ std::make_pair( "CLF" , OF_CLF ),
+ std::make_pair( "XML" , OF_XML ),
+ std::make_pair( "JUNIT", OF_JUNIT )
+ };
+
+
+ bool is_first = true;
+
+ BOOST_TEST_FOREACH( const_string, current_multi_config, v_output_format ) {
+
+ #ifdef BOOST_TEST_SUPPORT_TOKEN_ITERATOR
+
+ // ':' may be used for file names: C:/tmp/mylogsink.xml
+ // we merge the tokens that start with / or \ with the previous one.
+ std::vector<std::string> v_processed_tokens;
+
+ {
+ utils::string_token_iterator current_config( current_multi_config, (utils::dropped_delimeters = ":",
+ utils::kept_delimeters = utils::dt_none) );
+
+ for( ; current_config != utils::string_token_iterator() ; ++current_config) {
+ std::string str_copy(current_config->begin(), current_config->end());
+ if( ( str_copy[0] == '\\' || str_copy[0] == '/' )
+ && v_processed_tokens.size() > 0) {
+ v_processed_tokens.back() += ":" + str_copy; // ':' has been eaten up
+ }
+ else {
+ v_processed_tokens.push_back(str_copy);
+ }
+ }
+ }
- for( ; current_config != utils::string_token_iterator() ; ++current_config) {
+ BOOST_TEST_FOREACH( std::string const&, current_config, v_processed_tokens ) {
- utils::string_token_iterator current_format_specs( *current_config, (utils::keep_empty_tokens,
- utils::dropped_delimeters = ",",
- utils::kept_delimeters = utils::dt_none) );
+ utils::string_token_iterator current_format_specs( current_config, (utils::keep_empty_tokens,
+ utils::dropped_delimeters = ",",
+ utils::kept_delimeters = utils::dt_none) );
- output_format format = OF_INVALID ; // default
- if( current_format_specs != utils::string_token_iterator() &&
- current_format_specs->size() ) {
+ output_format format = OF_INVALID ; // default
+ if( current_format_specs != utils::string_token_iterator() &&
+ current_format_specs->size() ) {
- for(size_t elem=0; elem < sizeof(all_formats)/sizeof(all_formats[0]); elem++) {
- if(const_string(all_formats[elem].first) == *current_format_specs) {
- format = all_formats[elem].second;
- break;
+ for(size_t elem=0; elem < sizeof(all_formats)/sizeof(all_formats[0]); elem++) {
+ if(const_string(all_formats[elem].first) == *current_format_specs) {
+ format = all_formats[elem].second;
+ break;
+ }
}
}
- }
- BOOST_TEST_I_ASSRT( format != OF_INVALID,
- boost::runtime::access_to_missing_argument()
- << "Unable to determine the logger type from '"
- << *current_config
- << "'. Possible choices are: "
- << std::accumulate(all_formats,
- all_formats + sizeof(all_formats)/sizeof(all_formats[0]),
- std::string(""),
- sum_to_first_only())
- );
-
- // activates this format
- if( is_first ) {
- unit_test_log.set_format( format );
- }
- else {
- unit_test_log.add_format( format );
- }
- is_first = false;
+ BOOST_TEST_I_ASSRT( format != OF_INVALID,
+ boost::runtime::access_to_missing_argument()
+ << "Unable to determine the logger type from '"
+ << current_config
+ << "'. Possible choices are: "
+ << std::accumulate(all_formats,
+ all_formats + sizeof(all_formats)/sizeof(all_formats[0]),
+ std::string(""),
+ sum_to_first_only())
+ );
+
+ // activates this format
+ if( is_first ) {
+ unit_test_log.set_format( format );
+ }
+ else {
+ unit_test_log.add_format( format );
+ }
+ is_first = false;
- unit_test_log_formatter * const formatter = unit_test_log.get_formatter(format);
- BOOST_TEST_SETUP_ASSERT( formatter, "Logger setup error" );
+ unit_test_log_formatter * const formatter = unit_test_log.get_formatter(format);
+ BOOST_TEST_SETUP_ASSERT( formatter, "Logger setup error" );
- log_level formatter_log_level = invalid_log_level;
- if( !current_format_specs->size() ) {
- formatter_log_level = formatter->get_log_level(); // default log level given by the formatter
- }
- else if( ++current_format_specs != utils::string_token_iterator() ) {
+ log_level formatter_log_level = invalid_log_level;
+ ++current_format_specs ;
+ if( !current_format_specs->size() ) {
+ formatter_log_level = formatter->get_log_level(); // default log level given by the formatter
+ }
+ else if( current_format_specs != utils::string_token_iterator() ) {
- for(size_t elem=0; elem < sizeof(all_log_levels)/sizeof(all_log_levels[0]); elem++) {
- if(const_string(all_log_levels[elem].first) == *current_format_specs) {
- formatter_log_level = all_log_levels[elem].second;
- break;
+ for(size_t elem=0; elem < sizeof(all_log_levels)/sizeof(all_log_levels[0]); elem++) {
+ if(const_string(all_log_levels[elem].first) == *current_format_specs) {
+ formatter_log_level = all_log_levels[elem].second;
+ break;
+ }
}
}
- }
- BOOST_TEST_I_ASSRT( formatter_log_level != invalid_log_level,
- boost::runtime::access_to_missing_argument()
- << "Unable to determine the log level from '"
- << *current_config
- << "'. Possible choices are: "
- << std::accumulate(all_log_levels,
- all_log_levels + sizeof(all_log_levels)/sizeof(all_log_levels[0]),
- std::string(""),
- sum_to_first_only())
- );
+ BOOST_TEST_I_ASSRT( formatter_log_level != invalid_log_level,
+ boost::runtime::access_to_missing_argument()
+ << "Unable to determine the log level from '"
+ << current_config
+ << "'. Possible choices are: "
+ << std::accumulate(all_log_levels,
+ all_log_levels + sizeof(all_log_levels)/sizeof(all_log_levels[0]),
+ std::string(""),
+ sum_to_first_only())
+ );
- unit_test_log.set_threshold_level( format, formatter_log_level );
+ unit_test_log.set_threshold_level( format, formatter_log_level );
- runtime_config::stream_holder& stream_logger = s_frk_state().m_log_sinks[format];
- if( ++current_format_specs != utils::string_token_iterator() &&
- current_format_specs->size() ) {
- stream_logger.setup( *current_format_specs );
- }
- else {
- stream_logger.setup( formatter->get_default_stream_description() );
+ runtime_config::stream_holder& stream_logger = s_frk_state().m_log_sinks[format];
+ if( ++current_format_specs != utils::string_token_iterator() &&
+ current_format_specs->size() ) {
+ stream_logger.setup( *current_format_specs );
+ }
+ else {
+ stream_logger.setup( formatter->get_default_stream_description() );
+ }
+ unit_test_log.set_stream( format, stream_logger.ref() );
}
- unit_test_log.set_stream( format, stream_logger.ref() );
-
- }
-#endif
- }
+ #endif
+ } // for each logger
- }
- }
+ } // if/else new logger API
+ } // BOOST_TEST_I_TRY
BOOST_TEST_I_CATCH( boost::runtime::init_error, ex ) {
BOOST_TEST_SETUP_ASSERT( false, ex.msg );
}
@@ -1021,7 +1037,7 @@ init( init_unit_test_func init_func, int argc, char* argv[] )
results_reporter::set_format( runtime_config::get<output_format>( runtime_config::REPORT_FORMAT ) );
if( runtime_config::has( runtime_config::REPORT_SINK ) )
- s_frk_state().m_report_sink.setup( runtime_config::get<const_string>( runtime_config::REPORT_SINK ) );
+ s_frk_state().m_report_sink.setup( runtime_config::get<std::string>( runtime_config::REPORT_SINK ) );
results_reporter::set_stream( s_frk_state().m_report_sink.ref() );
// 40. Register default test observers
diff --git a/boost/test/impl/test_tree.ipp b/boost/test/impl/test_tree.ipp
index d45f7b32b5..08bdad3360 100644
--- a/boost/test/impl/test_tree.ipp
+++ b/boost/test/impl/test_tree.ipp
@@ -381,7 +381,8 @@ normalize_test_case_name( const_string name )
if( name[0] == '&' )
norm_name = norm_name.substr( 1 );
- std::replace(norm_name.begin(), norm_name.end(), ' ', '_');
+ std::replace(norm_name.begin(), norm_name.end(), ' ', '_');
+ std::replace(norm_name.begin(), norm_name.end(), ':', '_');
return norm_name;
}
diff --git a/boost/test/impl/unit_test_parameters.ipp b/boost/test/impl/unit_test_parameters.ipp
index f49079ea3e..315942e6c0 100644
--- a/boost/test/impl/unit_test_parameters.ipp
+++ b/boost/test/impl/unit_test_parameters.ipp
@@ -99,6 +99,7 @@ std::string WAIT_FOR_DEBUGGER = "wait_for_debugger";
std::string HELP = "help";
std::string USAGE = "usage";
+std::string VERSION = "version";
//____________________________________________________________________________//
@@ -148,12 +149,11 @@ register_parameters( rt::parameters_store& store )
"compiler, STL version and Boost version."
));
- ///////////////////////////////////////////////
-
build_info.add_cla_id( "--", BUILD_INFO, "=" );
build_info.add_cla_id( "-", "i", " " );
store.add( build_info );
+ ///////////////////////////////////////////////
rt::option catch_sys_errors( CATCH_SYS_ERRORS, (
rt::description = "Allows to switch between catching and ignoring system errors (signals).",
@@ -635,6 +635,14 @@ register_parameters( rt::parameters_store& store )
));
usage.add_cla_id( "-", "?", " " );
store.add( usage );
+
+ ///////////////////////////////////////////////
+
+ rt::option version( VERSION, (
+ rt::description = "Prints Boost.Test version and exits."
+ ));
+ version.add_cla_id( "--", VERSION, " " );
+ store.add( version );
}
static rt::arguments_store s_arguments_store;
@@ -668,7 +676,11 @@ init( int& argc, char** argv )
rt::finalize_arguments( s_parameters_store, s_arguments_store );
// Report help if requested
- if( runtime_config::get<bool>( USAGE ) ) {
+ if( runtime_config::get<bool>( VERSION ) ) {
+ parser->version( std::cerr );
+ BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_success ) );
+ }
+ else if( runtime_config::get<bool>( USAGE ) ) {
parser->usage( std::cerr );
BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_success ) );
}
diff --git a/boost/test/included/unit_test.hpp b/boost/test/included/unit_test.hpp
index 8835acd455..993d75e4c0 100644
--- a/boost/test/included/unit_test.hpp
+++ b/boost/test/included/unit_test.hpp
@@ -12,6 +12,8 @@
#ifndef BOOST_INCLUDED_UNIT_TEST_FRAMEWORK_HPP_071894GER
#define BOOST_INCLUDED_UNIT_TEST_FRAMEWORK_HPP_071894GER
+#define BOOST_TEST_INCLUDED
+
#include <boost/test/impl/compiler_log_formatter.ipp>
#include <boost/test/impl/junit_log_formatter.ipp>
#include <boost/test/impl/debug.ipp>
@@ -32,7 +34,6 @@
#include <boost/test/impl/junit_log_formatter.ipp>
#include <boost/test/impl/xml_report_formatter.ipp>
-#define BOOST_TEST_INCLUDED
#include <boost/test/unit_test.hpp>
#endif // BOOST_INCLUDED_UNIT_TEST_FRAMEWORK_HPP_071894GER
diff --git a/boost/test/tools/collection_comparison_op.hpp b/boost/test/tools/collection_comparison_op.hpp
index 9d5a7d8f7b..396de502f8 100644
--- a/boost/test/tools/collection_comparison_op.hpp
+++ b/boost/test/tools/collection_comparison_op.hpp
@@ -16,6 +16,7 @@
#include <boost/test/tools/assertion.hpp>
#include <boost/test/utils/is_forward_iterable.hpp>
+#include <boost/test/utils/is_cstring.hpp>
// Boost
#include <boost/mpl/bool.hpp>
@@ -52,7 +53,10 @@ namespace op {
template <typename OP, bool can_be_equal, bool prefer_shorter,
typename Lhs, typename Rhs>
-inline assertion_result
+inline
+typename boost::enable_if_c<
+ unit_test::is_forward_iterable<Lhs>::value && unit_test::is_forward_iterable<Rhs>::value,
+ assertion_result>::type
lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
{
assertion_result ar( true );
@@ -85,7 +89,6 @@ lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
return ar;
}
-
if( first1 != last1 ) {
if( prefer_shorter ) {
ar = false;
@@ -106,6 +109,23 @@ lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
return ar;
}
+template <typename OP, bool can_be_equal, bool prefer_shorter,
+ typename Lhs, typename Rhs>
+inline
+typename boost::enable_if_c<
+ (!unit_test::is_forward_iterable<Lhs>::value && unit_test::is_cstring<Lhs>::value) ||
+ (!unit_test::is_forward_iterable<Rhs>::value && unit_test::is_cstring<Rhs>::value),
+ assertion_result>::type
+lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
+{
+ typedef typename unit_test::deduce_cstring<Lhs>::type lhs_char_type;
+ typedef typename unit_test::deduce_cstring<Rhs>::type rhs_char_type;
+
+ return lexicographic_compare<OP, can_be_equal, prefer_shorter>(
+ boost::unit_test::basic_cstring<lhs_char_type>(lhs),
+ boost::unit_test::basic_cstring<rhs_char_type>(rhs));
+}
+
//____________________________________________________________________________//
// ************************************************************************** //
@@ -113,7 +133,10 @@ lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
// ************************************************************************** //
template <typename OP, typename Lhs, typename Rhs>
-inline assertion_result
+inline
+typename boost::enable_if_c<
+ unit_test::is_forward_iterable<Lhs>::value && unit_test::is_forward_iterable<Rhs>::value,
+ assertion_result>::type
element_compare( Lhs const& lhs, Rhs const& rhs )
{
assertion_result ar( true );
@@ -144,6 +167,22 @@ element_compare( Lhs const& lhs, Rhs const& rhs )
return ar;
}
+// In case string comparison is branching here
+template <typename OP, typename Lhs, typename Rhs>
+inline
+typename boost::enable_if_c<
+ (!unit_test::is_forward_iterable<Lhs>::value && unit_test::is_cstring<Lhs>::value) ||
+ (!unit_test::is_forward_iterable<Rhs>::value && unit_test::is_cstring<Rhs>::value),
+ assertion_result>::type
+element_compare( Lhs const& lhs, Rhs const& rhs )
+{
+ typedef typename unit_test::deduce_cstring<Lhs>::type lhs_char_type;
+ typedef typename unit_test::deduce_cstring<Rhs>::type rhs_char_type;
+
+ return element_compare<OP>(boost::unit_test::basic_cstring<lhs_char_type>(lhs),
+ boost::unit_test::basic_cstring<rhs_char_type>(rhs));
+}
+
//____________________________________________________________________________//
// ************************************************************************** //
@@ -328,8 +367,10 @@ compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<op::GE<L, R> >*
#define DEFINE_COLLECTION_COMPARISON( oper, name, rev ) \
template<typename Lhs,typename Rhs> \
struct name<Lhs,Rhs,typename boost::enable_if_c< \
- unit_test::is_forward_iterable<Lhs>::value && \
- unit_test::is_forward_iterable<Rhs>::value>::type> { \
+ unit_test::is_forward_iterable<Lhs>::value \
+ && !unit_test::is_cstring<Lhs>::value \
+ && unit_test::is_forward_iterable<Rhs>::value \
+ && !unit_test::is_cstring<Rhs>::value>::type> { \
public: \
typedef assertion_result result_type; \
\
diff --git a/boost/test/tools/cstring_comparison_op.hpp b/boost/test/tools/cstring_comparison_op.hpp
index 0aaf997b5d..09cbf267e2 100644
--- a/boost/test/tools/cstring_comparison_op.hpp
+++ b/boost/test/tools/cstring_comparison_op.hpp
@@ -30,8 +30,6 @@ namespace test_tools {
namespace assertion {
namespace op {
-
-
// ************************************************************************** //
// ************** string_compare ************** //
// ************************************************************************** //
@@ -39,19 +37,17 @@ namespace op {
#define DEFINE_CSTRING_COMPARISON( oper, name, rev ) \
template<typename Lhs,typename Rhs> \
struct name<Lhs,Rhs,typename boost::enable_if_c< \
- unit_test::is_cstring<Lhs>::value && \
- unit_test::is_cstring<Rhs>::value>::type> { \
- typedef typename boost::add_const< \
- typename remove_pointer< \
- typename decay<Lhs>::type>::type>::type \
- lhs_char_type; \
- typedef typename boost::add_const< \
- typename remove_pointer< \
- typename decay<Rhs>::type>::type>::type \
- rhs_char_type; \
+ ( unit_test::is_cstring<Lhs>::value \
+ && unit_test::is_cstring<Rhs>::value) \
+ >::type > \
+{ \
+ typedef typename unit_test::deduce_cstring<Lhs>::type lhs_char_type; \
+ typedef typename unit_test::deduce_cstring<Rhs>::type rhs_char_type; \
public: \
typedef assertion_result result_type; \
\
+ typedef name<lhs_char_type, rhs_char_type> elem_op; \
+ \
static bool \
eval( Lhs const& lhs, Rhs const& rhs) \
{ \
diff --git a/boost/test/tools/fpc_op.hpp b/boost/test/tools/fpc_op.hpp
index da143aa9f3..18364a27b9 100644
--- a/boost/test/tools/fpc_op.hpp
+++ b/boost/test/tools/fpc_op.hpp
@@ -178,16 +178,22 @@ public: \
eval( Lhs const& lhs, Rhs const& rhs ) \
{ \
if( lhs == 0 ) \
+ { \
return compare_fpv_near_zero( rhs, (OP*)0 ); \
+ } \
\
if( rhs == 0 ) \
+ { \
return compare_fpv_near_zero( lhs, (OP*)0 ); \
+ } \
\
bool direct_res = eval_direct( lhs, rhs ); \
\
if( (direct_res && fpctraits<OP>::cmp_direct) || \
fpc_tolerance<FPT>() == FPT(0) ) \
+ { \
return direct_res; \
+ } \
\
return compare_fpv<FPT>( lhs, rhs, (OP*)0 ); \
} \
diff --git a/boost/test/tree/test_case_template.hpp b/boost/test/tree/test_case_template.hpp
index 56871b7b6b..6a1fc3e57b 100644
--- a/boost/test/tree/test_case_template.hpp
+++ b/boost/test/tree/test_case_template.hpp
@@ -5,11 +5,8 @@
// See http://www.boost.org/libs/test for the library home page.
//
-// File : $RCSfile$
-//
-// Version : $Revision: -1 $
-//
-// Description : defines template_test_case_gen
+///@ file
+/// Defines template_test_case_gen
// ***************************************************************************
#ifndef BOOST_TEST_TREE_TEST_CASE_TEMPLATE_HPP_091911GER
@@ -34,10 +31,10 @@
#include <boost/type_traits/is_const.hpp>
#include <boost/function/function0.hpp>
-#ifndef BOOST_NO_RTTI
-#include <typeinfo> // for typeid
+#if defined(BOOST_NO_TYPEID) || defined(BOOST_NO_RTTI)
+# include <boost/current_function.hpp>
#else
-#include <boost/current_function.hpp>
+# include <boost/core/demangle.hpp>
#endif
// STL
@@ -82,8 +79,8 @@ struct generate_test_case_4_type {
std::string full_name;
assign_op( full_name, m_test_case_name, 0 );
full_name += '<';
-#ifndef BOOST_NO_RTTI
- full_name += typeid(TestType).name();
+#if !defined(BOOST_NO_TYPEID) && !defined(BOOST_NO_RTTI)
+ full_name += boost::core::demangle(typeid(TestType).name()); // same as execution_monitor.ipp
#else
full_name += BOOST_CURRENT_FUNCTION;
#endif
diff --git a/boost/test/unit_test_log_formatter.hpp b/boost/test/unit_test_log_formatter.hpp
index 5a9d6bada5..77fec40aed 100644
--- a/boost/test/unit_test_log_formatter.hpp
+++ b/boost/test/unit_test_log_formatter.hpp
@@ -165,16 +165,16 @@ public:
/// @param[in] os output stream to write a messages into
/// @param[in] tu skipped test unit
/// @param[in] reason explanation why was it skipped
- virtual void test_unit_skipped( std::ostream& os, test_unit const& tu, const_string reason )
+ virtual void test_unit_skipped( std::ostream& os, test_unit const& tu, const_string /* reason */)
{
test_unit_skipped( os, tu );
}
/// Deprecated version of this interface
- virtual void test_unit_skipped( std::ostream& os, test_unit const& tu ) {}
+ virtual void test_unit_skipped( std::ostream& /* os */, test_unit const& /* tu */) {}
/// Invoked when a test unit is aborted
- virtual void test_unit_aborted( std::ostream& os, test_unit const& tu ) {}
+ virtual void test_unit_aborted( std::ostream& /* os */, test_unit const& /* tu */) {}
// @}
diff --git a/boost/test/unit_test_parameters.hpp b/boost/test/unit_test_parameters.hpp
index d6fecf0b8a..4ac4eaee1f 100644
--- a/boost/test/unit_test_parameters.hpp
+++ b/boost/test/unit_test_parameters.hpp
@@ -17,7 +17,7 @@
// Boost.Test
#include <boost/test/detail/global_typedef.hpp>
#include <boost/test/utils/runtime/argument.hpp>
-#include <boost/make_shared.hpp>
+#include <boost/make_shared.hpp>
// STL
#include <iostream>
diff --git a/boost/test/utils/is_cstring.hpp b/boost/test/utils/is_cstring.hpp
index 75af0f348d..914c7cf673 100644
--- a/boost/test/utils/is_cstring.hpp
+++ b/boost/test/utils/is_cstring.hpp
@@ -20,6 +20,10 @@
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/decay.hpp>
#include <boost/type_traits/remove_pointer.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/type_traits/add_const.hpp>
+
+#include <string>
//____________________________________________________________________________//
@@ -47,11 +51,38 @@ struct is_cstring_impl<char*> : public mpl::true_ {};
template<>
struct is_cstring_impl<wchar_t*> : public mpl::true_ {};
+template <typename T>
+struct deduce_cstring_impl {
+ typedef typename boost::add_const<
+ typename boost::remove_pointer<
+ typename boost::decay<T>::type
+ >::type
+ >::type type;
+};
+
+template <typename T>
+struct deduce_cstring_impl< std::basic_string<T, std::char_traits<T> > > {
+ // const is required here
+ typedef typename boost::add_const<T>::type type;
+};
+
} // namespace ut_detail
template<typename T>
struct is_cstring : public ut_detail::is_cstring_impl<typename decay<T>::type> {};
+template<typename T>
+struct is_cstring< std::basic_string<T, std::char_traits<T> > > : public mpl::true_ {};
+
+template <class T>
+struct deduce_cstring {
+ typedef typename
+ boost::remove_const<
+ typename boost::remove_reference<T>::type
+ >::type U;
+ typedef typename ut_detail::deduce_cstring_impl<U>::type type;
+};
+
} // namespace unit_test
} // namespace boost
diff --git a/boost/test/utils/is_forward_iterable.hpp b/boost/test/utils/is_forward_iterable.hpp
index a7259b82c3..b218e96cba 100644
--- a/boost/test/utils/is_forward_iterable.hpp
+++ b/boost/test/utils/is_forward_iterable.hpp
@@ -77,6 +77,11 @@ struct is_forward_iterable< std::map<K, V, C, A> > : public mpl::true_ {};
template<typename K, typename C, typename A>
struct is_forward_iterable< std::set<K, C, A> > : public mpl::true_ {};
+// string is also forward iterable, even if sometimes we want to treat the
+// assertions differently.
+template<>
+struct is_forward_iterable< std::string > : public mpl::true_ {};
+
#else
namespace ut_detail {
diff --git a/boost/test/utils/iterator/token_iterator.hpp b/boost/test/utils/iterator/token_iterator.hpp
index abc530041d..e3a923a2ee 100644
--- a/boost/test/utils/iterator/token_iterator.hpp
+++ b/boost/test/utils/iterator/token_iterator.hpp
@@ -300,8 +300,12 @@ public:
this->init();
}
- template<typename Src, typename Modifier>
- basic_string_token_iterator( Src src, Modifier const& m )
+ // warning: making the constructor accept anything else than a cstring should
+ // ensure that no temporary object is created during string creation (previous
+ // definition was "template<typename Src, typename Modifier> basic_string_token_iterator( Src src ..."
+ // which may create a temporary string copy when called with an std::string.
+ template<typename Modifier>
+ basic_string_token_iterator( cstring src, Modifier const& m )
: m_src( src )
{
this->apply_modifier( m );
diff --git a/boost/test/utils/runtime/cla/parser.hpp b/boost/test/utils/runtime/cla/parser.hpp
index effde33a52..9fe8e1bbd9 100644
--- a/boost/test/utils/runtime/cla/parser.hpp
+++ b/boost/test/utils/runtime/cla/parser.hpp
@@ -23,6 +23,7 @@
#include <boost/test/utils/foreach.hpp>
#include <boost/test/utils/algorithm.hpp>
#include <boost/test/detail/throw_exception.hpp>
+#include <boost/test/detail/global_typedef.hpp>
#include <boost/algorithm/cxx11/all_of.hpp> // !! ?? unnecessary after cxx11
@@ -254,7 +255,37 @@ public:
return tr.remainder();
}
- // help/usage
+ // help/usage/version
+ void
+ version( std::ostream& ostr )
+ {
+ ostr << "Boost.Test module ";
+
+#if defined(BOOST_TEST_MODULE)
+ // we do not want to refer to the master test suite there
+ ostr << '\'' << BOOST_TEST_STRINGIZE( BOOST_TEST_MODULE ).trim( "\"" ) << "' ";
+#endif
+
+ ostr << "in executable '" << m_program_name << "'\n";
+ ostr << "Compiled from Boost version "
+ << BOOST_VERSION/100000 << "."
+ << BOOST_VERSION/100 % 1000 << "."
+ << BOOST_VERSION % 100 ;
+ ostr << " with ";
+#if defined(BOOST_TEST_INCLUDED)
+ ostr << "single header inclusion of";
+#elif defined(BOOST_TEST_DYN_LINK)
+ ostr << "dynamic linking to";
+#else
+ ostr << "static linking to";
+#endif
+ ostr << " Boost.Test\n";
+ ostr << "- Compiler: " << BOOST_COMPILER << '\n'
+ << "- Platform: " << BOOST_PLATFORM << '\n'
+ << "- STL : " << BOOST_STDLIB;
+ ostr << std::endl;
+ }
+
void
usage( std::ostream& ostr, cstring param_name = cstring() )
{
diff --git a/boost/test/utils/runtime/parameter.hpp b/boost/test/utils/runtime/parameter.hpp
index c198688493..f11ce9813c 100644
--- a/boost/test/utils/runtime/parameter.hpp
+++ b/boost/test/utils/runtime/parameter.hpp
@@ -220,7 +220,7 @@ protected:
private:
/// interface for usage/help customization
- virtual void cla_name_help( std::ostream& ostr, cstring cla_tag, cstring negation_prefix_ ) const
+ virtual void cla_name_help( std::ostream& ostr, cstring cla_tag, cstring /* negation_prefix_ */) const
{
ostr << cla_tag;
}