diff --git a/include/boost/test/impl/framework.ipp b/include/boost/test/impl/framework.ipp index e78f88b9..f7108280 100644 --- a/include/boost/test/impl/framework.ipp +++ b/include/boost/test/impl/framework.ipp @@ -392,7 +392,7 @@ parse_filters( test_unit_id master_tu_id, test_unit_id_list& tu_to_enable, test_ // 10. collect tu to enable and disable based on filters bool had_selector_filter = false; - auto const& filters = runtime_config::get>( runtime_config::RUN_FILTERS ); + std::vector const& filters = runtime_config::get >( runtime_config::RUN_FILTERS ); BOOST_TEST_FOREACH( const_string, filter, filters ) { BOOST_TEST_SETUP_ASSERT( !filter.is_empty(), "Invalid filter specification" ); @@ -537,7 +537,7 @@ public: test_unit_id_list tu_to_disable; // 10. If there are any filters supplied, figure out lists of test units to enable/disable - bool had_selector_filter = !runtime_config::get>( runtime_config::RUN_FILTERS ).empty() && + bool had_selector_filter = !runtime_config::get >( runtime_config::RUN_FILTERS ).empty() && parse_filters( master_tu_id, tu_to_enable, tu_to_disable ); // 20. Set the stage: either use default run status or disable all test units @@ -1196,7 +1196,7 @@ run( test_unit_id id, bool continue_test ) test_case_counter tcc; traverse_test_tree( id, tcc ); - BOOST_TEST_SETUP_ASSERT( tcc.p_count != 0 , runtime_config::get>( runtime_config::RUN_FILTERS ).empty() + BOOST_TEST_SETUP_ASSERT( tcc.p_count != 0 , runtime_config::get >( runtime_config::RUN_FILTERS ).empty() ? BOOST_TEST_L( "test tree is empty" ) : BOOST_TEST_L( "no test cases matching filter or all test cases were disabled" ) ); diff --git a/include/boost/test/impl/unit_test_parameters.ipp b/include/boost/test/impl/unit_test_parameters.ipp index ade5a092..0650d799 100644 --- a/include/boost/test/impl/unit_test_parameters.ipp +++ b/include/boost/test/impl/unit_test_parameters.ipp @@ -125,10 +125,13 @@ register_parameters( rt::parameters_store& store ) rt::parameter break_exec_path( BREAK_EXEC_PATH, ( rt::description = "For the exception safety testing allows to break at specific execution path.", - rt::env_var = "BOOST_TEST_BREAK_EXEC_PATH", + rt::env_var = "BOOST_TEST_BREAK_EXEC_PATH" +#ifndef BOOST_NO_CXX11_LAMBDAS + , rt::callback = [](rt::cstring) { BOOST_TEST_SETUP_ASSERT( false, "parameter break_exec_path is disabled in this release" ); } +#endif )); break_exec_path.add_cla_id( "--", BREAK_EXEC_PATH, "=" ); @@ -223,10 +226,18 @@ register_parameters( rt::parameters_store& store ) rt::env_var = "BOOST_TEST_LIST_CONTENT", rt::default_value = OF_INVALID, rt::optional_value = OF_CLF, - rt::enum_values::value = { + rt::enum_values::value = +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + { { "HRF", OF_CLF }, { "DOT", OF_DOT } }, +#else + rt::enum_values_list() + ( "HRF", OF_CLF ) + ( "DOT", OF_DOT ) + , +#endif rt::help = "Parameter " + LIST_CONTENT + " instructs the framework to list the content " "of the test module instead of executing the test cases. Parameter accepts " "optional string value indicating the format of the output. Currently the " @@ -254,11 +265,20 @@ register_parameters( rt::parameters_store& store ) rt::description = "Specifies log format.", rt::env_var = "BOOST_TEST_LOG_FORMAT", rt::default_value = OF_CLF, - rt::enum_values::value = { + rt::enum_values::value = +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + { { "HRF", OF_CLF }, { "CLF", OF_CLF }, { "XML", OF_XML } }, +#else + rt::enum_values_list() + ( "HRF", OF_CLF ) + ( "CLF", OF_CLF ) + ( "XML", OF_XML ) + , +#endif rt::help = "Parameter " + LOG_FORMAT + " allows to set the frameowrk's log format to one " "of the formats supplied by the framework. The only acceptable values for this " "parameter are the names of the output formats supplied by the framework. By " @@ -277,7 +297,9 @@ register_parameters( rt::parameters_store& store ) rt::description = "Specifies log level.", rt::env_var = "BOOST_TEST_LOG_LEVEL", rt::default_value = log_all_errors, - rt::enum_values::value = { + rt::enum_values::value = +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + { { "all" , log_successful_tests }, { "success" , log_successful_tests }, { "test_suite" , log_test_units }, @@ -290,6 +312,21 @@ register_parameters( rt::parameters_store& store ) { "fatal_error" , log_fatal_errors }, { "nothing" , log_nothing } }, +#else + rt::enum_values_list() + ( "all" , log_successful_tests ) + ( "success" , log_successful_tests ) + ( "test_suite" , log_test_units ) + ( "unit_scope" , log_test_units ) + ( "message" , log_messages ) + ( "warning" , log_warnings ) + ( "error" , log_all_errors ) + ( "cpp_exception" , log_cpp_exception_errors ) + ( "system_error" , log_system_errors ) + ( "fatal_error" , log_fatal_errors ) + ( "nothing" , log_nothing ) + , +#endif rt::help = "Parameter " + LOG_LEVEL + " allows to set the framework's log level. " "Log level defines the verbosity of testing log produced by a testing " "module. The verbosity ranges from a complete log, when all assertions " @@ -323,11 +360,20 @@ register_parameters( rt::parameters_store& store ) rt::enum_parameter output_format( OUTPUT_FORMAT, ( rt::description = "Specifies output format (both log and report).", rt::env_var = "BOOST_TEST_OUTPUT_FORMAT", - rt::enum_values::value = { + rt::enum_values::value = +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + { { "HRF", OF_CLF }, { "CLF", OF_CLF }, { "XML", OF_XML } }, +#else + rt::enum_values_list() + ( "HRF", OF_CLF ) + ( "CLF", OF_CLF ) + ( "XML", OF_XML ) + , +#endif rt::help = "Parameter " + OUTPUT_FORMAT + " combines an effect of " + REPORT_FORMAT + " and " + LOG_FORMAT + " parameters. This parameter has higher priority " "than either one of them. In other words if this parameter is specified " @@ -369,11 +415,20 @@ register_parameters( rt::parameters_store& store ) rt::description = "Specifies report format.", rt::env_var = "BOOST_TEST_REPORT_FORMAT", rt::default_value = OF_CLF, - rt::enum_values::value = { + rt::enum_values::value = +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + { { "HRF", OF_CLF }, { "CLF", OF_CLF }, { "XML", OF_XML } }, +#else + rt::enum_values_list() + ( "HRF", OF_CLF ) + ( "CLF", OF_CLF ) + ( "XML", OF_XML ) + , +#endif rt::help = "Parameter " + REPORT_FORMAT + " allows to set the framework's report format " "to one of the formats supplied by the framework. The only acceptable values " "for this parameter are the names of the output formats. By default the framework " @@ -392,12 +447,22 @@ register_parameters( rt::parameters_store& store ) rt::description = "Specifies report level.", rt::env_var = "BOOST_TEST_REPORT_LEVEL", rt::default_value = CONFIRMATION_REPORT, - rt::enum_values::value = { + rt::enum_values::value = +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + { { "confirm", CONFIRMATION_REPORT }, { "short", SHORT_REPORT }, { "detailed", DETAILED_REPORT }, { "no", NO_REPORT } }, +#else + rt::enum_values_list() + ( "confirm", CONFIRMATION_REPORT ) + ( "short", SHORT_REPORT ) + ( "detailed", DETAILED_REPORT ) + ( "no", NO_REPORT ) + , +#endif rt::help = "Parameter " + REPORT_LEVEL + " allows to set the verbosity level of the " "testing result report generated by the framework. Use value 'no' to " "eliminate the results report completely." diff --git a/include/boost/test/utils/named_params.hpp b/include/boost/test/utils/named_params.hpp index e007e9a8..ebd5a6a7 100644 --- a/include/boost/test/utils/named_params.hpp +++ b/include/boost/test/utils/named_params.hpp @@ -66,7 +66,7 @@ template struct is_named_param_pack > : public mpl::true_ {}; template -struct is_named_param_pack> : public mpl::true_ {}; +struct is_named_param_pack > : public mpl::true_ {}; // ************************************************************************** // // ************** param_type ************** // @@ -202,7 +202,7 @@ struct named_parameter_combine void erase( keyword kw ) const { m_param.erase( kw ); } using Rest::erase; - using nfp_detail::named_parameter_base>::operator,; + using nfp_detail::named_parameter_base >::operator,; // Visitation support template @@ -364,8 +364,8 @@ opt_get( Params const& p, Keyword k, T default_val ) // ************************************************************************** // template -inline typename enable_if_c>::value, -named_parameter_combine>::type +inline typename enable_if_c >::value, +named_parameter_combine >::type opt_append( Params const& params, NP const& np ) { return (params,np); @@ -374,7 +374,7 @@ opt_append( Params const& params, NP const& np ) //____________________________________________________________________________// template -inline typename enable_if_c>::value,Params>::type +inline typename enable_if_c >::value,Params>::type opt_append( Params const& params, NP const& ) { return params; diff --git a/include/boost/test/utils/runtime/argument.hpp b/include/boost/test/utils/runtime/argument.hpp index 8da1a9eb..879ee96f 100644 --- a/include/boost/test/utils/runtime/argument.hpp +++ b/include/boost/test/utils/runtime/argument.hpp @@ -95,15 +95,17 @@ public: template T& get( cstring parameter_name ) { - auto found = m_arguments.find( parameter_name ); + storage_type::const_iterator found = m_arguments.find( parameter_name ); BOOST_TEST_I_ASSRT( found != m_arguments.end(), - access_to_missing_argument() - << "There is no argument provided for parameter " << parameter_name ); + access_to_missing_argument() + << "There is no argument provided for parameter " + << parameter_name ); argument_ptr arg = found->second; BOOST_TEST_I_ASSRT( arg->p_value_type == rtti::type_id(), - arg_type_mismatch() << "Access with invalid type for argument corresponding to parameter " + arg_type_mismatch() + << "Access with invalid type for argument corresponding to parameter " << parameter_name ); return static_cast&>( *arg ).p_value.value; diff --git a/include/boost/test/utils/runtime/argument_factory.hpp b/include/boost/test/utils/runtime/argument_factory.hpp index 0cf331c2..fdd6c2f3 100644 --- a/include/boost/test/utils/runtime/argument_factory.hpp +++ b/include/boost/test/utils/runtime/argument_factory.hpp @@ -128,17 +128,25 @@ template struct value_interpreter { template explicit value_interpreter( Modifiers const& m ) +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST : m_name_to_value( m[enum_values::value] ) { } +#else + { + std::vector > const& values = m[enum_values::value]; + + m_name_to_value.insert( values.begin(), values.end() ); + } +#endif EnumType interpret( cstring param_name, cstring source ) const { - auto found = m_name_to_value.find( source ); + typename std::map::const_iterator found = m_name_to_value.find( source ); BOOST_TEST_I_ASSRT( found != m_name_to_value.end(), format_error( param_name ) << source << - " is not a valid enumeration value name for parameter " << param_name << "." ); + " is not a valid enumeration value name for parameter " << param_name << "." ); return found->second; } @@ -165,8 +173,8 @@ public: template explicit argument_factory( Modifiers const& m ) : m_interpreter( m ) - , m_optional_value( nfp::opt_get( m, optional_value, ValueType{} ) ) - , m_default_value( nfp::opt_get( m, default_value, ValueType{} ) ) + , m_optional_value( nfp::opt_get( m, optional_value, ValueType() ) ) + , m_default_value( nfp::opt_get( m, default_value, ValueType() ) ) { } @@ -204,7 +212,7 @@ public: ValueType value = m_interpreter.interpret( param_name, source ); if( store.has( param_name ) ) { - std::vector& values = store.get>( param_name ); + std::vector& values = store.get >( param_name ); values.push_back( value ); } else { @@ -216,7 +224,7 @@ public: } void produce_default( cstring param_name, arguments_store& store ) const { - store.set( param_name, std::vector{} ); + store.set( param_name, std::vector() ); } private: diff --git a/include/boost/test/utils/runtime/cla/parser.hpp b/include/boost/test/utils/runtime/cla/parser.hpp index 734f4d2f..44cd9df6 100644 --- a/include/boost/test/utils/runtime/cla/parser.hpp +++ b/include/boost/test/utils/runtime/cla/parser.hpp @@ -24,8 +24,11 @@ #include #include +#include // !! ?? unnecessary after cxx11 + // STL -#include +// !! ?? #include +#include #include @@ -42,7 +45,7 @@ namespace rt_cla_detail { struct parameter_trie; typedef shared_ptr parameter_trie_ptr; typedef std::map trie_per_char; -typedef std::vector> param_cla_id_list; +typedef std::vector > param_cla_id_list; struct parameter_trie { parameter_trie() : m_has_final_candidate( false ) {} @@ -77,7 +80,7 @@ struct parameter_trie { << "parameter cla id " << m_id_candidates.back().get().m_tag ); m_has_final_candidate = final; - m_id_candidates.push_back( param_id ); + m_id_candidates.push_back( ref(param_id) ); if( m_id_candidates.size() == 1 ) m_param_candidate = param_candidate; @@ -110,20 +113,25 @@ class parser { public: /// Initializes a parser and builds internal trie representation used for /// parsing based on the supplied parameters +#ifndef BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS template parser( parameters_store const& parameters, Modifiers const& m = nfp::no_params ) +#else + template + parser( parameters_store const& parameters, Modifiers const& m ) +#endif { nfp::opt_assign( m_end_of_param_indicator, m, end_of_params ); nfp::opt_assign( m_negation_prefix, m, negation_prefix ); - BOOST_TEST_I_ASSRT( std::all_of( m_end_of_param_indicator.begin(), - m_end_of_param_indicator.end(), - parameter_cla_id::valid_prefix_char ), + BOOST_TEST_I_ASSRT( algorithm::all_of( m_end_of_param_indicator.begin(), + m_end_of_param_indicator.end(), + parameter_cla_id::valid_prefix_char ), invalid_cla_id() << "End of parameters indicator can only consist of prefix characters." ); - BOOST_TEST_I_ASSRT( std::all_of( m_negation_prefix.begin(), - m_negation_prefix.end(), - parameter_cla_id::valid_name_char ), + BOOST_TEST_I_ASSRT( algorithm::all_of( m_negation_prefix.begin(), + m_negation_prefix.end(), + parameter_cla_id::valid_name_char ), invalid_cla_id() << "Negation prefix can only consist of prefix characters." ); build_trie( parameters ); @@ -137,8 +145,8 @@ public: m_program_name = argv[0]; cstring path_sep( "\\/" ); - auto it = unit_test::utils::find_last_of( m_program_name.begin(), m_program_name.end(), - path_sep.begin(), path_sep.end() ); + cstring::iterator it = unit_test::utils::find_last_of( m_program_name.begin(), m_program_name.end(), + path_sep.begin(), path_sep.end() ); if( it != m_program_name.end() ) m_program_name.trim_left( it + 1 ); @@ -172,7 +180,7 @@ public: tr.skip( prefix.size() ); // Locate parameter based on a name and skip it in the input - auto locate_res = locate_parameter( curr_trie, name, curr_token ); + locate_result locate_res = locate_parameter( curr_trie, name, curr_token ); parameter_cla_id const& found_id = locate_res.first; basic_param_ptr found_param = locate_res.second; @@ -229,10 +237,10 @@ public: usage( std::ostream& ostr, cstring param_name = cstring() ) { if( !param_name.is_empty() ) { - auto param = locate_parameter( m_param_trie[help_prefix], param_name, "" ).second; + basic_param_ptr param = locate_parameter( m_param_trie[help_prefix], param_name, "" ).second; param->usage( ostr, m_negation_prefix ); } - else { + else { ostr << "Usage: " << m_program_name << " [Boost.Test argument]... "; if( !m_end_of_param_indicator.empty() ) ostr << m_end_of_param_indicator << " [custom test module argument]..."; @@ -249,7 +257,7 @@ public: help( std::ostream& ostr, parameters_store const& parameters, cstring param_name ) { if( !param_name.is_empty() ) { - auto param = locate_parameter( m_param_trie[help_prefix], param_name, "" ).second; + basic_param_ptr param = locate_parameter( m_param_trie[help_prefix], param_name, "" ).second; param->help( ostr, m_negation_prefix ); return; } @@ -313,7 +321,7 @@ private: validate_token_format( cstring token, cstring& prefix, cstring& name, cstring& separator, bool& negative_form ) { // Match prefix - auto it = token.begin(); + cstring::iterator it = token.begin(); while( it != token.end() && parameter_cla_id::valid_prefix_char( *it ) ) ++it; @@ -396,9 +404,9 @@ private: if( !curr_trie ) { std::vector typo_candidate_names; - std::unordered_set unique_typo_candidate; + std::set unique_typo_candidate; // !! ?? unordered_set typo_candidate_names.reserve( typo_candidates.size() ); - unique_typo_candidate.reserve( typo_candidates.size() ); +// !! ?? unique_typo_candidate.reserve( typo_candidates.size() ); BOOST_TEST_FOREACH( trie_ptr, trie_cand, typo_candidates ) { // avoid ambiguos candidate trie @@ -413,9 +421,15 @@ private: } } +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES BOOST_TEST_I_THROW( unrecognized_param( std::move(typo_candidate_names) ) - << "An unrecognized parameter in the argument " - << token ); + << "An unrecognized parameter in the argument " + << token ); +#else + BOOST_TEST_I_THROW( unrecognized_param( typo_candidate_names ) + << "An unrecognized parameter in the argument " + << token ); +#endif } if( curr_trie->m_id_candidates.size() > 1 ) { @@ -423,8 +437,13 @@ private: BOOST_TEST_FOREACH( parameter_cla_id const&, param_id, curr_trie->m_id_candidates ) amb_names.push_back( param_id.m_tag ); - BOOST_TEST_I_THROW( ambiguous_param( std::move( amb_names ) ) << - "An ambiguous parameter name in the argument " << token ); +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_TEST_I_THROW( ambiguous_param( std::move( amb_names ) ) + << "An ambiguous parameter name in the argument " << token ); +#else + BOOST_TEST_I_THROW( ambiguous_param( amb_names ) + << "An ambiguous parameter name in the argument " << token ); +#endif } return locate_result( curr_trie->m_id_candidates.back().get(), curr_trie->m_param_candidate ); diff --git a/include/boost/test/utils/runtime/env/fetch.hpp b/include/boost/test/utils/runtime/env/fetch.hpp index d20ad10f..b0c6bead 100644 --- a/include/boost/test/utils/runtime/env/fetch.hpp +++ b/include/boost/test/utils/runtime/env/fetch.hpp @@ -72,7 +72,7 @@ fetch_absent( parameters_store const& params, runtime::arguments_store& args, Re if( args.has( param->p_name ) || param->p_env_var.empty() ) continue; - auto value = read_func( param->p_env_var ); + std::pair value = read_func( param->p_env_var ); if( !value.second ) continue; diff --git a/include/boost/test/utils/runtime/errors.hpp b/include/boost/test/utils/runtime/errors.hpp index 85d05ff7..a3654ab5 100644 --- a/include/boost/test/utils/runtime/errors.hpp +++ b/include/boost/test/utils/runtime/errors.hpp @@ -21,8 +21,8 @@ // Boost.Test #include -// Boost -#include +// Boost.Test +#include // STL #include @@ -39,6 +39,8 @@ namespace runtime { class param_error : public std::exception { public: + ~param_error() BOOST_NOEXCEPT_OR_NOTHROW {} + virtual const char * what() const BOOST_NOEXCEPT_OR_NOTHROW { return msg.c_str(); @@ -56,10 +58,13 @@ protected: class init_error : public param_error { protected: explicit init_error( cstring param_name ) : param_error( param_name ) {} + ~init_error() BOOST_NOEXCEPT_OR_NOTHROW {} }; + class input_error : public param_error { protected: explicit input_error( cstring param_name ) : param_error( param_name ) {} + ~input_error() BOOST_NOEXCEPT_OR_NOTHROW {} }; //____________________________________________________________________________// @@ -68,10 +73,13 @@ template class specific_param_error : public Base { protected: explicit specific_param_error( cstring param_name ) : Base( param_name ) {} + ~specific_param_error() BOOST_NOEXCEPT_OR_NOTHROW {} }; //____________________________________________________________________________// +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + template inline Derived operator<<(specific_param_error&& ex, char const* val) @@ -94,6 +102,32 @@ operator<<(specific_param_error&& ex, T const& val) //____________________________________________________________________________// +#else + +template +inline Derived +operator<<(specific_param_error const& ex, char const* val) +{ + const_cast&>(ex).msg.append( val ); + + return static_cast(ex); +} + +//____________________________________________________________________________// + +template +inline Derived +operator<<(specific_param_error const& ex, T const& val) +{ + const_cast&>(ex).msg.append( unit_test::utils::string_cast( val ) ); + + return static_cast(ex); +} + +//____________________________________________________________________________// + +#endif + // ************************************************************************** // // ************** specific exception types ************** // // ************************************************************************** // @@ -123,18 +157,32 @@ SPECIFIC_EX_TYPE( missing_req_arg, input_error ); class ambiguous_param : public specific_param_error { public: +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES explicit ambiguous_param( std::vector&& amb_candidates ) : specific_param_error( "" ) , m_amb_candidates( std::move( amb_candidates ) ) {} +#else + explicit ambiguous_param( std::vector const& amb_candidates ) + : specific_param_error( "" ) + , m_amb_candidates( amb_candidates ) {} +#endif + ~ambiguous_param() BOOST_NOEXCEPT_OR_NOTHROW {} std::vector m_amb_candidates; }; class unrecognized_param : public specific_param_error { public: +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES explicit unrecognized_param( std::vector&& type_candidates ) : specific_param_error( "" ) , m_typo_candidates( std::move( type_candidates ) ) {} +#else + explicit unrecognized_param( std::vector const& type_candidates ) + : specific_param_error( "" ) + , m_typo_candidates( type_candidates ) {} +#endif + ~unrecognized_param() BOOST_NOEXCEPT_OR_NOTHROW {} std::vector m_typo_candidates; }; diff --git a/include/boost/test/utils/runtime/modifier.hpp b/include/boost/test/utils/runtime/modifier.hpp index 98bb210a..d90ed650 100644 --- a/include/boost/test/utils/runtime/modifier.hpp +++ b/include/boost/test/utils/runtime/modifier.hpp @@ -32,6 +32,8 @@ namespace runtime { namespace { +#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS + auto const& description = unit_test::static_constant>::value; auto const& help = unit_test::static_constant>::value; auto const& env_var = unit_test::static_constant>::value; @@ -47,6 +49,45 @@ using enum_values = unit_test::static_constant< nfp::typed_keyword>, struct enum_values_t> >; +#else + +nfp::typed_keyword description; +nfp::typed_keyword help; +nfp::typed_keyword env_var; +nfp::typed_keyword end_of_params; +nfp::typed_keyword negation_prefix; +nfp::typed_keyword value_hint; +nfp::keyword optional_value; +nfp::keyword default_value; +nfp::keyword callback; + +template +struct enum_values_list { + typedef std::pair ElemT; + typedef std::vector ValuesT; + + enum_values_list const& + operator()( cstring k, EnumType v ) const + { + const_cast(this)->m_values.push_back( ElemT( k, v ) ); + + return *this; + } + + operator ValuesT const&() const { return m_values; } + +private: + ValuesT m_values; +}; + +template +struct enum_values : unit_test::static_constant< + nfp::typed_keyword, struct enum_values_t> > +{ +}; + +#endif + } // local namespace } // namespace runtime diff --git a/include/boost/test/utils/runtime/parameter.hpp b/include/boost/test/utils/runtime/parameter.hpp index 4009e6e4..dca39724 100644 --- a/include/boost/test/utils/runtime/parameter.hpp +++ b/include/boost/test/utils/runtime/parameter.hpp @@ -27,6 +27,7 @@ // Boost #include +#include // STL #include @@ -49,15 +50,15 @@ struct parameter_cla_id { , m_negatable( negatable ) { - BOOST_TEST_I_ASSRT( std::all_of( m_prefix.begin(), m_prefix.end(), valid_prefix_char ), + BOOST_TEST_I_ASSRT( algorithm::all_of( m_prefix.begin(), m_prefix.end(), valid_prefix_char ), invalid_cla_id() << "Parameter " << m_tag << " has invalid characters in prefix." ); - BOOST_TEST_I_ASSRT( std::all_of( m_tag.begin(), m_tag.end(), valid_name_char ), + BOOST_TEST_I_ASSRT( algorithm::all_of( m_tag.begin(), m_tag.end(), valid_name_char ), invalid_cla_id() << "Parameter " << m_tag << " has invalid characters in name." ); - BOOST_TEST_I_ASSRT( std::all_of( m_value_separator.begin(), m_value_separator.end(), valid_separator_char ), + BOOST_TEST_I_ASSRT( algorithm::all_of( m_value_separator.begin(), m_value_separator.end(), valid_separator_char ), invalid_cla_id() << "Parameter " << m_tag << " has invalid characters in value separator." ); } @@ -98,15 +99,15 @@ protected: template basic_param( cstring name, bool is_optional, bool is_repeatable, Modifiers const& m ) : p_name( name.begin(), name.end() ) - , p_description( nfp::opt_get( m, description, std::string{} ) ) - , p_help( nfp::opt_get( m, runtime::help, std::string{} ) ) - , p_env_var( nfp::opt_get( m, env_var, std::string{} ) ) - , p_value_hint( nfp::opt_get( m, value_hint, std::string{} ) ) + , p_description( nfp::opt_get( m, description, std::string() ) ) + , p_help( nfp::opt_get( m, runtime::help, std::string() ) ) + , p_env_var( nfp::opt_get( m, env_var, std::string() ) ) + , p_value_hint( nfp::opt_get( m, value_hint, std::string() ) ) , p_optional( is_optional ) , p_repeatable( is_repeatable ) , p_has_optional_value( m.has( optional_value ) ) , p_has_default_value( m.has( default_value ) || is_repeatable ) - , p_callback( nfp::opt_get( m, callback, callback_type{} ) ) + , p_callback( nfp::opt_get( m, callback, callback_type() ) ) { add_cla_id( help_prefix, name, ":" ); } @@ -251,8 +252,13 @@ template parameter( cstring name, Modifiers const& m = nfp::no_params ) +#else + template + parameter( cstring name, Modifiers const& m ) +#endif : basic_param( name, a != runtime::REQUIRED_PARAM, a == runtime::REPEATABLE_PARAM, m ) , m_arg_factory( m ) { @@ -292,8 +298,13 @@ private: class option : public basic_param { public: /// Constructor with modifiers +#ifndef BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS template option( cstring name, Modifiers const& m = nfp::no_params ) +#else + template + option( cstring name, Modifiers const& m ) +#endif : basic_param( name, true, false, nfp::opt_append( nfp::opt_append( m, optional_value = true), default_value = false) ) , m_arg_factory( nfp::opt_append( nfp::opt_append( m, optional_value = true), default_value = false) ) { @@ -353,12 +364,22 @@ class enum_parameter : public parameter { typedef parameter base; public: /// Constructor with modifiers +#ifndef BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS template enum_parameter( cstring name, Modifiers const& m = nfp::no_params ) +#else + template + enum_parameter( cstring name, Modifiers const& m ) +#endif : base( name, m ) { +#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS auto const& values = m[enum_values::value]; auto it = values.begin(); +#else + std::vector > const& values = m[enum_values::value]; + typename std::vector >::const_iterator it = values.begin(); +#endif while( it != values.end() ) { m_valid_names.push_back( it->first ); ++it; @@ -393,6 +414,7 @@ private: std::vector m_valid_names; }; + // ************************************************************************** // // ************** runtime::parameters_store ************** // // ************************************************************************** // @@ -430,7 +452,7 @@ public: /// Returns map of all the registered parameter basic_param_ptr get( cstring name ) const { - auto const& found = m_parameters.find( name ); + storage_type::const_iterator const& found = m_parameters.find( name ); BOOST_TEST_I_ASSRT( found != m_parameters.end(), unknown_param() << "Parameter " << name << " is unknown." ); diff --git a/include/boost/test/utils/xml_printer.hpp b/include/boost/test/utils/xml_printer.hpp index 1a407e38..914e0c50 100644 --- a/include/boost/test/utils/xml_printer.hpp +++ b/include/boost/test/utils/xml_printer.hpp @@ -42,6 +42,7 @@ namespace utils { inline void print_escaped( std::ostream& where_to, const_string value ) { +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST static std::map const char_type{{ {'<' , "lt"}, {'>' , "gt"}, @@ -49,9 +50,20 @@ print_escaped( std::ostream& where_to, const_string value ) {'\'', "apos"}, {'"' , "quot"} }}; +#else + static std::map char_type; + + if( char_type.empty() ) { + char_type['<'] = "lt"; + char_type['>'] = "gt"; + char_type['&'] = "amp"; + char_type['\'']= "apos"; + char_type['"'] = "quot"; + } +#endif BOOST_TEST_FOREACH( char, c, value ) { - auto found_ref = char_type.find( c ); + std::map::const_iterator found_ref = char_type.find( c ); if( found_ref != char_type.end() ) where_to << '&' << found_ref->second << ';'; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 8b183f7e..e87fa842 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -37,7 +37,7 @@ rule boost.test-self-test ( test-rule : test-suite : test-name : usage-variant ? return [ $(test-rule) $(source_files) ../build//$(usage-variant) $(extra-libs) # gcov - : #args + : -- "" #args : $(pattern_file) : # Activating -pedantic finds more gotchas # Unfortunately, this warns about the use of "long long" in gcc's own stdlib @@ -46,7 +46,7 @@ rule boost.test-self-test ( test-rule : test-suite : test-name : usage-variant ? gcc:-Wno-long-long gcc:-Wno-variadic-macros clang:-Wno-c99-extensions - # gcc:--coverage +# gcc:--coverage all $(extra-options) $(requirements) @@ -98,7 +98,7 @@ test-suite "utils-ts" [ boost.test-self-test run : utils-ts : class_properties-test ] [ boost.test-self-test run : utils-ts : foreach-test ] [ boost.test-self-test run : utils-ts : named_params-test ] - [ boost.test-self-test run : utils-ts : runtime-param-test ] + [ boost.test-self-test run : utils-ts : runtime-param-test : : : : : : [ requires cxx11_auto_declarations cxx11_function_template_default_args cxx11_lambdas cxx11_hdr_initializer_list ] ] [ boost.test-self-test run : utils-ts : string_cast-test ] [ boost.test-self-test run : utils-ts : token_iterator-test ] ; diff --git a/test/baseline-outputs/errors-handling-test.pattern2 b/test/baseline-outputs/errors-handling-test.pattern2 index babc355a..4d04baa1 100644 --- a/test/baseline-outputs/errors-handling-test.pattern2 +++ b/test/baseline-outputs/errors-handling-test.pattern2 @@ -2,14 +2,14 @@ =========================== log level: log_successful_tests; error type: no error; -160: Entering test case "error_on_demand" -95: info: check 'no error' has passed +164: Entering test case "error_on_demand" +99: info: check 'no error' has passed Leaving test case "error_on_demand" =========================== log level: log_successful_tests; error type: user message; -160: Entering test case "error_on_demand" +164: Entering test case "error_on_demand" message Test case error_on_demand did not check any assertions Leaving test case "error_on_demand" @@ -17,43 +17,43 @@ Leaving test case "error_on_demand" =========================== log level: log_successful_tests; error type: user warning; -160: Entering test case "error_on_demand" -103: warning: in "error_on_demand": warning +164: Entering test case "error_on_demand" +107: warning: in "error_on_demand": warning Test case error_on_demand did not check any assertions Leaving test case "error_on_demand" =========================== log level: log_successful_tests; error type: user non-fatal error; -160: Entering test case "error_on_demand" -107: error: in "error_on_demand": non-fatal error +164: Entering test case "error_on_demand" +111: error: in "error_on_demand": non-fatal error Leaving test case "error_on_demand" =========================== log level: log_successful_tests; error type: cpp exception; -160: Entering test case "error_on_demand" +164: Entering test case "error_on_demand" 0: fatal error: in "error_on_demand": std::runtime_error: test std::runtime error what() message -117: last checkpoint: error_on_demand() throw runtime_error +121: last checkpoint: error_on_demand() throw runtime_error Leaving test case "error_on_demand" =========================== log level: log_successful_tests; error type: system error; -160: Entering test case "error_on_demand" -111: fatal error: in "error_on_demand": fatal error +164: Entering test case "error_on_demand" +115: fatal error: in "error_on_demand": fatal error Leaving test case "error_on_demand" =========================== log level: log_test_suites; error type: no error; -160: Entering test case "error_on_demand" +164: Entering test case "error_on_demand" Leaving test case "error_on_demand" =========================== log level: log_test_suites; error type: user message; -160: Entering test case "error_on_demand" +164: Entering test case "error_on_demand" message Test case error_on_demand did not check any assertions Leaving test case "error_on_demand" @@ -61,31 +61,31 @@ Leaving test case "error_on_demand" =========================== log level: log_test_suites; error type: user warning; -160: Entering test case "error_on_demand" -103: warning: in "error_on_demand": warning +164: Entering test case "error_on_demand" +107: warning: in "error_on_demand": warning Test case error_on_demand did not check any assertions Leaving test case "error_on_demand" =========================== log level: log_test_suites; error type: user non-fatal error; -160: Entering test case "error_on_demand" -107: error: in "error_on_demand": non-fatal error +164: Entering test case "error_on_demand" +111: error: in "error_on_demand": non-fatal error Leaving test case "error_on_demand" =========================== log level: log_test_suites; error type: cpp exception; -160: Entering test case "error_on_demand" +164: Entering test case "error_on_demand" 0: fatal error: in "error_on_demand": std::runtime_error: test std::runtime error what() message -117: last checkpoint: error_on_demand() throw runtime_error +121: last checkpoint: error_on_demand() throw runtime_error Leaving test case "error_on_demand" =========================== log level: log_test_suites; error type: system error; -160: Entering test case "error_on_demand" -111: fatal error: in "error_on_demand": fatal error +164: Entering test case "error_on_demand" +115: fatal error: in "error_on_demand": fatal error Leaving test case "error_on_demand" =========================== @@ -101,24 +101,24 @@ Test case error_on_demand did not check any assertions =========================== log level: log_messages; error type: user warning; -103: warning: in "error_on_demand": warning +107: warning: in "error_on_demand": warning Test case error_on_demand did not check any assertions =========================== log level: log_messages; error type: user non-fatal error; -107: error: in "error_on_demand": non-fatal error +111: error: in "error_on_demand": non-fatal error =========================== log level: log_messages; error type: cpp exception; 0: fatal error: in "error_on_demand": std::runtime_error: test std::runtime error what() message -117: last checkpoint: error_on_demand() throw runtime_error +121: last checkpoint: error_on_demand() throw runtime_error =========================== log level: log_messages; error type: system error; -111: fatal error: in "error_on_demand": fatal error +115: fatal error: in "error_on_demand": fatal error =========================== log level: log_warnings; error type: no error; @@ -131,23 +131,23 @@ log level: log_warnings; error type: user message; =========================== log level: log_warnings; error type: user warning; -103: warning: in "error_on_demand": warning +107: warning: in "error_on_demand": warning =========================== log level: log_warnings; error type: user non-fatal error; -107: error: in "error_on_demand": non-fatal error +111: error: in "error_on_demand": non-fatal error =========================== log level: log_warnings; error type: cpp exception; 0: fatal error: in "error_on_demand": std::runtime_error: test std::runtime error what() message -117: last checkpoint: error_on_demand() throw runtime_error +121: last checkpoint: error_on_demand() throw runtime_error =========================== log level: log_warnings; error type: system error; -111: fatal error: in "error_on_demand": fatal error +115: fatal error: in "error_on_demand": fatal error =========================== log level: log_all_errors; error type: no error; @@ -164,18 +164,18 @@ log level: log_all_errors; error type: user warning; =========================== log level: log_all_errors; error type: user non-fatal error; -107: error: in "error_on_demand": non-fatal error +111: error: in "error_on_demand": non-fatal error =========================== log level: log_all_errors; error type: cpp exception; 0: fatal error: in "error_on_demand": std::runtime_error: test std::runtime error what() message -117: last checkpoint: error_on_demand() throw runtime_error +121: last checkpoint: error_on_demand() throw runtime_error =========================== log level: log_all_errors; error type: system error; -111: fatal error: in "error_on_demand": fatal error +115: fatal error: in "error_on_demand": fatal error =========================== log level: log_cpp_exception_errors; error type: no error; @@ -197,12 +197,12 @@ log level: log_cpp_exception_errors; error type: user non-fatal error; log level: log_cpp_exception_errors; error type: cpp exception; 0: fatal error: in "error_on_demand": std::runtime_error: test std::runtime error what() message -117: last checkpoint: error_on_demand() throw runtime_error +121: last checkpoint: error_on_demand() throw runtime_error =========================== log level: log_cpp_exception_errors; error type: system error; -111: fatal error: in "error_on_demand": fatal error +115: fatal error: in "error_on_demand": fatal error =========================== log level: log_system_errors; error type: no error; @@ -227,7 +227,7 @@ log level: log_system_errors; error type: cpp exception; =========================== log level: log_system_errors; error type: system error; -111: fatal error: in "error_on_demand": fatal error +115: fatal error: in "error_on_demand": fatal error =========================== log level: log_fatal_errors; error type: no error; @@ -252,7 +252,7 @@ log level: log_fatal_errors; error type: cpp exception; =========================== log level: log_fatal_errors; error type: system error; -111: fatal error: in "error_on_demand": fatal error +115: fatal error: in "error_on_demand": fatal error =========================== log level: log_nothing; error type: no error; diff --git a/test/utils-ts/named_params-test.cpp b/test/utils-ts/named_params-test.cpp index af8e71ca..11f7575b 100644 --- a/test/utils-ts/named_params-test.cpp +++ b/test/utils-ts/named_params-test.cpp @@ -183,6 +183,11 @@ BOOST_AUTO_TEST_CASE( test_const_arg ) //____________________________________________________________________________// +// the unit tests below assert functionality for non copyable classes, C++11 only +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \ + && !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) \ + && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) + namespace test_mutable_arg { nfp::typed_keyword k1; @@ -212,6 +217,7 @@ BOOST_AUTO_TEST_CASE( test_mutable_arg ) //____________________________________________________________________________// + namespace test_noncopyable_arg { struct NC { @@ -240,6 +246,9 @@ BOOST_AUTO_TEST_CASE( test_noncopyable_arg ) } // test_noncopyable_arg + +#endif /* C++11 only */ + //____________________________________________________________________________// namespace test_required_arg { @@ -378,7 +387,7 @@ nfp::typed_keyword k2; template void dotest0( Params const& p, T& targ ) { - targ = nfp::opt_get( p, k1, T{} ); + targ = nfp::opt_get( p, k1, T() ); } BOOST_AUTO_TEST_CASE( test_optional_get ) @@ -507,6 +516,10 @@ BOOST_AUTO_TEST_CASE( test_optional_append ) //____________________________________________________________________________// +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \ + && !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) \ + && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) + namespace test_no_params { nfp::typed_keyword k1; @@ -524,3 +537,4 @@ BOOST_AUTO_TEST_CASE( test_no_params ) } } // test_no_params +#endif