Fixed perfect forwarding bug

This commit is contained in:
Mathieu Champlon 2018-03-17 22:20:04 +01:00
parent 062d465ba5
commit 860e072439
4 changed files with 64 additions and 7 deletions

View file

@ -84,11 +84,46 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_unlimited_expectation_is_valid, mock_erro
f();
CHECK_CALLS( 2 );
}
{
mock::detail::function< void( int, std::string ) > f;
f.expect();
f( 1, "s1" );
f( 2, "s2" );
CHECK_CALLS( 2 );
}
{
mock::detail::function< void( int, const std::string& ) > f;
f.expect();
f( 1, "s" );
f( 1, "s" );
f( 1, "s1" );
f( 2, "s2" );
CHECK_CALLS( 2 );
}
}
BOOST_FIXTURE_TEST_CASE( triggering_several_once_expectations_is_valid, mock_error_fixture )
{
{
mock::detail::function< void() > f;
f.expect().once();
f.expect().once();
f();
f();
CHECK_CALLS( 2 );
}
{
mock::detail::function< void( int, std::string ) > f;
f.expect().once().with( 1, "s1" );
f.expect().once().with( 2, "s2" );
f( 1, "s1" );
f( 2, "s2" );
CHECK_CALLS( 2 );
}
{
mock::detail::function< void( int, const std::string& ) > f;
f.expect().once().with( 1, "s1" );
f.expect().once().with( 2, "s2" );
f( 1, "s1" );
f( 2, "s2" );
CHECK_CALLS( 2 );
}
}

View file

@ -754,6 +754,19 @@ BOOST_FIXTURE_TEST_CASE( std_unique_ptr_argument_is_supported_in_retrieve_constr
BOOST_CHECK_EQUAL( 7, *i );
CHECK_CALLS( 1 );
}
{
std::unique_ptr< int > i;
MOCK_FUNCTOR( f, void( std::unique_ptr< int > ) );
MOCK_EXPECT( f ).once().with( nullptr );
MOCK_EXPECT( f ).once().with( mock::retrieve( i ) );
f( 0 );
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( 2 );
}
}
#endif