Make action classes non-relocatable

This fixes an issue with auto_ptr. As shown by missing coverage the
actual copy/move ctors are not required as C++11 emplace functions can
be used.
Furthermore some places using shared_ptr could be replaced by unique_ptr
leading to better performance.
This commit is contained in:
Alexander Grund 2020-07-14 21:17:14 +02:00
parent f3d6564d2b
commit d9f9fce6fc
No known key found for this signature in database
GPG key ID: AA48A0760367A42B
5 changed files with 54 additions and 55 deletions

View file

@ -535,6 +535,19 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_valu
BOOST_CHECK( ! f().get() );
CHECK_CALLS( 2 );
}
{
mock::detail::function< std::auto_ptr< int >() > f;
f.expect().once().returns( new int( 1 ) );
f.expect().once().returns( new int( 2 ) );
f.expect().once().returns( new int( 3 ) );
f.expect().returns( new int( 4 ) );
BOOST_CHECK_EQUAL( 1, *f() );
BOOST_CHECK_EQUAL( 2, *f() );
BOOST_CHECK_EQUAL( 3, *f() );
BOOST_CHECK_EQUAL( 4, *f() );
BOOST_CHECK( ! f().get() );
CHECK_CALLS( 5 );
}
{
mock::detail::function< std::auto_ptr< int >() > f;
f.expect().returns( std::auto_ptr< int >( new int( 3 ) ) );