Refactoring

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@131 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2010-03-01 23:06:08 +00:00
parent d327700205
commit fb4df4527b
8 changed files with 129 additions and 129 deletions

View file

@ -57,13 +57,13 @@ namespace
BOOST_FIXTURE_TEST_CASE( an_expectation_can_be_passed_as_functor, error_fixture )
{
mock::expectation< void() > e;
mock::function< void() > e;
boost::function< void() > f = e;
}
BOOST_FIXTURE_TEST_CASE( an_expectation_can_be_passed_as_functor_using_boost_bind_and_boost_ref, error_fixture )
{
mock::expectation< void() > e;
mock::function< void() > e;
boost::function< void() > f = boost::bind( boost::ref( e ) );
}
@ -72,11 +72,11 @@ BOOST_FIXTURE_TEST_CASE( an_expectation_can_be_passed_as_functor_using_boost_bin
BOOST_FIXTURE_TEST_CASE( triggering_an_empty_expectation_calls_no_match_error, error_fixture )
{
{
mock::expectation< void() > e;
mock::function< void() > e;
CHECK_ERROR( e(), no_match );
}
{
mock::expectation< int( int, const std::string& ) > e;
mock::function< int( int, const std::string& ) > e;
CHECK_ERROR( e( 1, "s" ), no_match );
}
}
@ -84,12 +84,12 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_empty_expectation_calls_no_match_error, e
BOOST_FIXTURE_TEST_CASE( triggering_a_never_expectation_calls_no_match_error, error_fixture )
{
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect().never();
CHECK_ERROR( e(), no_match );
}
{
mock::expectation< int( int, const std::string& ) > e;
mock::function< int( int, const std::string& ) > e;
e.expect().never();
CHECK_ERROR( e( 1, "s" ), no_match );
}
@ -98,13 +98,13 @@ BOOST_FIXTURE_TEST_CASE( triggering_a_never_expectation_calls_no_match_error, er
BOOST_FIXTURE_TEST_CASE( triggering_an_unlimited_expectation_is_valid, error_fixture )
{
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect();
e();
e();
}
{
mock::expectation< void( int, const std::string& ) > e;
mock::function< void( int, const std::string& ) > e;
e.expect();
e( 1, "s" );
e( 1, "s" );
@ -114,13 +114,13 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_unlimited_expectation_is_valid, error_fix
BOOST_FIXTURE_TEST_CASE( triggering_a_once_expectation_calls_no_match_error_after_one_call, error_fixture )
{
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect().once();
e();
CHECK_ERROR( e(), no_match );
}
{
mock::expectation< void( int, const std::string& ) > e;
mock::function< void( int, const std::string& ) > e;
e.expect().once();
e( 1, "s" );
CHECK_ERROR( e( 1, "s" ), no_match );
@ -129,7 +129,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_a_once_expectation_calls_no_match_error_afte
BOOST_FIXTURE_TEST_CASE( literal_zero_can_be_used_in_expectation_operator_call_as_pointers, error_fixture )
{
mock::expectation< void( int* ) > e;
mock::function< void( int* ) > e;
e.expect().once();
e( 0 );
}
@ -139,11 +139,11 @@ BOOST_FIXTURE_TEST_CASE( literal_zero_can_be_used_in_expectation_operator_call_a
BOOST_FIXTURE_TEST_CASE( verifying_an_empty_expectation_succeeds, error_fixture )
{
{
mock::expectation< void() > e;
mock::function< void() > e;
BOOST_CHECK( e.verify() );
}
{
mock::expectation< int( int, const std::string& ) > e;
mock::function< int( int, const std::string& ) > e;
BOOST_CHECK( e.verify() );
}
}
@ -151,12 +151,12 @@ BOOST_FIXTURE_TEST_CASE( verifying_an_empty_expectation_succeeds, error_fixture
BOOST_FIXTURE_TEST_CASE( verifying_an_unlimited_expectation_succeeds, error_fixture )
{
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect();
BOOST_CHECK( e.verify() );
}
{
mock::expectation< int( int, const std::string& ) > e;
mock::function< int( int, const std::string& ) > e;
e.expect();
BOOST_CHECK( e.verify() );
}
@ -165,13 +165,13 @@ BOOST_FIXTURE_TEST_CASE( verifying_an_unlimited_expectation_succeeds, error_fixt
BOOST_FIXTURE_TEST_CASE( verifying_a_once_expectation_after_one_call_succeeds, error_fixture )
{
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect().once();
e();
BOOST_CHECK( e.verify() );
}
{
mock::expectation< void( int, const std::string& ) > e;
mock::function< void( int, const std::string& ) > e;
e.expect().once();
e( 1, "s" );
BOOST_CHECK( e.verify() );
@ -181,12 +181,12 @@ BOOST_FIXTURE_TEST_CASE( verifying_a_once_expectation_after_one_call_succeeds, e
BOOST_FIXTURE_TEST_CASE( verifying_a_once_expectation_before_the_call_fails, error_fixture )
{
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect().once();
CHECK_ERROR( BOOST_CHECK( ! e.verify() ), verification_failed );
}
{
mock::expectation< int( int, const std::string& ) > e;
mock::function< int( int, const std::string& ) > e;
e.expect().once();
CHECK_ERROR( BOOST_CHECK( ! e.verify() ), verification_failed );
}
@ -197,13 +197,13 @@ BOOST_FIXTURE_TEST_CASE( verifying_a_once_expectation_before_the_call_fails, err
BOOST_FIXTURE_TEST_CASE( triggering_a_reset_expectation_calls_no_match_error, error_fixture )
{
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect();
e.reset();
CHECK_ERROR( e(), no_match );
}
{
mock::expectation< int( int, const std::string& ) > e;
mock::function< int( int, const std::string& ) > e;
e.expect();
e.reset();
CHECK_ERROR( e( 1, "s" ), no_match );
@ -213,13 +213,13 @@ BOOST_FIXTURE_TEST_CASE( triggering_a_reset_expectation_calls_no_match_error, er
BOOST_FIXTURE_TEST_CASE( verifying_a_reset_expectation_succeeds, error_fixture )
{
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect();
e.reset();
BOOST_CHECK( e.verify() );
}
{
mock::expectation< int( int, const std::string& ) > e;
mock::function< int( int, const std::string& ) > e;
e.expect();
e.reset();
BOOST_CHECK( e.verify() );
@ -231,12 +231,12 @@ BOOST_FIXTURE_TEST_CASE( verifying_a_reset_expectation_succeeds, error_fixture )
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in_equal_constraint_calls_no_match_error, error_fixture )
{
{
mock::expectation< void( int ) > e;
mock::function< void( int ) > e;
e.expect().with( 42 );
CHECK_ERROR( e( 43 ), no_match );
}
{
mock::expectation< int( int, const std::string& ) > e;
mock::function< int( int, const std::string& ) > e;
e.expect().with( 42, "expected" );
CHECK_ERROR( e( 42, "actual" ), no_match );
}
@ -244,7 +244,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in_equal_or_less_constraint_calls_no_match_error, error_fixture )
{
mock::expectation< void( int ) > e;
mock::function< void( int ) > e;
e.expect().with( mock::equal( 42 ) || mock::less( 42 ) );
e( 41 );
e( 42 );
@ -253,7 +253,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in_equal_and_not_less_constraint_calls_no_match_error, error_fixture )
{
mock::expectation< void( int ) > e;
mock::function< void( int ) > e;
e.expect().with( mock::equal( 42 ) && ! mock::less( 41 ) );
e( 42 );
CHECK_ERROR( e( 43 ), no_match );
@ -277,13 +277,13 @@ namespace
BOOST_FIXTURE_TEST_CASE( passing_call_values_by_reference_is_transparent, error_fixture )
{
{
mock::expectation< void( my_interface& ) > e;
mock::function< void( my_interface& ) > e;
my_implementation imp;
e.expect().with( mock::same( imp ) );
e( imp );
}
{
mock::expectation< void( const my_interface& ) > e;
mock::function< void( const my_interface& ) > e;
my_implementation imp;
e.expect().with( mock::same( imp ) );
e( imp );
@ -301,12 +301,12 @@ namespace
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_failing_custom_constraint_calls_no_match_error, error_fixture )
{
{
mock::expectation< void( int ) > e;
mock::function< void( int ) > e;
e.expect().with( &custom_constraint );
CHECK_ERROR( e( 42 ), no_match );
}
{
mock::expectation< int( int, const std::string& ) > e;
mock::function< int( int, const std::string& ) > e;
e.expect().with( &custom_constraint, "actual" );
CHECK_ERROR( e( 42, "actual" ), no_match );
}
@ -314,7 +314,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_failing_custom_constrain
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in_custom_constraint_calls_no_match_error, error_fixture )
{
mock::expectation< void( int ) > e;
mock::function< void( int ) > e;
e.expect().with( mock::constraint( &custom_constraint, "custom constraint" ) );
CHECK_ERROR( e( 42 ), no_match );
}
@ -322,7 +322,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in
/*
BOOST_FIXTURE_TEST_CASE( literal_zero_can_be_used_in_place_of_null_pointers_in_constraints, error_fixture )
{
mock::expectation< void( int* ) > e;
mock::function< void( int* ) > e;
e.expect().with( 0 );
e.reset();
}
@ -333,17 +333,17 @@ BOOST_FIXTURE_TEST_CASE( literal_zero_can_be_used_in_place_of_null_pointers_in_c
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_no_return_set_calls_missing_action, error_fixture )
{
{
mock::expectation< int() > e;
mock::function< int() > e;
e.expect();
CHECK_ERROR( e(), missing_action );
}
{
mock::expectation< int&() > e;
mock::function< int&() > e;
e.expect();
CHECK_ERROR( e(), missing_action );
}
{
mock::expectation< const std::string&() > e;
mock::function< const std::string&() > e;
e.expect();
CHECK_ERROR( e(), missing_action );
}
@ -352,43 +352,43 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_no_return_set_calls_miss
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_value, error_fixture )
{
{
mock::expectation< int() > e;
mock::function< int() > e;
e.expect().returns( 42 );
BOOST_CHECK_EQUAL( 42, e() );
}
{
mock::expectation< int() > e;
mock::function< int() > e;
const int i = 42;
e.expect().returns( i );
BOOST_CHECK_EQUAL( i, e() );
}
{
mock::expectation< int() > e;
mock::function< int() > e;
int i = 42;
e.expect().returns( boost::ref( i ) );
i = 43;
BOOST_CHECK_EQUAL( 43, e() );
}
{
mock::expectation< int&() > e;
mock::function< int&() > e;
e.expect().returns( 42 );
BOOST_CHECK_EQUAL( 42, e() );
}
{
mock::expectation< int&() > e;
mock::function< int&() > e;
const int result = 42;
e.expect().returns( result );
BOOST_CHECK_EQUAL( result, e() );
}
{
mock::expectation< int&() > e;
mock::function< int&() > e;
int i = 42;
e.expect().returns( i );
i = 43;
BOOST_CHECK_EQUAL( 42, e() );
}
{
mock::expectation< int&() > e;
mock::function< int&() > e;
int i = 42;
e.expect().returns( boost::ref( i ) );
i = 43;
@ -397,27 +397,27 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_value, error_
BOOST_CHECK_EQUAL( 12, i );
}
{
mock::expectation< std::string() > e;
mock::function< std::string() > e;
e.expect().returns( "result" );
BOOST_CHECK_EQUAL( "result", e() );
}
{
mock::expectation< const std::string&() > e;
mock::function< const std::string&() > e;
e.expect().returns( "result" );
BOOST_CHECK_EQUAL( "result", e() );
}
{
mock::expectation< int*() > e;
mock::function< int*() > e;
e.expect().returns( 0 );
BOOST_CHECK( ! e() );
}
{
mock::expectation< int() > e;
mock::function< int() > e;
e.expect().returns( 0 );
BOOST_CHECK_EQUAL( 0, e() );
}
{
mock::expectation< int&() > e;
mock::function< int&() > e;
e.expect().returns( 0 );
BOOST_CHECK_EQUAL( 0, e() );
}
@ -432,7 +432,7 @@ namespace
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_value, error_fixture )
{
{
mock::expectation< std::auto_ptr< int >() > e;
mock::function< std::auto_ptr< int >() > e;
std::auto_ptr< int > ptr( new int( 3 ) );
e.expect().returns( boost::ref( ptr ) );
BOOST_CHECK_EQUAL( 3, *ptr );
@ -441,7 +441,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_valu
BOOST_CHECK( ! e().get() );
}
{
mock::expectation< std::auto_ptr< int >() > e;
mock::function< std::auto_ptr< int >() > e;
std::auto_ptr< int > ptr( new int( 3 ) );
e.expect().returns( ptr );
BOOST_CHECK( ! ptr.get() );
@ -449,29 +449,29 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_valu
BOOST_CHECK( ! e().get() );
}
{
mock::expectation< std::auto_ptr< int >() > e;
mock::function< std::auto_ptr< int >() > e;
e.expect().returns( new int( 3 ) );
BOOST_CHECK_EQUAL( 3, *e() );
BOOST_CHECK( ! e().get() );
}
{
mock::expectation< std::auto_ptr< int >() > e;
mock::function< std::auto_ptr< int >() > e;
e.expect().returns( std::auto_ptr< int >( new int( 3 ) ) );
BOOST_CHECK_EQUAL( 3, *e() );
BOOST_CHECK( ! e().get() );
}
{
mock::expectation< std::auto_ptr< A >() > e;
mock::function< std::auto_ptr< A >() > e;
e.expect().returns( new B );
BOOST_CHECK_NO_THROW( e() );
}
{
mock::expectation< std::auto_ptr< A >() > e;
mock::function< std::auto_ptr< A >() > e;
e.expect().returns( std::auto_ptr< A >( new B ) );
BOOST_CHECK_NO_THROW( e() );
}
{
mock::expectation< std::auto_ptr< A >() > e;
mock::function< std::auto_ptr< A >() > e;
e.expect().returns( std::auto_ptr< B >( new B ) );
BOOST_CHECK_NO_THROW( e() );
}
@ -487,7 +487,7 @@ namespace
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor, error_fixture )
{
mock::expectation< int() > e;
mock::function< int() > e;
e.expect().calls( &custom_result );
BOOST_CHECK_EQUAL( 42, e() );
}
@ -502,21 +502,21 @@ namespace
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor_with_parameters, error_fixture )
{
mock::expectation< int( int ) > e;
mock::function< int( int ) > e;
e.expect().calls( &custom_result_with_parameter );
BOOST_CHECK_EQUAL( 42, e( 42 ) );
}
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor_without_parameters_thanks_to_boost_bind, error_fixture )
{
mock::expectation< int( int ) > e;
mock::function< int( int ) > e;
e.expect().calls( boost::bind( &custom_result ) );
BOOST_CHECK_EQUAL( 42, e( 17 ) );
}
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_throws_the_set_exception, error_fixture )
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect().throws( std::runtime_error( "some exception" ) );
try
{
@ -535,7 +535,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_throws_the_set_exception, err
BOOST_FIXTURE_TEST_CASE( expecting_twice_a_single_expectation_makes_it_callable_twice, error_fixture )
{
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect().once();
e.expect().once();
e();
@ -543,7 +543,7 @@ BOOST_FIXTURE_TEST_CASE( expecting_twice_a_single_expectation_makes_it_callable_
CHECK_ERROR( e(), no_match );
}
{
mock::expectation< void( const std::string& ) > e;
mock::function< void( const std::string& ) > e;
e.expect().once().with( "first" );
e.expect().once().with( "second" );
e( "first" );
@ -555,7 +555,7 @@ BOOST_FIXTURE_TEST_CASE( expecting_twice_a_single_expectation_makes_it_callable_
BOOST_FIXTURE_TEST_CASE( best_matcher_is_selected_first, error_fixture )
{
{
mock::expectation< void( int ) > e;
mock::function< void( int ) > e;
e.expect().once().with( 1 );
e.expect().once().with( 2 );
e( 2 );
@ -563,7 +563,7 @@ BOOST_FIXTURE_TEST_CASE( best_matcher_is_selected_first, error_fixture )
CHECK_ERROR( e( 3 ), no_match );
}
{
mock::expectation< void( const std::string& ) > e;
mock::function< void( const std::string& ) > e;
e.expect().once().with( "first" );
e.expect().once().with( "second" );
e( "second" );
@ -588,28 +588,28 @@ namespace
BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, error_fixture )
{
{
mock::expectation< void( int ) > e;
e.tag( "my expectation" );
mock::function< void( int ) > e;
e.tag( "my function" );
e.expect().once().with( 1 );
e.expect().once().with( 2 );
BOOST_CHECK_NO_THROW( e( 2 ) );
const std::string expected = "my expectation\n"
const std::string expected = "my function\n"
". once().with( 1 )\n"
"v once().with( 2 )";
BOOST_CHECK_EQUAL( expected, to_string( e ) );
e.reset();
}
{
mock::expectation< void( int ) > e;
e.tag( "my expectation" );
mock::function< void( int ) > e;
e.tag( "my function" );
e.expect().never().with( 1 );
const std::string expected = "my expectation\n"
const std::string expected = "my function\n"
"v never().with( 1 )";
BOOST_CHECK_EQUAL( expected, to_string( e ) );
e.reset();
}
{
mock::expectation< void( const std::string& ) > e;
mock::function< void( const std::string& ) > e;
e.expect().never().with( mock::less( "first" ) );
e.expect().exactly( 2 ).with( "second" );
BOOST_CHECK_NO_THROW( e( "second" ) );
@ -629,55 +629,55 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err
e.reset();
}
{
mock::expectation< void( int ) > e;
e.tag( "my expectation" );
mock::function< void( int ) > e;
e.tag( "my function" );
e.expect().once();
const std::string expected = "my expectation\n"
const std::string expected = "my function\n"
". once().with( any )";
BOOST_CHECK_EQUAL( expected, to_string( e ) );
e.reset();
}
{
mock::expectation< void( int ) > e;
e.tag( "my expectation" );
mock::function< void( int ) > e;
e.tag( "my function" );
e.expect().once().with( mock::any );
const std::string expected = "my expectation\n"
const std::string expected = "my function\n"
". once().with( any )";
BOOST_CHECK_EQUAL( expected, to_string( e ) );
e.reset();
}
{
mock::expectation< void( int ) > e;
e.tag( "my expectation" );
mock::function< void( int ) > e;
e.tag( "my function" );
e.expect().once();
const std::string expected = "my expectation\n"
const std::string expected = "my function\n"
". once().with( any )";
BOOST_CHECK_EQUAL( expected, to_string( e ) );
e.reset();
}
{
mock::expectation< void( int ) > e;
e.tag( "my expectation" );
mock::function< void( int ) > e;
e.tag( "my function" );
e.expect().once().with( &custom_constraint );
const std::string expected = "my expectation\n"
const std::string expected = "my function\n"
". once().with( ? )";
BOOST_CHECK_EQUAL( expected, to_string( e ) );
e.reset();
}
{
mock::expectation< void( int ) > e;
e.tag( "my expectation" );
mock::function< void( int ) > e;
e.tag( "my function" );
e.expect().once().with( mock::constraint( &custom_constraint, "custom constraint" ) );
const std::string expected = "my expectation\n"
const std::string expected = "my function\n"
". once().with( custom constraint )";
BOOST_CHECK_EQUAL( expected, to_string( e ) );
e.reset();
}
{
mock::expectation< void( int ) > e;
e.tag( "my expectation" );
mock::function< void( int ) > e;
e.tag( "my function" );
e.expect().once().with( mock::constraint( &custom_constraint, true ) );
const std::string expected = "my expectation\n"
const std::string expected = "my function\n"
". once().with( true )";
BOOST_CHECK_EQUAL( expected, to_string( e ) );
e.reset();
@ -686,27 +686,27 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err
BOOST_FIXTURE_TEST_CASE( expectation_with_remaining_untriggered_matches_upon_destruction_calls_untriggered_expectation, error_fixture )
{
std::auto_ptr< mock::expectation< void() > > e( new mock::expectation< void() > );
std::auto_ptr< mock::function< void() > > e( new mock::function< void() > );
e->expect().once();
CHECK_ERROR( e.reset(), untriggered_expectation );
}
BOOST_FIXTURE_TEST_CASE( verifying_expectation_with_remaining_matches_disables_the_automatic_verification_upon_destruction, error_fixture )
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect().once();
CHECK_ERROR( e.verify(), verification_failed );
}
BOOST_FIXTURE_TEST_CASE( triggering_no_match_call_disables_the_automatic_verification_upon_destruction, error_fixture )
{
mock::expectation< void() > e;
mock::function< void() > e;
CHECK_ERROR( e(), no_match );
}
BOOST_FIXTURE_TEST_CASE( adding_a_matcher_reactivates_the_verification_upon_destruction, error_fixture )
{
std::auto_ptr< mock::expectation< void() > > e( new mock::expectation< void() > );
std::auto_ptr< mock::function< void() > > e( new mock::function< void() > );
CHECK_ERROR( (*e)(), no_match );
e->expect().once();
CHECK_ERROR( e.reset(), untriggered_expectation );
@ -716,7 +716,7 @@ BOOST_FIXTURE_TEST_CASE( throwing_an_exception_disables_the_automatic_verificati
{
try
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect().once();
throw std::exception();
}

View file

@ -19,10 +19,10 @@ namespace
void f1();
int f2( float );
BOOST_MPL_ASSERT(( boost::is_same< mock::expectation< void() >,
mock::expectation< BOOST_TYPEOF( f1 ) > > ));
BOOST_MPL_ASSERT(( boost::is_same< mock::expectation< int( float ) >,
mock::expectation< BOOST_TYPEOF( f2 ) > > ));
BOOST_MPL_ASSERT(( boost::is_same< mock::function< void() >,
mock::function< BOOST_TYPEOF( f1 ) > > ));
BOOST_MPL_ASSERT(( boost::is_same< mock::function< int( float ) >,
mock::function< BOOST_TYPEOF( f2 ) > > ));
struct example
{
@ -32,8 +32,8 @@ namespace
BOOST_STATIC_ASSERT(
(boost::is_same<
mock::expectation< void() >,
mock::expectation<
mock::function< void() >,
mock::function<
mock::detail::signature<
BOOST_TYPEOF( &example::method1 )
>::type
@ -41,8 +41,8 @@ namespace
>::value) );
BOOST_STATIC_ASSERT(
(boost::is_same<
mock::expectation< float( int ) >,
mock::expectation<
mock::function< float( int ) >,
mock::function<
mock::detail::signature<
BOOST_TYPEOF( &example::method2 )
>::type
@ -226,22 +226,22 @@ BOOST_MPL_ASSERT(( boost::is_same< mock::detail::invalid_type, mock::detail::arg
BOOST_AUTO_TEST_CASE( call_selects_proper_form )
{
{
mock::expectation< void() > e;
mock::function< void() > e;
e.expect().once();
mock::detail::call( e );
}
{
mock::expectation< void( int ) > e;
mock::function< void( int ) > e;
e.expect().once();
mock::detail::call( e, 3 );
}
{
mock::expectation< int() > e;
mock::function< int() > e;
e.expect().once().returns( 0 );
mock::detail::call( e );
}
{
mock::expectation< int( int ) > e;
mock::function< int( int ) > e;
e.expect().once().returns( 0 );
mock::detail::call( e, 3 );
}

View file

@ -14,7 +14,7 @@
#define MOCK_ERROR_POLICY silent_error
#include <turtle/object.hpp>
#include <turtle/expectation.hpp>
#include <turtle/function.hpp>
BOOST_AUTO_TEST_CASE( verifying_an_empty_object_succeeds )
{
@ -25,7 +25,7 @@ BOOST_AUTO_TEST_CASE( verifying_an_empty_object_succeeds )
BOOST_AUTO_TEST_CASE( verifying_an_object_containing_a_failing_expectation_fails )
{
mock::object o;
mock::expectation< void() > e;
mock::function< void() > e;
o.set_parent( e );
e.expect().once();
BOOST_CHECK( ! o.verify() );
@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE( verifying_an_object_containing_a_failing_expectation_fails
BOOST_AUTO_TEST_CASE( verifying_all_objects_with_one_of_them_containing_a_failing_expectation_fails )
{
mock::object o;
mock::expectation< void() > e;
mock::function< void() > e;
o.set_parent( e );
e.expect().once();
BOOST_CHECK( ! mock::verify() );
@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE( verifying_all_objects_with_one_of_them_containing_a_failin
BOOST_AUTO_TEST_CASE( resetting_an_object_containing_a_failing_expectation_and_verifying_it_succeeds )
{
mock::object o;
mock::expectation< void() > e;
mock::function< void() > e;
o.set_parent( e );
e.expect().once();
o.reset();
@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE( resetting_an_object_containing_a_failing_expectation_and_v
BOOST_AUTO_TEST_CASE( an_object_is_assignable_by_sharing_its_state )
{
mock::object o1;
mock::expectation< void() > e;
mock::function< void() > e;
{
mock::object o2;
o2.set_parent( e );
@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE( an_object_is_copiable_by_sharing_its_state )
{
std::auto_ptr< mock::object > o2( new mock::object );
const mock::object o1( *o2 );
mock::expectation< void() > e;
mock::function< void() > e;
o2->set_parent( e );
e.expect().once();
BOOST_CHECK( ! o2->verify() );

View file

@ -18,7 +18,7 @@
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_out_of_order_throws )
{
mock::sequence s;
mock::expectation< void( int ) > e;
mock::function< void( int ) > e;
e.expect().once().with( 1 ).in( s );
e.expect().once().with( 2 ).in( s );
BOOST_CHECK_NO_THROW( e( 2 ) );
@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_out_of_order_throws
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_out_of_order_multiple_invocations_throws )
{
mock::sequence s;
mock::expectation< void( int ) > e;
mock::function< void( int ) > e;
e.expect().with( 1 ).in( s );
e.expect().once().with( 2 ).in( s );
BOOST_CHECK_NO_THROW( e( 1 ) );
@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_out_of_order_multipl
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_in_order_is_valid )
{
mock::sequence s;
mock::expectation< void( int ) > e;
mock::function< void( int ) > e;
e.expect().once().with( 1 ).in( s );
e.expect().once().with( 2 ).in( s );
BOOST_CHECK_NO_THROW( e( 1 ) );
@ -49,7 +49,7 @@ BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_in_order_is_valid )
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_enforces_call_order_verification_between_two_different_expectations )
{
mock::sequence s;
mock::expectation< void() > e1, e2;
mock::function< void() > e1, e2;
e1.expect().once().in( s );
e2.expect().once().in( s );
BOOST_CHECK_NO_THROW( e2() );
@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE( registering_to_a_sequence_enforces_call_order_verification
BOOST_AUTO_TEST_CASE( destroying_a_sequence_removes_order_call_enforcement )
{
mock::expectation< void() > e1, e2;
mock::function< void() > e1, e2;
{
mock::sequence s;
e1.expect().once().in( s );
@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE( destroying_a_sequence_removes_order_call_enforcement )
BOOST_AUTO_TEST_CASE( resetting_an_expectation_removes_it_from_order_call_enforcement )
{
mock::sequence s;
mock::expectation< void() > e1, e2;
mock::function< void() > e1, e2;
e1.expect().once().in( s );
e2.expect().once().in( s );
e1.reset();
@ -81,7 +81,7 @@ BOOST_AUTO_TEST_CASE( resetting_an_expectation_removes_it_from_order_call_enforc
BOOST_AUTO_TEST_CASE( an_expectation_can_be_used_in_several_sequences )
{
mock::sequence s1, s2;
mock::expectation< void() > e;
mock::function< void() > e;
e.expect().once().in( s1 ).in( s2 );
BOOST_CHECK_NO_THROW( e() );
}
@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE( an_expectation_can_be_used_in_several_sequences )
BOOST_AUTO_TEST_CASE( a_result_specification_is_set_after_a_sequence )
{
mock::sequence s;
mock::expectation< int() > e;
mock::function< int() > e;
e.expect().once().in( s ).returns( 3 );
BOOST_CHECK_EQUAL( 3, e() );
}