diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:41:18 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:43:11 +0900 |
commit | f763a99a501650eff2c60288aa6f10ef916d769e (patch) | |
tree | 02af7e13f9a38c888ebf340fe764cbe7dae99da9 /boost/test/data | |
parent | 5cde13f21d36c7224b0e13d11c4b49379ae5210d (diff) | |
download | boost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.gz boost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.bz2 boost-f763a99a501650eff2c60288aa6f10ef916d769e.zip |
Imported Upstream version 1.62.0upstream/1.62.0
Change-Id: I9d4c1ddb7b7d8f0069217ecc582700f9fda6dd4c
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/test/data')
-rw-r--r-- | boost/test/data/for_each_sample.hpp | 4 | ||||
-rw-r--r-- | boost/test/data/test_case.hpp | 55 |
2 files changed, 41 insertions, 18 deletions
diff --git a/boost/test/data/for_each_sample.hpp b/boost/test/data/for_each_sample.hpp index b3bc1ffc78..4785b038cc 100644 --- a/boost/test/data/for_each_sample.hpp +++ b/boost/test/data/for_each_sample.hpp @@ -63,7 +63,9 @@ invoke_action( Action const& action, T&& args, std::true_type /* is_tuple */ ) { invoke_action_impl( action, std::forward<T>(args), - typename make_index_sequence< 0, std::tuple_size<T>::value >::type{} ); + typename make_index_sequence< 0, + std::tuple_size<typename std::decay<T>::type>::value + >::type{} ); } diff --git a/boost/test/data/test_case.hpp b/boost/test/data/test_case.hpp index 9564816ee4..dd9de141c4 100644 --- a/boost/test/data/test_case.hpp +++ b/boost/test/data/test_case.hpp @@ -37,6 +37,7 @@ #include <boost/test/detail/suppress_warnings.hpp> #include <boost/test/tools/detail/print_helper.hpp> +#include <boost/test/utils/string_cast.hpp> #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \ && !defined(BOOST_TEST_DATASET_MAX_ARITY) @@ -122,16 +123,25 @@ public: #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES test_case_gen( const_string tc_name, const_string tc_file, std::size_t tc_line, DataSet&& ds ) : m_tc_name( ut_detail::normalize_test_case_name( tc_name ) ) + , m_tc_file( tc_file ) + , m_tc_line( tc_line ) + , m_tc_index( 0 ) { data::for_each_sample( std::forward<DataSet>( ds ), *this ); } test_case_gen( test_case_gen&& gen ) : m_tc_name( gen.m_tc_name ) + , m_tc_file( gen.m_tc_file ) + , m_tc_line( gen.m_tc_line ) + , m_tc_index( gen.m_tc_index ) , m_test_cases( std::move(gen.m_test_cases) ) {} #else test_case_gen( const_string tc_name, const_string tc_file, std::size_t tc_line, DataSet const& ds ) : m_tc_name( ut_detail::normalize_test_case_name( tc_name ) ) + , m_tc_file( tc_file ) + , m_tc_line( tc_line ) + , m_tc_index( 0 ) { data::for_each_sample( ds, *this ); } @@ -149,24 +159,23 @@ public: } #if !defined(BOOST_TEST_DATASET_VARIADIC) - /// make this variadic -#define TC_MAKE(z,arity,_) \ - template<BOOST_PP_ENUM_PARAMS(arity, typename Arg)> \ - void operator()( BOOST_PP_ENUM_BINARY_PARAMS(arity, Arg, const& arg) ) const \ - { \ - m_test_cases.push_back( new test_case( m_tc_name, m_tc_file, m_tc_line, \ - boost::bind( &TestCase::template test_method<BOOST_PP_ENUM_PARAMS(arity,Arg)>, \ - BOOST_PP_ENUM_PARAMS(arity, arg) ) ) ); \ - } \ + // see BOOST_TEST_DATASET_MAX_ARITY to increase the default supported arity +#define TC_MAKE(z,arity,_) \ + template<BOOST_PP_ENUM_PARAMS(arity, typename Arg)> \ + void operator()( BOOST_PP_ENUM_BINARY_PARAMS(arity, Arg, const& arg) ) const \ + { \ + m_test_cases.push_back( new test_case( genTestCaseName(), m_tc_file, m_tc_line, \ + boost::bind( &TestCase::template test_method<BOOST_PP_ENUM_PARAMS(arity,Arg)>,\ + BOOST_PP_ENUM_PARAMS(arity, arg) ) ) ); \ + } \ BOOST_PP_REPEAT_FROM_TO(1, BOOST_TEST_DATASET_MAX_ARITY, TC_MAKE, _) #else - template<typename ...Arg> void operator()(Arg&& ... arg) const { m_test_cases.push_back( - new test_case( m_tc_name, + new test_case( genTestCaseName(), m_tc_file, m_tc_line, boost::bind( &TestCase::template test_method<Arg...>, @@ -175,10 +184,16 @@ public: #endif private: + std::string genTestCaseName() const + { + return "_" + utils::string_cast(m_tc_index++); + } + // Data members std::string m_tc_name; const_string m_tc_file; std::size_t m_tc_line; + mutable std::size_t m_tc_index; mutable std::list<test_unit*> m_test_cases; }; @@ -217,16 +232,16 @@ make_test_case_gen( const_string tc_name, const_string tc_file, std::size_t tc_l /**/ #define BOOST_DATA_TEST_CASE_IMPL(arity, F, test_name, dataset, params) \ -struct test_name : public F { \ +struct BOOST_PP_CAT(test_name, case) : public F { \ template<BOOST_PP_ENUM_PARAMS(arity, typename Arg)> \ static void test_method( BOOST_DATA_TEST_CASE_PARAMS( params ) ) \ { \ BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture entry.");\ - test_name t; \ + BOOST_PP_CAT(test_name, case) t; \ BOOST_TEST_CHECKPOINT('"' << #test_name << "\" entry."); \ BOOST_TEST_CONTEXT( "" \ BOOST_PP_SEQ_FOR_EACH(BOOST_DATA_TEST_CONTEXT, _, params)) \ - t._impl(BOOST_PP_SEQ_ENUM(params)); \ + t._impl(BOOST_PP_SEQ_ENUM(params)); \ BOOST_TEST_CHECKPOINT('"' << #test_name << "\" exit."); \ } \ private: \ @@ -234,15 +249,21 @@ private: \ void _impl(BOOST_DATA_TEST_CASE_PARAMS( params )); \ }; \ \ -BOOST_AUTO_TU_REGISTRAR( test_name )( \ - boost::unit_test::data::ds_detail::make_test_case_gen<test_name>( \ +BOOST_AUTO_TEST_SUITE( test_name ) \ + \ +BOOST_AUTO_TU_REGISTRAR( BOOST_PP_CAT(test_name, case) )( \ + boost::unit_test::data::ds_detail::make_test_case_gen< \ + BOOST_PP_CAT(test_name, case)>( \ BOOST_STRINGIZE( test_name ), \ __FILE__, __LINE__, \ boost::unit_test::data::ds_detail::seed{} ->* dataset ), \ boost::unit_test::decorator::collector::instance() ); \ \ +BOOST_AUTO_TEST_SUITE_END() \ + \ template<BOOST_PP_ENUM_PARAMS(arity, typename Arg)> \ - void test_name::_impl( BOOST_DATA_TEST_CASE_PARAMS( params ) ) \ + void BOOST_PP_CAT(test_name, case)::_impl( \ + BOOST_DATA_TEST_CASE_PARAMS( params ) ) \ /**/ #define BOOST_DATA_TEST_CASE_WITH_PARAMS( F, test_name, dataset, ... ) \ |