mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Prevented a crash when mocking a destructor and throwing out of the object scope
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@121 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
456869d82b
commit
0e8079d47a
8 changed files with 174 additions and 113 deletions
|
|
@ -259,3 +259,41 @@ BOOST_FIXTURE_TEST_CASE( basic_mock_object_collaboration_usage, fixture )
|
|||
MOCK_EXPECT( observer, notify ).once().with( 3 );
|
||||
subject.increment();
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
MOCK_CLASS( my_destroyed_class )
|
||||
{
|
||||
MOCK_DESTRUCTOR( my_destroyed_class, destructor )
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( mocking_a_destructor )
|
||||
{
|
||||
my_destroyed_class c;
|
||||
MOCK_EXPECT( c, destructor ).once();
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( failed_expectation_in_mocked_destructor_does_not_throw )
|
||||
{
|
||||
try
|
||||
{
|
||||
my_destroyed_class c;
|
||||
throw std::runtime_error( "should not crash" );
|
||||
}
|
||||
catch( std::runtime_error& )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( failed_sequence_in_mocked_destructor_does_not_throw )
|
||||
{
|
||||
mock::sequence s;
|
||||
my_custom_mock m;
|
||||
{
|
||||
my_destroyed_class c;
|
||||
MOCK_EXPECT( c, destructor ).once().in( s );
|
||||
MOCK_EXPECT( m, my_method ).once().in( s );
|
||||
m.my_method();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue