mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Moved some components into a detail sub-directory
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@489 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
435dadf89d
commit
bd30f8c492
6 changed files with 97 additions and 94 deletions
|
|
@ -72,13 +72,13 @@ namespace
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( a_function_can_be_passed_as_functor, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( a_function_can_be_passed_as_functor, error_fixture )
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
boost::function< void() > functor = f;
|
boost::function< void() > functor = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( a_function_can_be_passed_as_functor_using_boost_bind_and_boost_ref, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( a_function_can_be_passed_as_functor_using_boost_bind_and_boost_ref, error_fixture )
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
boost::function< void() > functor = boost::bind( boost::ref( f ) );
|
boost::function< void() > functor = boost::bind( boost::ref( f ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,11 +87,11 @@ BOOST_FIXTURE_TEST_CASE( a_function_can_be_passed_as_functor_using_boost_bind_an
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_an_unconfigured_function_calls_unexpected_call_error, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_unconfigured_function_calls_unexpected_call_error, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
CHECK_ERROR( f(), unexpected_call, 0, "?()" );
|
CHECK_ERROR( f(), unexpected_call, 0, "?()" );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int( int, const std::string& ) > f;
|
mock::detail::function< int( int, const std::string& ) > f;
|
||||||
CHECK_ERROR( f( 1, "s" ), unexpected_call, 0, "?( 1, \"s\" )" );
|
CHECK_ERROR( f( 1, "s" ), unexpected_call, 0, "?( 1, \"s\" )" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -99,12 +99,12 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_unconfigured_function_calls_unexpected_ca
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_a_never_expectation_calls_unexpected_call_error, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_a_never_expectation_calls_unexpected_call_error, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
f.expect().never();
|
f.expect().never();
|
||||||
CHECK_ERROR( f(), unexpected_call, 0, "?()\nv never()" );
|
CHECK_ERROR( f(), unexpected_call, 0, "?()\nv never()" );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int( int, const std::string& ) > f;
|
mock::detail::function< int( int, const std::string& ) > f;
|
||||||
f.expect().never();
|
f.expect().never();
|
||||||
CHECK_ERROR( f( 1, "s" ), unexpected_call, 0, "?( 1, \"s\" )\nv never().with( any, any )" );
|
CHECK_ERROR( f( 1, "s" ), unexpected_call, 0, "?( 1, \"s\" )\nv never().with( any, any )" );
|
||||||
}
|
}
|
||||||
|
|
@ -113,14 +113,14 @@ BOOST_FIXTURE_TEST_CASE( triggering_a_never_expectation_calls_unexpected_call_er
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_an_unlimited_expectation_is_valid, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_unlimited_expectation_is_valid, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
f.expect();
|
f.expect();
|
||||||
f();
|
f();
|
||||||
f();
|
f();
|
||||||
CHECK_CALLS( 2 );
|
CHECK_CALLS( 2 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< void( int, const std::string& ) > f;
|
mock::detail::function< void( int, const std::string& ) > f;
|
||||||
f.expect();
|
f.expect();
|
||||||
f( 1, "s" );
|
f( 1, "s" );
|
||||||
f( 1, "s" );
|
f( 1, "s" );
|
||||||
|
|
@ -131,13 +131,13 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_unlimited_expectation_is_valid, error_fix
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_a_once_expectation_calls_unexpected_call_error_after_one_call, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_a_once_expectation_calls_unexpected_call_error_after_one_call, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
f();
|
f();
|
||||||
CHECK_ERROR( f(), unexpected_call, 1, "?()\nv once()" );
|
CHECK_ERROR( f(), unexpected_call, 1, "?()\nv once()" );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< void( int, const std::string& ) > f;
|
mock::detail::function< void( int, const std::string& ) > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
f( 1, "s" );
|
f( 1, "s" );
|
||||||
CHECK_ERROR( f( 1, "s" ), unexpected_call, 1, "?( 1, \"s\" )\nv once().with( any, any )" );
|
CHECK_ERROR( f( 1, "s" ), unexpected_call, 1, "?( 1, \"s\" )\nv once().with( any, any )" );
|
||||||
|
|
@ -146,7 +146,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_a_once_expectation_calls_unexpected_call_err
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( literal_zero_can_be_used_in_function_call_as_pointers, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( literal_zero_can_be_used_in_function_call_as_pointers, error_fixture )
|
||||||
{
|
{
|
||||||
mock::function< void( int* ) > f;
|
mock::detail::function< void( int* ) > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
f( 0 );
|
f( 0 );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
|
|
@ -157,11 +157,11 @@ BOOST_FIXTURE_TEST_CASE( literal_zero_can_be_used_in_function_call_as_pointers,
|
||||||
BOOST_FIXTURE_TEST_CASE( verifying_an_unconfigured_function_succeeds, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( verifying_an_unconfigured_function_succeeds, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
BOOST_CHECK( f.verify() );
|
BOOST_CHECK( f.verify() );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int( int, const std::string& ) > f;
|
mock::detail::function< int( int, const std::string& ) > f;
|
||||||
BOOST_CHECK( f.verify() );
|
BOOST_CHECK( f.verify() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -169,14 +169,14 @@ BOOST_FIXTURE_TEST_CASE( verifying_an_unconfigured_function_succeeds, error_fixt
|
||||||
BOOST_FIXTURE_TEST_CASE( verifying_an_unlimited_expectation_succeeds, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( verifying_an_unlimited_expectation_succeeds, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
f.expect();
|
f.expect();
|
||||||
BOOST_CHECK( f.verify() );
|
BOOST_CHECK( f.verify() );
|
||||||
CHECK_CALLS( 0 );
|
CHECK_CALLS( 0 );
|
||||||
}
|
}
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
{
|
{
|
||||||
mock::function< int( int, const std::string& ) > f;
|
mock::detail::function< int( int, const std::string& ) > f;
|
||||||
f.expect();
|
f.expect();
|
||||||
BOOST_CHECK( f.verify() );
|
BOOST_CHECK( f.verify() );
|
||||||
CHECK_CALLS( 0 );
|
CHECK_CALLS( 0 );
|
||||||
|
|
@ -187,14 +187,14 @@ 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 )
|
BOOST_FIXTURE_TEST_CASE( verifying_a_once_expectation_after_one_call_succeeds, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
f();
|
f();
|
||||||
BOOST_CHECK( f.verify() );
|
BOOST_CHECK( f.verify() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< void( int, const std::string& ) > f;
|
mock::detail::function< void( int, const std::string& ) > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
f( 1, "s" );
|
f( 1, "s" );
|
||||||
BOOST_CHECK( f.verify() );
|
BOOST_CHECK( f.verify() );
|
||||||
|
|
@ -205,12 +205,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 )
|
BOOST_FIXTURE_TEST_CASE( verifying_a_once_expectation_before_the_call_fails, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
CHECK_ERROR( BOOST_CHECK( ! f.verify() ), verification_failed, 0, "?\n. once()" );
|
CHECK_ERROR( BOOST_CHECK( ! f.verify() ), verification_failed, 0, "?\n. once()" );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int( int, const std::string& ) > f;
|
mock::detail::function< int( int, const std::string& ) > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
CHECK_ERROR( BOOST_CHECK( ! f.verify() ), verification_failed, 0, "?\n. once().with( any, any )" );
|
CHECK_ERROR( BOOST_CHECK( ! f.verify() ), verification_failed, 0, "?\n. once().with( any, any )" );
|
||||||
}
|
}
|
||||||
|
|
@ -218,7 +218,7 @@ 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 )
|
BOOST_FIXTURE_TEST_CASE( verifying_a_once_expectation_after_a_verify_and_one_call_succeeds, error_fixture )
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
CHECK_ERROR( BOOST_CHECK( ! f.verify() ), verification_failed, 0, "?\n. once()" );
|
CHECK_ERROR( BOOST_CHECK( ! f.verify() ), verification_failed, 0, "?\n. once()" );
|
||||||
f();
|
f();
|
||||||
|
|
@ -231,13 +231,13 @@ BOOST_FIXTURE_TEST_CASE( verifying_a_once_expectation_after_a_verify_and_one_cal
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_a_reset_function_calls_unexpected_call_error, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_a_reset_function_calls_unexpected_call_error, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
f.expect();
|
f.expect();
|
||||||
f.reset();
|
f.reset();
|
||||||
CHECK_ERROR( f(), unexpected_call, 0, "?()" );
|
CHECK_ERROR( f(), unexpected_call, 0, "?()" );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int( int, const std::string& ) > f;
|
mock::detail::function< int( int, const std::string& ) > f;
|
||||||
f.expect();
|
f.expect();
|
||||||
f.reset();
|
f.reset();
|
||||||
CHECK_ERROR( f( 1, "s" ), unexpected_call, 0, "?( 1, \"s\" )" );
|
CHECK_ERROR( f( 1, "s" ), unexpected_call, 0, "?( 1, \"s\" )" );
|
||||||
|
|
@ -247,13 +247,13 @@ BOOST_FIXTURE_TEST_CASE( triggering_a_reset_function_calls_unexpected_call_error
|
||||||
BOOST_FIXTURE_TEST_CASE( verifying_a_reset_function_succeeds, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( verifying_a_reset_function_succeeds, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
f.expect();
|
f.expect();
|
||||||
f.reset();
|
f.reset();
|
||||||
BOOST_CHECK( f.verify() );
|
BOOST_CHECK( f.verify() );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int( int, const std::string& ) > f;
|
mock::detail::function< int( int, const std::string& ) > f;
|
||||||
f.expect();
|
f.expect();
|
||||||
f.reset();
|
f.reset();
|
||||||
BOOST_CHECK( f.verify() );
|
BOOST_CHECK( f.verify() );
|
||||||
|
|
@ -265,12 +265,12 @@ BOOST_FIXTURE_TEST_CASE( verifying_a_reset_function_succeeds, error_fixture )
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in_equal_constraint_calls_unexpected_call_error, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in_equal_constraint_calls_unexpected_call_error, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void( int ) > f;
|
mock::detail::function< void( int ) > f;
|
||||||
f.expect().with( 42 );
|
f.expect().with( 42 );
|
||||||
CHECK_ERROR( f( 43 ), unexpected_call, 0, "?( 43 )\n. unlimited().with( 42 )" );
|
CHECK_ERROR( f( 43 ), unexpected_call, 0, "?( 43 )\n. unlimited().with( 42 )" );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int( int, const std::string& ) > f;
|
mock::detail::function< int( int, const std::string& ) > f;
|
||||||
f.expect().with( 42, "expected" );
|
f.expect().with( 42, "expected" );
|
||||||
CHECK_ERROR( f( 42, "actual" ), unexpected_call, 0, "?( 42, \"actual\" )\n. unlimited().with( 42, \"expected\" )" );
|
CHECK_ERROR( f( 42, "actual" ), unexpected_call, 0, "?( 42, \"actual\" )\n. unlimited().with( 42, \"expected\" )" );
|
||||||
}
|
}
|
||||||
|
|
@ -278,7 +278,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_unexpected_call_error, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in_equal_or_less_constraint_calls_unexpected_call_error, error_fixture )
|
||||||
{
|
{
|
||||||
mock::function< void( int ) > f;
|
mock::detail::function< void( int ) > f;
|
||||||
f.expect().with( mock::equal( 42 ) || mock::less( 42 ) );
|
f.expect().with( mock::equal( 42 ) || mock::less( 42 ) );
|
||||||
f( 41 );
|
f( 41 );
|
||||||
f( 42 );
|
f( 42 );
|
||||||
|
|
@ -287,7 +287,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_unexpected_call_error, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in_equal_and_not_less_constraint_calls_unexpected_call_error, error_fixture )
|
||||||
{
|
{
|
||||||
mock::function< void( int ) > f;
|
mock::detail::function< void( int ) > f;
|
||||||
f.expect().with( mock::equal( 42 ) && ! mock::less( 41 ) );
|
f.expect().with( mock::equal( 42 ) && ! mock::less( 41 ) );
|
||||||
f( 42 );
|
f( 42 );
|
||||||
CHECK_ERROR( f( 43 ), unexpected_call, 1, "?( 43 )\n. unlimited().with( ( equal( 42 ) && ! less( 41 ) ) )" );
|
CHECK_ERROR( f( 43 ), unexpected_call, 1, "?( 43 )\n. unlimited().with( ( equal( 42 ) && ! less( 41 ) ) )" );
|
||||||
|
|
@ -311,14 +311,14 @@ namespace
|
||||||
BOOST_FIXTURE_TEST_CASE( passing_call_values_by_reference_is_transparent, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( passing_call_values_by_reference_is_transparent, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void( my_interface& ) > f;
|
mock::detail::function< void( my_interface& ) > f;
|
||||||
my_implementation imp;
|
my_implementation imp;
|
||||||
f.expect().with( mock::same( imp ) );
|
f.expect().with( mock::same( imp ) );
|
||||||
f( imp );
|
f( imp );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< void( const my_interface& ) > f;
|
mock::detail::function< void( const my_interface& ) > f;
|
||||||
my_implementation imp;
|
my_implementation imp;
|
||||||
f.expect().with( mock::same( imp ) );
|
f.expect().with( mock::same( imp ) );
|
||||||
f( imp );
|
f( imp );
|
||||||
|
|
@ -337,12 +337,12 @@ namespace
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_failing_custom_constraint_calls_unexpected_call_error, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_failing_custom_constraint_calls_unexpected_call_error, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void( int ) > f;
|
mock::detail::function< void( int ) > f;
|
||||||
f.expect().with( &custom_constraint );
|
f.expect().with( &custom_constraint );
|
||||||
CHECK_ERROR( f( 42 ), unexpected_call, 0, "?( 42 )\n. unlimited().with( ? )" );
|
CHECK_ERROR( f( 42 ), unexpected_call, 0, "?( 42 )\n. unlimited().with( ? )" );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int( int, const std::string& ) > f;
|
mock::detail::function< int( int, const std::string& ) > f;
|
||||||
f.expect().with( &custom_constraint, "actual" );
|
f.expect().with( &custom_constraint, "actual" );
|
||||||
CHECK_ERROR( f( 42, "actual" ), unexpected_call, 0, "?( 42, \"actual\" )\n. unlimited().with( ?, \"actual\" )" );
|
CHECK_ERROR( f( 42, "actual" ), unexpected_call, 0, "?( 42, \"actual\" )\n. unlimited().with( ?, \"actual\" )" );
|
||||||
}
|
}
|
||||||
|
|
@ -350,7 +350,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_failing_custom_constrain
|
||||||
|
|
||||||
//BOOST_FIXTURE_TEST_CASE( literal_zero_can_be_used_in_place_of_null_pointers_in_constraints, error_fixture )
|
//BOOST_FIXTURE_TEST_CASE( literal_zero_can_be_used_in_place_of_null_pointers_in_constraints, error_fixture )
|
||||||
//{
|
//{
|
||||||
// mock::function< void( int* ) > f;
|
// mock::detail::function< void( int* ) > f;
|
||||||
// f.expect().with( 0 );
|
// f.expect().with( 0 );
|
||||||
// f.reset();
|
// f.reset();
|
||||||
// CHECK_CALLS( 1 );
|
// CHECK_CALLS( 1 );
|
||||||
|
|
@ -361,17 +361,17 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_failing_custom_constrain
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_no_return_set_calls_missing_action, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_no_return_set_calls_missing_action, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< int() > f;
|
mock::detail::function< int() > f;
|
||||||
f.expect();
|
f.expect();
|
||||||
CHECK_ERROR( f(), missing_action, 0, "?()\n. unlimited()" );
|
CHECK_ERROR( f(), missing_action, 0, "?()\n. unlimited()" );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int&() > f;
|
mock::detail::function< int&() > f;
|
||||||
f.expect();
|
f.expect();
|
||||||
CHECK_ERROR( f(), missing_action, 0, "?()\n. unlimited()" );
|
CHECK_ERROR( f(), missing_action, 0, "?()\n. unlimited()" );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< const std::string&() > f;
|
mock::detail::function< const std::string&() > f;
|
||||||
f.expect();
|
f.expect();
|
||||||
CHECK_ERROR( f(), missing_action, 0, "?()\n. unlimited()" );
|
CHECK_ERROR( f(), missing_action, 0, "?()\n. unlimited()" );
|
||||||
}
|
}
|
||||||
|
|
@ -380,20 +380,20 @@ 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 )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_value, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< int() > f;
|
mock::detail::function< int() > f;
|
||||||
f.expect().returns( 42 );
|
f.expect().returns( 42 );
|
||||||
BOOST_CHECK_EQUAL( 42, f() );
|
BOOST_CHECK_EQUAL( 42, f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int() > f;
|
mock::detail::function< int() > f;
|
||||||
const int i = 42;
|
const int i = 42;
|
||||||
f.expect().returns( i );
|
f.expect().returns( i );
|
||||||
BOOST_CHECK_EQUAL( i, f() );
|
BOOST_CHECK_EQUAL( i, f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int() > f;
|
mock::detail::function< int() > f;
|
||||||
int i = 42;
|
int i = 42;
|
||||||
f.expect().returns( boost::ref( i ) );
|
f.expect().returns( boost::ref( i ) );
|
||||||
i = 43;
|
i = 43;
|
||||||
|
|
@ -401,20 +401,20 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_value, error_
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int&() > f;
|
mock::detail::function< int&() > f;
|
||||||
f.expect().returns( 42 );
|
f.expect().returns( 42 );
|
||||||
BOOST_CHECK_EQUAL( 42, f() );
|
BOOST_CHECK_EQUAL( 42, f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int&() > f;
|
mock::detail::function< int&() > f;
|
||||||
const int result = 42;
|
const int result = 42;
|
||||||
f.expect().returns( result );
|
f.expect().returns( result );
|
||||||
BOOST_CHECK_EQUAL( result, f() );
|
BOOST_CHECK_EQUAL( result, f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int&() > f;
|
mock::detail::function< int&() > f;
|
||||||
int i = 42;
|
int i = 42;
|
||||||
f.expect().returns( i );
|
f.expect().returns( i );
|
||||||
i = 43;
|
i = 43;
|
||||||
|
|
@ -422,7 +422,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_value, error_
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int&() > f;
|
mock::detail::function< int&() > f;
|
||||||
int i = 42;
|
int i = 42;
|
||||||
f.expect().returns( boost::ref( i ) );
|
f.expect().returns( boost::ref( i ) );
|
||||||
i = 43;
|
i = 43;
|
||||||
|
|
@ -432,31 +432,31 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_value, error_
|
||||||
CHECK_CALLS( 2 );
|
CHECK_CALLS( 2 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< std::string() > f;
|
mock::detail::function< std::string() > f;
|
||||||
f.expect().returns( "result" );
|
f.expect().returns( "result" );
|
||||||
BOOST_CHECK_EQUAL( "result", f() );
|
BOOST_CHECK_EQUAL( "result", f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< const std::string&() > f;
|
mock::detail::function< const std::string&() > f;
|
||||||
f.expect().returns( "result" );
|
f.expect().returns( "result" );
|
||||||
BOOST_CHECK_EQUAL( "result", f() );
|
BOOST_CHECK_EQUAL( "result", f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int*() > f;
|
mock::detail::function< int*() > f;
|
||||||
f.expect().returns( 0 );
|
f.expect().returns( 0 );
|
||||||
BOOST_CHECK( ! f() );
|
BOOST_CHECK( ! f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int() > f;
|
mock::detail::function< int() > f;
|
||||||
f.expect().returns( 0 );
|
f.expect().returns( 0 );
|
||||||
BOOST_CHECK_EQUAL( 0, f() );
|
BOOST_CHECK_EQUAL( 0, f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< int&() > f;
|
mock::detail::function< int&() > f;
|
||||||
f.expect().returns( 0 );
|
f.expect().returns( 0 );
|
||||||
BOOST_CHECK_EQUAL( 0, f() );
|
BOOST_CHECK_EQUAL( 0, f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
|
|
@ -472,7 +472,7 @@ namespace
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_value, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_value, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< std::auto_ptr< int >() > f;
|
mock::detail::function< std::auto_ptr< int >() > f;
|
||||||
std::auto_ptr< int > ptr( new int( 3 ) );
|
std::auto_ptr< int > ptr( new int( 3 ) );
|
||||||
f.expect().returns( boost::ref( ptr ) );
|
f.expect().returns( boost::ref( ptr ) );
|
||||||
BOOST_CHECK_EQUAL( 3, *ptr );
|
BOOST_CHECK_EQUAL( 3, *ptr );
|
||||||
|
|
@ -482,7 +482,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_valu
|
||||||
CHECK_CALLS( 2 );
|
CHECK_CALLS( 2 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< std::auto_ptr< int >() > f;
|
mock::detail::function< std::auto_ptr< int >() > f;
|
||||||
std::auto_ptr< int > ptr( new int( 3 ) );
|
std::auto_ptr< int > ptr( new int( 3 ) );
|
||||||
f.expect().returns( ptr );
|
f.expect().returns( ptr );
|
||||||
BOOST_CHECK( ! ptr.get() );
|
BOOST_CHECK( ! ptr.get() );
|
||||||
|
|
@ -491,33 +491,33 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_valu
|
||||||
CHECK_CALLS( 2 );
|
CHECK_CALLS( 2 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< std::auto_ptr< int >() > f;
|
mock::detail::function< std::auto_ptr< int >() > f;
|
||||||
f.expect().returns( new int( 3 ) );
|
f.expect().returns( new int( 3 ) );
|
||||||
BOOST_CHECK_EQUAL( 3, *f() );
|
BOOST_CHECK_EQUAL( 3, *f() );
|
||||||
BOOST_CHECK( ! f().get() );
|
BOOST_CHECK( ! f().get() );
|
||||||
CHECK_CALLS( 2 );
|
CHECK_CALLS( 2 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< std::auto_ptr< int >() > f;
|
mock::detail::function< std::auto_ptr< int >() > f;
|
||||||
f.expect().returns( std::auto_ptr< int >( new int( 3 ) ) );
|
f.expect().returns( std::auto_ptr< int >( new int( 3 ) ) );
|
||||||
BOOST_CHECK_EQUAL( 3, *f() );
|
BOOST_CHECK_EQUAL( 3, *f() );
|
||||||
BOOST_CHECK( ! f().get() );
|
BOOST_CHECK( ! f().get() );
|
||||||
CHECK_CALLS( 2 );
|
CHECK_CALLS( 2 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< std::auto_ptr< A >() > f;
|
mock::detail::function< std::auto_ptr< A >() > f;
|
||||||
f.expect().returns( new B );
|
f.expect().returns( new B );
|
||||||
BOOST_CHECK_NO_THROW( f() );
|
BOOST_CHECK_NO_THROW( f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< std::auto_ptr< A >() > f;
|
mock::detail::function< std::auto_ptr< A >() > f;
|
||||||
f.expect().returns( std::auto_ptr< A >( new B ) );
|
f.expect().returns( std::auto_ptr< A >( new B ) );
|
||||||
BOOST_CHECK_NO_THROW( f() );
|
BOOST_CHECK_NO_THROW( f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< std::auto_ptr< A >() > f;
|
mock::detail::function< std::auto_ptr< A >() > f;
|
||||||
f.expect().returns( std::auto_ptr< B >( new B ) );
|
f.expect().returns( std::auto_ptr< B >( new B ) );
|
||||||
BOOST_CHECK_NO_THROW( f() );
|
BOOST_CHECK_NO_THROW( f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
|
|
@ -534,7 +534,7 @@ namespace
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor, error_fixture )
|
||||||
{
|
{
|
||||||
mock::function< int() > f;
|
mock::detail::function< int() > f;
|
||||||
f.expect().calls( &custom_result );
|
f.expect().calls( &custom_result );
|
||||||
BOOST_CHECK_EQUAL( 42, f() );
|
BOOST_CHECK_EQUAL( 42, f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
|
|
@ -550,7 +550,7 @@ namespace
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor_with_parameters, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor_with_parameters, error_fixture )
|
||||||
{
|
{
|
||||||
mock::function< int( int ) > f;
|
mock::detail::function< int( int ) > f;
|
||||||
f.expect().calls( &custom_result_with_parameter );
|
f.expect().calls( &custom_result_with_parameter );
|
||||||
BOOST_CHECK_EQUAL( 42, f( 42 ) );
|
BOOST_CHECK_EQUAL( 42, f( 42 ) );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
|
|
@ -558,7 +558,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor_with
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor_without_parameters_thanks_to_boost_bind, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor_without_parameters_thanks_to_boost_bind, error_fixture )
|
||||||
{
|
{
|
||||||
mock::function< int( int ) > f;
|
mock::detail::function< int( int ) > f;
|
||||||
f.expect().calls( boost::bind( &custom_result ) );
|
f.expect().calls( boost::bind( &custom_result ) );
|
||||||
BOOST_CHECK_EQUAL( 42, f( 17 ) );
|
BOOST_CHECK_EQUAL( 42, f( 17 ) );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
|
|
@ -566,7 +566,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_calls_the_custom_functor_with
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_throws_the_set_exception, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_throws_the_set_exception, error_fixture )
|
||||||
{
|
{
|
||||||
mock::function< int() > f;
|
mock::detail::function< int() > f;
|
||||||
f.expect().throws( std::runtime_error( "some exception" ) );
|
f.expect().throws( std::runtime_error( "some exception" ) );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -586,7 +586,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 )
|
BOOST_FIXTURE_TEST_CASE( expecting_twice_a_single_expectation_makes_it_callable_twice, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
f();
|
f();
|
||||||
|
|
@ -594,7 +594,7 @@ BOOST_FIXTURE_TEST_CASE( expecting_twice_a_single_expectation_makes_it_callable_
|
||||||
CHECK_ERROR( f(), unexpected_call, 2, "?()\nv once()\nv once()" );
|
CHECK_ERROR( f(), unexpected_call, 2, "?()\nv once()\nv once()" );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< void( const std::string& ) > f;
|
mock::detail::function< void( const std::string& ) > f;
|
||||||
f.expect().once().with( "first" );
|
f.expect().once().with( "first" );
|
||||||
f.expect().once().with( "second" );
|
f.expect().once().with( "second" );
|
||||||
f( "first" );
|
f( "first" );
|
||||||
|
|
@ -606,7 +606,7 @@ BOOST_FIXTURE_TEST_CASE( expecting_twice_a_single_expectation_makes_it_callable_
|
||||||
BOOST_FIXTURE_TEST_CASE( best_expectation_is_selected_first, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( best_expectation_is_selected_first, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void( int ) > f;
|
mock::detail::function< void( int ) > f;
|
||||||
f.expect().once().with( 1 );
|
f.expect().once().with( 1 );
|
||||||
f.expect().once().with( 2 );
|
f.expect().once().with( 2 );
|
||||||
f( 2 );
|
f( 2 );
|
||||||
|
|
@ -614,7 +614,7 @@ BOOST_FIXTURE_TEST_CASE( best_expectation_is_selected_first, error_fixture )
|
||||||
CHECK_ERROR( f( 3 ), unexpected_call, 2, "?( 3 )\nv once().with( 1 )\nv once().with( 2 )" );
|
CHECK_ERROR( f( 3 ), unexpected_call, 2, "?( 3 )\nv once().with( 1 )\nv once().with( 2 )" );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< void( const std::string& ) > f;
|
mock::detail::function< void( const std::string& ) > f;
|
||||||
f.expect().once().with( "first" );
|
f.expect().once().with( "first" );
|
||||||
f.expect().once().with( "second" );
|
f.expect().once().with( "second" );
|
||||||
f( "second" );
|
f( "second" );
|
||||||
|
|
@ -639,7 +639,7 @@ namespace
|
||||||
BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, error_fixture )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
mock::function< void( int ) > f;
|
mock::detail::function< void( int ) > f;
|
||||||
f.expect().once().with( 1 );
|
f.expect().once().with( 1 );
|
||||||
f.expect().once().with( 2 );
|
f.expect().once().with( 2 );
|
||||||
BOOST_CHECK_NO_THROW( f( 2 ) );
|
BOOST_CHECK_NO_THROW( f( 2 ) );
|
||||||
|
|
@ -651,7 +651,7 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err
|
||||||
f.reset();
|
f.reset();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< void( int ) > f;
|
mock::detail::function< void( int ) > f;
|
||||||
f.expect().never().with( 1 );
|
f.expect().never().with( 1 );
|
||||||
const std::string expected = "?\n"
|
const std::string expected = "?\n"
|
||||||
"v never().with( 1 )";
|
"v never().with( 1 )";
|
||||||
|
|
@ -659,7 +659,7 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err
|
||||||
f.reset();
|
f.reset();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< void( const std::string& ) > f;
|
mock::detail::function< void( const std::string& ) > f;
|
||||||
f.expect().never().with( mock::less( "first" ) );
|
f.expect().never().with( mock::less( "first" ) );
|
||||||
f.expect().exactly( 2 ).with( "second" );
|
f.expect().exactly( 2 ).with( "second" );
|
||||||
BOOST_CHECK_NO_THROW( f( "second" ) );
|
BOOST_CHECK_NO_THROW( f( "second" ) );
|
||||||
|
|
@ -680,7 +680,7 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err
|
||||||
f.reset();
|
f.reset();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< void( int ) > f;
|
mock::detail::function< void( int ) > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
const std::string expected = "?\n"
|
const std::string expected = "?\n"
|
||||||
". once().with( any )";
|
". once().with( any )";
|
||||||
|
|
@ -688,7 +688,7 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err
|
||||||
f.reset();
|
f.reset();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< void( int ) > f;
|
mock::detail::function< void( int ) > f;
|
||||||
f.expect().once().with( mock::any );
|
f.expect().once().with( mock::any );
|
||||||
const std::string expected = "?\n"
|
const std::string expected = "?\n"
|
||||||
". once().with( any )";
|
". once().with( any )";
|
||||||
|
|
@ -696,7 +696,7 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err
|
||||||
f.reset();
|
f.reset();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< void( int ) > f;
|
mock::detail::function< void( int ) > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
const std::string expected = "?\n"
|
const std::string expected = "?\n"
|
||||||
". once().with( any )";
|
". once().with( any )";
|
||||||
|
|
@ -704,7 +704,7 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err
|
||||||
f.reset();
|
f.reset();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mock::function< void( int ) > f;
|
mock::detail::function< void( int ) > f;
|
||||||
f.expect().once().with( &custom_constraint );
|
f.expect().once().with( &custom_constraint );
|
||||||
const std::string expected = "?\n"
|
const std::string expected = "?\n"
|
||||||
". once().with( ? )";
|
". once().with( ? )";
|
||||||
|
|
@ -715,27 +715,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 )
|
BOOST_FIXTURE_TEST_CASE( expectation_with_remaining_untriggered_matches_upon_destruction_calls_untriggered_expectation, error_fixture )
|
||||||
{
|
{
|
||||||
std::auto_ptr< mock::function< void() > > f( new mock::function< void() > );
|
std::auto_ptr< mock::detail::function< void() > > f( new mock::detail::function< void() > );
|
||||||
f->expect().once();
|
f->expect().once();
|
||||||
CHECK_ERROR( f.reset(), untriggered_expectation, 0, "?\n. once()" );
|
CHECK_ERROR( f.reset(), untriggered_expectation, 0, "?\n. once()" );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( verifying_expectation_with_remaining_matches_disables_the_automatic_verification_upon_destruction, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( verifying_expectation_with_remaining_matches_disables_the_automatic_verification_upon_destruction, error_fixture )
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
CHECK_ERROR( f.verify(), verification_failed, 0, "?\n. once()" );
|
CHECK_ERROR( f.verify(), verification_failed, 0, "?\n. once()" );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_unexpected_call_call_disables_the_automatic_verification_upon_destruction, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_unexpected_call_call_disables_the_automatic_verification_upon_destruction, error_fixture )
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
CHECK_ERROR( f(), unexpected_call, 0, "?()" );
|
CHECK_ERROR( f(), unexpected_call, 0, "?()" );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( adding_an_expectation_reactivates_the_verification_upon_destruction, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( adding_an_expectation_reactivates_the_verification_upon_destruction, error_fixture )
|
||||||
{
|
{
|
||||||
std::auto_ptr< mock::function< void() > > f( new mock::function< void() > );
|
std::auto_ptr< mock::detail::function< void() > > f( new mock::detail::function< void() > );
|
||||||
CHECK_ERROR( (*f)(), unexpected_call, 0, "?()" );
|
CHECK_ERROR( (*f)(), unexpected_call, 0, "?()" );
|
||||||
f->expect().once();
|
f->expect().once();
|
||||||
CHECK_ERROR( f.reset(), untriggered_expectation, 0, "?\n. once()" );
|
CHECK_ERROR( f.reset(), untriggered_expectation, 0, "?\n. once()" );
|
||||||
|
|
@ -745,7 +745,7 @@ BOOST_FIXTURE_TEST_CASE( throwing_an_exception_disables_the_automatic_verificati
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mock::function< void() > f;
|
mock::detail::function< void() > f;
|
||||||
f.expect().once();
|
f.expect().once();
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ namespace
|
||||||
mock::detail::configure( o, e, "instance", mock::detail::type_name( typeid( "type" ) ), "name" );
|
mock::detail::configure( o, e, "instance", mock::detail::type_name( typeid( "type" ) ), "name" );
|
||||||
}
|
}
|
||||||
object o;
|
object o;
|
||||||
mock::function< void() > e;
|
mock::detail::function< void() > e;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ BOOST_FIXTURE_TEST_CASE( resetting_an_object_containing_a_failing_expectation_an
|
||||||
BOOST_AUTO_TEST_CASE( an_object_is_assignable_by_sharing_its_state )
|
BOOST_AUTO_TEST_CASE( an_object_is_assignable_by_sharing_its_state )
|
||||||
{
|
{
|
||||||
object o1;
|
object o1;
|
||||||
mock::function< void() > e;
|
mock::detail::function< void() > e;
|
||||||
{
|
{
|
||||||
object o2;
|
object o2;
|
||||||
mock::detail::configure( o2, e, "instance", mock::detail::type_name( typeid( "type" ) ), "name" );
|
mock::detail::configure( o2, e, "instance", mock::detail::type_name( typeid( "type" ) ), "name" );
|
||||||
|
|
@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE( an_object_is_copiable_by_sharing_its_state )
|
||||||
{
|
{
|
||||||
std::auto_ptr< object > o2( new object );
|
std::auto_ptr< object > o2( new object );
|
||||||
const object o1( *o2 );
|
const object o1( *o2 );
|
||||||
mock::function< void() > e;
|
mock::detail::function< void() > e;
|
||||||
mock::detail::configure( *o2, e, "instance", mock::detail::type_name( typeid( "type" ) ), "name" );
|
mock::detail::configure( *o2, e, "instance", mock::detail::type_name( typeid( "type" ) ), "name" );
|
||||||
e.expect().once();
|
e.expect().once();
|
||||||
BOOST_CHECK( ! mock::verify( *o2 ) );
|
BOOST_CHECK( ! mock::verify( *o2 ) );
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,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_throws )
|
||||||
{
|
{
|
||||||
mock::sequence s;
|
mock::sequence s;
|
||||||
mock::function< void( int ) > e;
|
mock::detail::function< void( int ) > e;
|
||||||
e.expect().once().with( 1 ).in( s );
|
e.expect().once().with( 1 ).in( s );
|
||||||
e.expect().once().with( 2 ).in( s );
|
e.expect().once().with( 2 ).in( s );
|
||||||
BOOST_CHECK_NO_THROW( e( 2 ) );
|
BOOST_CHECK_NO_THROW( e( 2 ) );
|
||||||
|
|
@ -24,7 +24,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 )
|
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_out_of_order_multiple_invocations_throws )
|
||||||
{
|
{
|
||||||
mock::sequence s;
|
mock::sequence s;
|
||||||
mock::function< void( int ) > e;
|
mock::detail::function< void( int ) > e;
|
||||||
e.expect().with( 1 ).in( s );
|
e.expect().with( 1 ).in( s );
|
||||||
e.expect().once().with( 2 ).in( s );
|
e.expect().once().with( 2 ).in( s );
|
||||||
BOOST_CHECK_NO_THROW( e( 1 ) );
|
BOOST_CHECK_NO_THROW( e( 1 ) );
|
||||||
|
|
@ -35,7 +35,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 )
|
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_in_order_is_valid )
|
||||||
{
|
{
|
||||||
mock::sequence s;
|
mock::sequence s;
|
||||||
mock::function< void( int ) > e;
|
mock::detail::function< void( int ) > e;
|
||||||
e.expect().once().with( 1 ).in( s );
|
e.expect().once().with( 1 ).in( s );
|
||||||
e.expect().once().with( 2 ).in( s );
|
e.expect().once().with( 2 ).in( s );
|
||||||
BOOST_CHECK_NO_THROW( e( 1 ) );
|
BOOST_CHECK_NO_THROW( e( 1 ) );
|
||||||
|
|
@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_in_order_is_valid )
|
||||||
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_multiply_calling_in_order_is_valid )
|
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_multiply_calling_in_order_is_valid )
|
||||||
{
|
{
|
||||||
mock::sequence s;
|
mock::sequence s;
|
||||||
mock::function< void( int ) > e;
|
mock::detail::function< void( int ) > e;
|
||||||
e.expect().exactly( 2 ).with( 1 ).in( s );
|
e.expect().exactly( 2 ).with( 1 ).in( s );
|
||||||
e.expect().exactly( 2 ).with( 2 ).in( s );
|
e.expect().exactly( 2 ).with( 2 ).in( s );
|
||||||
BOOST_CHECK_NO_THROW( e( 1 ) );
|
BOOST_CHECK_NO_THROW( e( 1 ) );
|
||||||
|
|
@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_multiply_calling_in_order_is
|
||||||
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_enforces_call_order_verification_between_two_different_expectations )
|
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_enforces_call_order_verification_between_two_different_expectations )
|
||||||
{
|
{
|
||||||
mock::sequence s;
|
mock::sequence s;
|
||||||
mock::function< void() > e1, e2;
|
mock::detail::function< void() > e1, e2;
|
||||||
e1.expect().once().in( s );
|
e1.expect().once().in( s );
|
||||||
e2.expect().once().in( s );
|
e2.expect().once().in( s );
|
||||||
BOOST_CHECK_NO_THROW( e2() );
|
BOOST_CHECK_NO_THROW( e2() );
|
||||||
|
|
@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE( registering_to_a_sequence_enforces_call_order_verification
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( destroying_a_sequence_does_not_remove_order_call_enforcement )
|
BOOST_AUTO_TEST_CASE( destroying_a_sequence_does_not_remove_order_call_enforcement )
|
||||||
{
|
{
|
||||||
mock::function< void() > e1, e2;
|
mock::detail::function< void() > e1, e2;
|
||||||
{
|
{
|
||||||
mock::sequence s;
|
mock::sequence s;
|
||||||
e1.expect().once().in( s );
|
e1.expect().once().in( s );
|
||||||
|
|
@ -81,7 +81,7 @@ BOOST_AUTO_TEST_CASE( destroying_a_sequence_does_not_remove_order_call_enforceme
|
||||||
BOOST_AUTO_TEST_CASE( resetting_an_expectation_removes_it_from_order_call_enforcement )
|
BOOST_AUTO_TEST_CASE( resetting_an_expectation_removes_it_from_order_call_enforcement )
|
||||||
{
|
{
|
||||||
mock::sequence s;
|
mock::sequence s;
|
||||||
mock::function< void() > e1, e2;
|
mock::detail::function< void() > e1, e2;
|
||||||
e1.expect().once().in( s );
|
e1.expect().once().in( s );
|
||||||
e2.expect().once().in( s );
|
e2.expect().once().in( s );
|
||||||
e1.reset();
|
e1.reset();
|
||||||
|
|
@ -93,7 +93,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 )
|
BOOST_AUTO_TEST_CASE( an_expectation_can_be_used_in_several_sequences )
|
||||||
{
|
{
|
||||||
mock::sequence s1, s2;
|
mock::sequence s1, s2;
|
||||||
mock::function< void() > e;
|
mock::detail::function< void() > e;
|
||||||
e.expect().once().in( s1 ).in( s2 );
|
e.expect().once().in( s1 ).in( s2 );
|
||||||
BOOST_CHECK_NO_THROW( e() );
|
BOOST_CHECK_NO_THROW( e() );
|
||||||
BOOST_CHECK( e.verify() );
|
BOOST_CHECK( e.verify() );
|
||||||
|
|
@ -102,7 +102,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 )
|
BOOST_AUTO_TEST_CASE( a_result_specification_is_set_after_a_sequence )
|
||||||
{
|
{
|
||||||
mock::sequence s;
|
mock::sequence s;
|
||||||
mock::function< int() > e;
|
mock::detail::function< int() > e;
|
||||||
e.expect().once().in( s ).returns( 3 );
|
e.expect().once().in( s ).returns( 3 );
|
||||||
BOOST_CHECK_EQUAL( 3, e() );
|
BOOST_CHECK_EQUAL( 3, e() );
|
||||||
BOOST_CHECK( e.verify() );
|
BOOST_CHECK( e.verify() );
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,12 @@
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
template< typename Signature >
|
template< typename Signature >
|
||||||
bool verify( const function< Signature >& f )
|
bool verify( const detail::function< Signature >& f )
|
||||||
{
|
{
|
||||||
return f.verify();
|
return f.verify();
|
||||||
}
|
}
|
||||||
template< typename Signature >
|
template< typename Signature >
|
||||||
void reset( function< Signature >& f )
|
void reset( detail::function< Signature >& f )
|
||||||
{
|
{
|
||||||
f.reset();
|
f.reset();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
#include "expectation_template.hpp"
|
#include "expectation_template.hpp"
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
|
{
|
||||||
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename Signature > class function;
|
template< typename Signature > class function;
|
||||||
|
|
||||||
|
|
@ -264,4 +266,5 @@ namespace mock
|
||||||
|
|
||||||
boost::shared_ptr< function_impl > impl_;
|
boost::shared_ptr< function_impl > impl_;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace mock
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename S >
|
template< typename S >
|
||||||
struct functor : mock::function< S >
|
struct functor : mock::detail::function< S >
|
||||||
{
|
{
|
||||||
functor()
|
functor()
|
||||||
{
|
{
|
||||||
|
|
@ -54,8 +54,8 @@ namespace detail
|
||||||
t##_mock( mock::detail::root, "?." )
|
t##_mock( mock::detail::root, "?." )
|
||||||
|
|
||||||
#define MOCK_METHOD_HELPER(S, t) \
|
#define MOCK_METHOD_HELPER(S, t) \
|
||||||
mutable mock::function< S > t##_mock_; \
|
mutable mock::detail::function< S > t##_mock_; \
|
||||||
mock::function< S >& t##_mock( \
|
mock::detail::function< S >& t##_mock( \
|
||||||
const mock::detail::context&, \
|
const mock::detail::context&, \
|
||||||
boost::unit_test::const_string instance ) const \
|
boost::unit_test::const_string instance ) const \
|
||||||
{ \
|
{ \
|
||||||
|
|
@ -120,11 +120,11 @@ namespace detail
|
||||||
MOCK_METHOD_HELPER(T(), t)
|
MOCK_METHOD_HELPER(T(), t)
|
||||||
|
|
||||||
#define MOCK_FUNCTION_HELPER(S, t, s) \
|
#define MOCK_FUNCTION_HELPER(S, t, s) \
|
||||||
s mock::function< S >& t##_mock( \
|
s mock::detail::function< S >& t##_mock( \
|
||||||
mock::detail::context& context, \
|
mock::detail::context& context, \
|
||||||
boost::unit_test::const_string instance ) \
|
boost::unit_test::const_string instance ) \
|
||||||
{ \
|
{ \
|
||||||
static mock::function< S > f; \
|
static mock::detail::function< S > f; \
|
||||||
return f( context, instance ); \
|
return f( context, instance ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue