Merge pull request #35 from mat007/support-move-only-types-as-arguments

Support move only types as arguments
This commit is contained in:
Mathieu Champlon 2018-03-12 19:21:54 +01:00 committed by GitHub
commit 176b9bdc01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 250 additions and 62 deletions

View file

@ -704,3 +704,56 @@ BOOST_FIXTURE_TEST_CASE( mock_method_accepts_polymorphic_multi_constraint, mock_
m.m2( 1, 2 );
CHECK_CALLS( 1 );
}
#ifdef MOCK_SMART_PTR
BOOST_FIXTURE_TEST_CASE( std_unique_ptr_argument_is_supported_in_action, mock_error_fixture )
{
MOCK_FUNCTOR( f, void( std::unique_ptr< int > ) );
std::unique_ptr< int > p;
MOCK_EXPECT( f ).once().calls(
[]( std::unique_ptr< int > )
{
} );
f( std::unique_ptr< int >( new int( 7 ) ) );
CHECK_CALLS( 1 );
}
BOOST_FIXTURE_TEST_CASE( std_unique_ptr_argument_is_supported_in_equal_constraint, mock_error_fixture )
{
{
MOCK_FUNCTOR( f, void( std::unique_ptr< int > ) );
MOCK_EXPECT( f ).once().with( mock::equal( 7 ) );
f( std::unique_ptr< int >( new int( 7 ) ) );
CHECK_CALLS( 1 );
}
{
MOCK_FUNCTOR( f, void( std::unique_ptr< int > ) );
MOCK_EXPECT( f ).once().with( 7 );
f( std::unique_ptr< int >( new int( 7 ) ) );
CHECK_CALLS( 1 );
}
}
BOOST_FIXTURE_TEST_CASE( std_unique_ptr_argument_is_supported_in_retrieve_constraint, mock_error_fixture )
{
{
MOCK_FUNCTOR( f, void( std::unique_ptr< int > ) );
MOCK_EXPECT( f ).once().with( nullptr );
f( 0 );
CHECK_CALLS( 1 );
}
{
std::unique_ptr< int > i;
MOCK_FUNCTOR( f, void( std::unique_ptr< int > ) );
MOCK_EXPECT( f ).once().with( mock::retrieve( i ) );
std::unique_ptr< int > j( new int( 7 ) );
f( std::move( j ) );
BOOST_CHECK( !j );
BOOST_REQUIRE( i );
BOOST_CHECK_EQUAL( 7, *i );
CHECK_CALLS( 1 );
}
}
#endif