Fixed a bug that caused an object to remain invalid forever after being invalid and verified once

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@424 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2012-03-15 21:42:01 +00:00
parent 45d2d58000
commit 209ffa986f
2 changed files with 12 additions and 2 deletions

View file

@ -209,12 +209,12 @@ namespace mock
<< lazy_expectations( this )
#define MOCK_EXPECTATION_INVOKE(z, n, A) \
{ \
valid_ = false; \
for( expectations_cit it = expectations_.begin(); it != expectations_.end(); ++it ) \
if( it->is_valid( BOOST_PP_ENUM_PARAMS(n, p) ) ) \
{ \
if( ! it->invoke() ) \
{ \
valid_ = false; \
error_type::sequence_failed( MOCK_EXPECTATION_CALL_CONTEXT(n), it->file(), it->line() ); \
return A; \
} \
@ -223,10 +223,10 @@ namespace mock
error_type::missing_action( MOCK_EXPECTATION_CALL_CONTEXT(n), it->file(), it->line() ); \
return A; \
} \
valid_ = true; \
error_type::expected_call( MOCK_EXPECTATION_CALL_CONTEXT(n), it->file(), it->line() ); \
return it->functor()( BOOST_PP_ENUM_PARAMS(n, p) ); \
} \
valid_ = false; \
error_type::unexpected_call( MOCK_EXPECTATION_CALL_CONTEXT(n) ); \
return A; \
}

View file

@ -215,6 +215,16 @@ BOOST_FIXTURE_TEST_CASE( verifying_a_once_expectation_before_the_call_fails, err
}
}
BOOST_FIXTURE_TEST_CASE( verifying_a_once_expectation_after_a_verify_and_one_call_succeeds, error_fixture )
{
mock::function< void() > f;
f.expect().once();
CHECK_ERROR( BOOST_CHECK( ! f.verify() ), verification_failed, 0, "?\n. once()" );
f();
BOOST_CHECK( f.verify() );
CHECK_CALLS( 1 );
}
// reset
BOOST_FIXTURE_TEST_CASE( triggering_a_reset_function_calls_unexpected_call_error, error_fixture )