mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Replace Boost.Bind by std::bind and lambdas
This commit is contained in:
parent
35e43d58a6
commit
a426e02759
9 changed files with 28 additions and 41 deletions
|
|
@ -12,7 +12,6 @@
|
|||
#include <turtle/constraints.hpp>
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
#include <boost/utility/result_of.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
|
@ -37,10 +36,10 @@ BOOST_FIXTURE_TEST_CASE( a_function_can_be_passed_as_functor, mock_error_fixture
|
|||
std::function< void() > functor = f;
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE( a_function_can_be_passed_as_functor_using_boost_bind_and_boost_ref, mock_error_fixture )
|
||||
BOOST_FIXTURE_TEST_CASE( a_function_can_be_passed_as_functor_using_std_bind_and_std_ref, mock_error_fixture )
|
||||
{
|
||||
mock::detail::function< void() > f;
|
||||
std::function< void() > functor = boost::bind( std::ref( f ) );
|
||||
std::function< void() > functor = std::bind( std::ref( f ) );
|
||||
}
|
||||
|
||||
// invocations
|
||||
|
|
@ -688,10 +687,10 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor_with
|
|||
CHECK_CALLS( 1 );
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor_without_parameters_thanks_to_boost_bind, mock_error_fixture )
|
||||
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor_without_parameters_thanks_to_std_bind, mock_error_fixture )
|
||||
{
|
||||
mock::detail::function< int( int ) > f;
|
||||
f.expect().calls( boost::bind( &custom_result ) );
|
||||
f.expect().calls( std::bind( &custom_result ) );
|
||||
BOOST_CHECK_EQUAL( 42, f( 17 ) );
|
||||
CHECK_CALLS( 1 );
|
||||
}
|
||||
|
|
@ -917,7 +916,7 @@ BOOST_FIXTURE_TEST_CASE( function_is_thread_safe, mock_error_fixture )
|
|||
mock::detail::function< int() > f;
|
||||
boost::thread_group group;
|
||||
for( int i = 0; i < 100; ++i )
|
||||
group.create_thread( boost::bind( &iterate, std::ref( f ) ) );
|
||||
group.create_thread( [&f](){ iterate(f); } );
|
||||
group.join_all();
|
||||
CHECK_CALLS( 100 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,11 +71,14 @@ BOOST_AUTO_TEST_CASE( std_bind_first_is_functor )
|
|||
is_functor( std::bind1st( std::ptr_fun( &f2 ), "" ) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( boost_bind_is_functor )
|
||||
BOOST_AUTO_TEST_CASE( bind_is_functor )
|
||||
{
|
||||
is_functor( boost::bind( &f0 ) );
|
||||
is_functor( boost::bind( &f1, _1 ) );
|
||||
is_functor( boost::bind( &f2, "", _1 ) );
|
||||
is_functor( std::bind( &f0 ) );
|
||||
is_functor( std::bind( &f1, std::placeholders::_1 ) );
|
||||
is_functor( std::bind( &f2, "", std::placeholders::_1 ) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( boost_lambda_is_functor )
|
||||
|
|
|
|||
|
|
@ -646,7 +646,7 @@ BOOST_FIXTURE_TEST_CASE( mock_functor_creation_is_thread_safe, mock_error_fixtur
|
|||
{
|
||||
boost::thread_group group;
|
||||
for( int i = 0; i < 100; ++i )
|
||||
group.create_thread( boost::bind( &create_functor, i ) );
|
||||
group.create_thread( [i](){ create_functor( i ); } );
|
||||
group.join_all();
|
||||
CHECK_CALLS( 100 );
|
||||
}
|
||||
|
|
@ -665,7 +665,7 @@ BOOST_FIXTURE_TEST_CASE( mock_class_is_thread_safe, mock_error_fixture )
|
|||
my_mock m;
|
||||
boost::thread_group group;
|
||||
for( int i = 0; i < 100; ++i )
|
||||
group.create_thread( boost::bind( &iterate, std::ref( m ) ) );
|
||||
group.create_thread( [&m](){ iterate(m); } );
|
||||
group.join_all();
|
||||
CHECK_CALLS( 100 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include <boost/lambda/lambda.hpp>
|
||||
#endif
|
||||
#include <boost/bind.hpp>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
|
|
@ -646,9 +647,10 @@ BOOST_AUTO_TEST_CASE( boost_phoenix_functor_yields_question_mark_when_serialized
|
|||
BOOST_CHECK_EQUAL( "?", to_string( boost::phoenix::arg_names::_1 < 42 ) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( boost_bind_functor_yields_question_mark_when_serialized )
|
||||
BOOST_AUTO_TEST_CASE( bind_functor_yields_question_mark_when_serialized )
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "?", to_string( boost::bind( &some_function ) ) );
|
||||
BOOST_CHECK_EQUAL( "?", to_string( std::bind( &some_function ) ) );
|
||||
}
|
||||
|
||||
#ifndef BOOST_MSVC // this produces an ICE with all versions of MSVC
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include <turtle/mock.hpp>
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <functional>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
|
@ -162,7 +162,8 @@ namespace
|
|||
BOOST_FIXTURE_TEST_CASE( MOCK_CONST_METHOD_EXT_macro_defines_a_bindable_method, mock_error_fixture )
|
||||
{
|
||||
my_mock m;
|
||||
boost::bind( &my_mock::my_method, &m, 42 );
|
||||
const auto f = std::bind( &my_mock::my_method, &m, 42 );
|
||||
(void) f;
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE( MOCK_VERIFY_macro, mock_error_fixture )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue