diff --git a/test/detail/test_function.cpp b/test/detail/test_function.cpp index e234a6a..8d54c2c 100644 --- a/test/detail/test_function.cpp +++ b/test/detail/test_function.cpp @@ -72,13 +72,13 @@ namespace 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_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 ) ); } @@ -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 ) { { - mock::function< void() > f; + mock::detail::function< void() > f; 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\" )" ); } } @@ -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 ) { { - mock::function< void() > f; + mock::detail::function< void() > f; f.expect().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(); 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 ) { { - mock::function< void() > f; + mock::detail::function< void() > f; f.expect(); f(); f(); CHECK_CALLS( 2 ); } { - mock::function< void( int, const std::string& ) > f; + mock::detail::function< void( int, const std::string& ) > f; f.expect(); 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 ) { { - mock::function< void() > f; + mock::detail::function< void() > f; f.expect().once(); f(); 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( 1, "s" ); 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 ) { - mock::function< void( int* ) > f; + mock::detail::function< void( int* ) > f; f.expect().once(); f( 0 ); 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 ) { { - mock::function< void() > f; + mock::detail::function< void() > f; 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() ); } } @@ -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 ) { { - mock::function< void() > f; + mock::detail::function< void() > f; f.expect(); BOOST_CHECK( f.verify() ); CHECK_CALLS( 0 ); } CHECK_CALLS( 1 ); { - mock::function< int( int, const std::string& ) > f; + mock::detail::function< int( int, const std::string& ) > f; f.expect(); BOOST_CHECK( f.verify() ); 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 ) { { - mock::function< void() > f; + mock::detail::function< void() > f; f.expect().once(); f(); BOOST_CHECK( f.verify() ); CHECK_CALLS( 1 ); } { - mock::function< void( int, const std::string& ) > f; + mock::detail::function< void( int, const std::string& ) > f; f.expect().once(); f( 1, "s" ); 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 ) { { - mock::function< void() > f; + mock::detail::function< void() > f; f.expect().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(); 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 ) { - mock::function< void() > f; + mock::detail::function< void() > f; f.expect().once(); CHECK_ERROR( BOOST_CHECK( ! f.verify() ), verification_failed, 0, "?\n. once()" ); 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 ) { { - mock::function< void() > f; + mock::detail::function< void() > f; f.expect(); f.reset(); 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.reset(); 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 ) { { - mock::function< void() > f; + mock::detail::function< void() > f; f.expect(); f.reset(); BOOST_CHECK( f.verify() ); } { - mock::function< int( int, const std::string& ) > f; + mock::detail::function< int( int, const std::string& ) > f; f.expect(); f.reset(); 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 ) { { - mock::function< void( int ) > f; + mock::detail::function< void( int ) > f; f.expect().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" ); 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 ) { - mock::function< void( int ) > f; + mock::detail::function< void( int ) > f; f.expect().with( mock::equal( 42 ) || mock::less( 42 ) ); f( 41 ); 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 ) { - mock::function< void( int ) > f; + mock::detail::function< void( int ) > f; f.expect().with( mock::equal( 42 ) && ! mock::less( 41 ) ); f( 42 ); 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 ) { { - mock::function< void( my_interface& ) > f; + mock::detail::function< void( my_interface& ) > f; my_implementation imp; f.expect().with( mock::same( imp ) ); f( imp ); CHECK_CALLS( 1 ); } { - mock::function< void( const my_interface& ) > f; + mock::detail::function< void( const my_interface& ) > f; my_implementation imp; f.expect().with( mock::same( 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 ) { { - mock::function< void( int ) > f; + mock::detail::function< void( int ) > f; f.expect().with( &custom_constraint ); 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" ); 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 ) //{ -// mock::function< void( int* ) > f; +// mock::detail::function< void( int* ) > f; // f.expect().with( 0 ); // f.reset(); // 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 ) { { - mock::function< int() > f; + mock::detail::function< int() > f; f.expect(); CHECK_ERROR( f(), missing_action, 0, "?()\n. unlimited()" ); } { - mock::function< int&() > f; + mock::detail::function< int&() > f; f.expect(); CHECK_ERROR( f(), missing_action, 0, "?()\n. unlimited()" ); } { - mock::function< const std::string&() > f; + mock::detail::function< const std::string&() > f; f.expect(); 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 ) { { - mock::function< int() > f; + mock::detail::function< int() > f; f.expect().returns( 42 ); BOOST_CHECK_EQUAL( 42, f() ); CHECK_CALLS( 1 ); } { - mock::function< int() > f; + mock::detail::function< int() > f; const int i = 42; f.expect().returns( i ); BOOST_CHECK_EQUAL( i, f() ); CHECK_CALLS( 1 ); } { - mock::function< int() > f; + mock::detail::function< int() > f; int i = 42; f.expect().returns( boost::ref( i ) ); i = 43; @@ -401,20 +401,20 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_value, error_ CHECK_CALLS( 1 ); } { - mock::function< int&() > f; + mock::detail::function< int&() > f; f.expect().returns( 42 ); BOOST_CHECK_EQUAL( 42, f() ); CHECK_CALLS( 1 ); } { - mock::function< int&() > f; + mock::detail::function< int&() > f; const int result = 42; f.expect().returns( result ); BOOST_CHECK_EQUAL( result, f() ); CHECK_CALLS( 1 ); } { - mock::function< int&() > f; + mock::detail::function< int&() > f; int i = 42; f.expect().returns( i ); i = 43; @@ -422,7 +422,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_value, error_ CHECK_CALLS( 1 ); } { - mock::function< int&() > f; + mock::detail::function< int&() > f; int i = 42; f.expect().returns( boost::ref( i ) ); i = 43; @@ -432,31 +432,31 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_value, error_ CHECK_CALLS( 2 ); } { - mock::function< std::string() > f; + mock::detail::function< std::string() > f; f.expect().returns( "result" ); BOOST_CHECK_EQUAL( "result", f() ); CHECK_CALLS( 1 ); } { - mock::function< const std::string&() > f; + mock::detail::function< const std::string&() > f; f.expect().returns( "result" ); BOOST_CHECK_EQUAL( "result", f() ); CHECK_CALLS( 1 ); } { - mock::function< int*() > f; + mock::detail::function< int*() > f; f.expect().returns( 0 ); BOOST_CHECK( ! f() ); CHECK_CALLS( 1 ); } { - mock::function< int() > f; + mock::detail::function< int() > f; f.expect().returns( 0 ); BOOST_CHECK_EQUAL( 0, f() ); CHECK_CALLS( 1 ); } { - mock::function< int&() > f; + mock::detail::function< int&() > f; f.expect().returns( 0 ); BOOST_CHECK_EQUAL( 0, f() ); CHECK_CALLS( 1 ); @@ -472,7 +472,7 @@ namespace 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 ) ); f.expect().returns( boost::ref( 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 ); } { - mock::function< std::auto_ptr< int >() > f; + mock::detail::function< std::auto_ptr< int >() > f; std::auto_ptr< int > ptr( new int( 3 ) ); f.expect().returns( ptr ); BOOST_CHECK( ! ptr.get() ); @@ -491,33 +491,33 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_valu CHECK_CALLS( 2 ); } { - mock::function< std::auto_ptr< int >() > f; + mock::detail::function< std::auto_ptr< int >() > f; f.expect().returns( new int( 3 ) ); BOOST_CHECK_EQUAL( 3, *f() ); BOOST_CHECK( ! f().get() ); 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 ) ) ); BOOST_CHECK_EQUAL( 3, *f() ); BOOST_CHECK( ! f().get() ); CHECK_CALLS( 2 ); } { - mock::function< std::auto_ptr< A >() > f; + mock::detail::function< std::auto_ptr< A >() > f; f.expect().returns( new B ); BOOST_CHECK_NO_THROW( f() ); 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 ) ); BOOST_CHECK_NO_THROW( f() ); 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 ) ); BOOST_CHECK_NO_THROW( f() ); CHECK_CALLS( 1 ); @@ -534,7 +534,7 @@ namespace 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 ); BOOST_CHECK_EQUAL( 42, f() ); CHECK_CALLS( 1 ); @@ -550,7 +550,7 @@ namespace 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 ); BOOST_CHECK_EQUAL( 42, f( 42 ) ); 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 ) { - mock::function< int( int ) > f; + mock::detail::function< int( int ) > f; f.expect().calls( boost::bind( &custom_result ) ); BOOST_CHECK_EQUAL( 42, f( 17 ) ); 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 ) { - mock::function< int() > f; + mock::detail::function< int() > f; f.expect().throws( std::runtime_error( "some exception" ) ); 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 ) { { - mock::function< void() > f; + mock::detail::function< void() > f; f.expect().once(); f.expect().once(); 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()" ); } { - mock::function< void( const std::string& ) > f; + mock::detail::function< void( const std::string& ) > f; f.expect().once().with( "first" ); f.expect().once().with( "second" ); 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 ) { { - mock::function< void( int ) > f; + mock::detail::function< void( int ) > f; f.expect().once().with( 1 ); f.expect().once().with( 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 )" ); } { - mock::function< void( const std::string& ) > f; + mock::detail::function< void( const std::string& ) > f; f.expect().once().with( "first" ); f.expect().once().with( "second" ); f( "second" ); @@ -639,7 +639,7 @@ namespace 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( 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(); } { - mock::function< void( int ) > f; + mock::detail::function< void( int ) > f; f.expect().never().with( 1 ); const std::string expected = "?\n" "v never().with( 1 )"; @@ -659,7 +659,7 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err 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().exactly( 2 ).with( "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(); } { - mock::function< void( int ) > f; + mock::detail::function< void( int ) > f; f.expect().once(); const std::string expected = "?\n" ". once().with( any )"; @@ -688,7 +688,7 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err f.reset(); } { - mock::function< void( int ) > f; + mock::detail::function< void( int ) > f; f.expect().once().with( mock::any ); const std::string expected = "?\n" ". once().with( any )"; @@ -696,7 +696,7 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err f.reset(); } { - mock::function< void( int ) > f; + mock::detail::function< void( int ) > f; f.expect().once(); const std::string expected = "?\n" ". once().with( any )"; @@ -704,7 +704,7 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err f.reset(); } { - mock::function< void( int ) > f; + mock::detail::function< void( int ) > f; f.expect().once().with( &custom_constraint ); const std::string expected = "?\n" ". 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 ) { - 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(); 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 ) { - mock::function< void() > f; + mock::detail::function< void() > f; f.expect().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 ) { - mock::function< void() > f; + mock::detail::function< void() > f; CHECK_ERROR( f(), unexpected_call, 0, "?()" ); } 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, "?()" ); f->expect().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 { - mock::function< void() > f; + mock::detail::function< void() > f; f.expect().once(); throw std::exception(); } diff --git a/test/test_object.cpp b/test/test_object.cpp index cb594f4..027b543 100644 --- a/test/test_object.cpp +++ b/test/test_object.cpp @@ -34,7 +34,7 @@ namespace mock::detail::configure( o, e, "instance", mock::detail::type_name( typeid( "type" ) ), "name" ); } 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 ) { object o1; - mock::function< void() > e; + mock::detail::function< void() > e; { object o2; 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 ); 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" ); e.expect().once(); BOOST_CHECK( ! mock::verify( *o2 ) ); diff --git a/test/test_sequence.cpp b/test/test_sequence.cpp index 5c5abc4..f2534ee 100644 --- a/test/test_sequence.cpp +++ b/test/test_sequence.cpp @@ -14,7 +14,7 @@ BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_out_of_order_throws ) { 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( 2 ).in( s ); 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 ) { mock::sequence s; - mock::function< void( int ) > e; + mock::detail::function< void( int ) > e; e.expect().with( 1 ).in( s ); e.expect().once().with( 2 ).in( s ); 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 ) { 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( 2 ).in( s ); 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 ) { 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( 2 ).in( s ); 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 ) { mock::sequence s; - mock::function< void() > e1, e2; + mock::detail::function< void() > e1, e2; e1.expect().once().in( s ); e2.expect().once().in( s ); 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 ) { - mock::function< void() > e1, e2; + mock::detail::function< void() > e1, e2; { mock::sequence 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 ) { mock::sequence s; - mock::function< void() > e1, e2; + mock::detail::function< void() > e1, e2; e1.expect().once().in( s ); e2.expect().once().in( s ); 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 ) { mock::sequence s1, s2; - mock::function< void() > e; + mock::detail::function< void() > e; e.expect().once().in( s1 ).in( s2 ); BOOST_CHECK_NO_THROW( e() ); 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 ) { mock::sequence s; - mock::function< int() > e; + mock::detail::function< int() > e; e.expect().once().in( s ).returns( 3 ); BOOST_CHECK_EQUAL( 3, e() ); BOOST_CHECK( e.verify() ); diff --git a/turtle/detail/function.hpp b/turtle/detail/function.hpp index 5170308..8498f30 100644 --- a/turtle/detail/function.hpp +++ b/turtle/detail/function.hpp @@ -48,12 +48,12 @@ namespace mock { template< typename Signature > - bool verify( const function< Signature >& f ) + bool verify( const detail::function< Signature >& f ) { return f.verify(); } template< typename Signature > - void reset( function< Signature >& f ) + void reset( detail::function< Signature >& f ) { f.reset(); } diff --git a/turtle/detail/function_template.hpp b/turtle/detail/function_template.hpp index 24e6250..e6b9f25 100644 --- a/turtle/detail/function_template.hpp +++ b/turtle/detail/function_template.hpp @@ -9,6 +9,8 @@ #include "expectation_template.hpp" namespace mock +{ +namespace detail { template< typename Signature > class function; @@ -264,4 +266,5 @@ namespace mock boost::shared_ptr< function_impl > impl_; }; +} } // mock diff --git a/turtle/mock.hpp b/turtle/mock.hpp index 0418305..8ca4fe7 100644 --- a/turtle/mock.hpp +++ b/turtle/mock.hpp @@ -24,7 +24,7 @@ namespace mock namespace detail { template< typename S > - struct functor : mock::function< S > + struct functor : mock::detail::function< S > { functor() { @@ -54,8 +54,8 @@ namespace detail t##_mock( mock::detail::root, "?." ) #define MOCK_METHOD_HELPER(S, t) \ - mutable mock::function< S > t##_mock_; \ - mock::function< S >& t##_mock( \ + mutable mock::detail::function< S > t##_mock_; \ + mock::detail::function< S >& t##_mock( \ const mock::detail::context&, \ boost::unit_test::const_string instance ) const \ { \ @@ -120,11 +120,11 @@ namespace detail MOCK_METHOD_HELPER(T(), t) #define MOCK_FUNCTION_HELPER(S, t, s) \ - s mock::function< S >& t##_mock( \ + s mock::detail::function< S >& t##_mock( \ mock::detail::context& context, \ boost::unit_test::const_string instance ) \ { \ - static mock::function< S > f; \ + static mock::detail::function< S > f; \ return f( context, instance ); \ }