From 3c0bb8e16eb25d1ae43812c7a124d828031b6ba3 Mon Sep 17 00:00:00 2001 From: mat007 Date: Mon, 7 Jan 2013 16:16:38 +0000 Subject: [PATCH] Cleanup git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@581 860be788-9bd5-4423-9f1e-828f051e677b --- test/test_constraints.cpp | 108 +++++++++++------------ turtle/constraint.hpp | 22 ++--- turtle/detail/action.hpp | 8 +- turtle/detail/expectation_template.hpp | 1 - turtle/detail/function_impl_template.hpp | 6 +- turtle/detail/invocation.hpp | 3 +- turtle/error.hpp | 3 +- turtle/matcher.hpp | 10 +-- 8 files changed, 79 insertions(+), 82 deletions(-) diff --git a/test/test_constraints.cpp b/test/test_constraints.cpp index c5d8ea8..809b076 100644 --- a/test/test_constraints.cpp +++ b/test/test_constraints.cpp @@ -43,8 +43,8 @@ BOOST_AUTO_TEST_CASE( constraints_can_be_combined_using_the_and_operator ) BOOST_AUTO_TEST_CASE( equal ) { - BOOST_CHECK( mock::equal( std::string( "string" ) ).f_( "string" ) ); - BOOST_CHECK( ! mock::equal( std::string( "string" ) ).f_( "not string" ) ); + BOOST_CHECK( mock::equal( std::string( "string" ) ).c_( "string" ) ); + BOOST_CHECK( ! mock::equal( std::string( "string" ) ).c_( "not string" ) ); { std::string s; mock::constraint< @@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE( equal ) > > c = mock::equal( boost::cref( s ) ); s = "string"; - BOOST_CHECK( c.f_( "string" ) ); + BOOST_CHECK( c.c_( "string" ) ); } } @@ -63,8 +63,8 @@ BOOST_AUTO_TEST_CASE( same ) int i = 0; int j = 0; BOOST_CHECK_EQUAL( i, j ); - BOOST_CHECK( ! mock::same( i ).f_( j ) ); - BOOST_CHECK( mock::same( i ).f_( i ) ); + BOOST_CHECK( ! mock::same( i ).c_( j ) ); + BOOST_CHECK( mock::same( i ).c_( i ) ); } { int i = 0; @@ -75,8 +75,8 @@ BOOST_AUTO_TEST_CASE( same ) const boost::reference_wrapper< const int > > > c = mock::same( boost::cref( i ) ); - BOOST_CHECK( ! c.f_( j ) ); - BOOST_CHECK( c.f_( i ) ); + BOOST_CHECK( ! c.c_( j ) ); + BOOST_CHECK( c.c_( i ) ); } } @@ -84,18 +84,18 @@ BOOST_AUTO_TEST_CASE( assign ) { { int i = 0; - BOOST_CHECK( mock::assign( 3 ).f_( i ) ); + BOOST_CHECK( mock::assign( 3 ).c_( i ) ); BOOST_CHECK_EQUAL( 3, i ); } { int i = 0; - BOOST_CHECK( mock::assign( 3 ).f_( &i ) ); + BOOST_CHECK( mock::assign( 3 ).c_( &i ) ); BOOST_CHECK_EQUAL( 3, i ); } { const int* i = 0; const int j = 1; - BOOST_CHECK( mock::assign( &j ).f_( i ) ); + BOOST_CHECK( mock::assign( &j ).c_( i ) ); BOOST_CHECK_EQUAL( &j, i ); } { @@ -106,10 +106,10 @@ BOOST_AUTO_TEST_CASE( assign ) boost::reference_wrapper< const int > > > c = mock::assign( boost::cref( j ) ); - BOOST_CHECK( c.f_( i ) ); + BOOST_CHECK( c.c_( i ) ); BOOST_CHECK_EQUAL( 1, i ); j = 3; - BOOST_CHECK( c.f_( i ) ); + BOOST_CHECK( c.c_( i ) ); BOOST_CHECK_EQUAL( 3, i ); } { @@ -120,10 +120,10 @@ BOOST_AUTO_TEST_CASE( assign ) boost::reference_wrapper< const int > > > c = mock::assign( boost::cref( j ) ); - BOOST_CHECK( c.f_( &i ) ); + BOOST_CHECK( c.c_( &i ) ); BOOST_CHECK_EQUAL( 1, i ); j = 3; - BOOST_CHECK( c.f_( &i ) ); + BOOST_CHECK( c.c_( &i ) ); BOOST_CHECK_EQUAL( 3, i ); } { @@ -135,10 +135,10 @@ BOOST_AUTO_TEST_CASE( assign ) boost::reference_wrapper< int* const > > > c = mock::assign( boost::cref( j ) ); - BOOST_CHECK( c.f_( i ) ); + BOOST_CHECK( c.c_( i ) ); BOOST_CHECK_EQUAL( j, i ); j = 0; - BOOST_CHECK( c.f_( i ) ); + BOOST_CHECK( c.c_( i ) ); BOOST_CHECK_EQUAL( j, i ); } } @@ -148,61 +148,61 @@ BOOST_AUTO_TEST_CASE( retrieve ) { int i = 0; const int j = 1; - BOOST_CHECK( mock::retrieve( i ).f_( j ) ); + BOOST_CHECK( mock::retrieve( i ).c_( j ) ); BOOST_CHECK_EQUAL( i, j ); } { int* i = 0; int j = 1; - BOOST_CHECK( mock::retrieve( i ).f_( &j ) ); + BOOST_CHECK( mock::retrieve( i ).c_( &j ) ); BOOST_CHECK_EQUAL( i, &j ); } { const int* i = 0; const int j = 1; - BOOST_CHECK( mock::retrieve( i ).f_( j ) ); + BOOST_CHECK( mock::retrieve( i ).c_( j ) ); BOOST_CHECK_EQUAL( i, &j ); } { const int* i = 0; int j = 1; - BOOST_CHECK( mock::retrieve( i ).f_( j ) ); + BOOST_CHECK( mock::retrieve( i ).c_( j ) ); BOOST_CHECK_EQUAL( i, &j ); } { int* i = 0; int j = 1; - BOOST_CHECK( mock::retrieve( i ).f_( j ) ); + BOOST_CHECK( mock::retrieve( i ).c_( j ) ); BOOST_CHECK_EQUAL( i, &j ); } { const int* i = 0; const int j = 1; - BOOST_CHECK( mock::retrieve( i ).f_( j ) ); + BOOST_CHECK( mock::retrieve( i ).c_( j ) ); BOOST_CHECK_EQUAL( i, &j ); } { int** i = 0; int* j = 0; - BOOST_CHECK( mock::retrieve( i ).f_( j ) ); + BOOST_CHECK( mock::retrieve( i ).c_( j ) ); BOOST_CHECK_EQUAL( i, &j ); } { const int** i = 0; const int* j = 0; - BOOST_CHECK( mock::retrieve( i ).f_( j ) ); + BOOST_CHECK( mock::retrieve( i ).c_( j ) ); BOOST_CHECK_EQUAL( i, &j ); } { int i = 0; const int j = 1; - BOOST_CHECK( mock::retrieve( boost::ref( i ) ).f_( j ) ); + BOOST_CHECK( mock::retrieve( boost::ref( i ) ).c_( j ) ); BOOST_CHECK_EQUAL( i, j ); } { const int* i = 0; const int j = 1; - BOOST_CHECK( mock::retrieve( boost::ref( i ) ).f_( j ) ); + BOOST_CHECK( mock::retrieve( boost::ref( i ) ).c_( j ) ); BOOST_CHECK_EQUAL( i, &j ); } } @@ -225,23 +225,23 @@ BOOST_AUTO_TEST_CASE( retrieve_uses_assignment_operator ) { B b; const A a = A(); - mock::retrieve( b ).f_( a ); + mock::retrieve( b ).c_( a ); } BOOST_AUTO_TEST_CASE( affirm ) { int* i = 0; int j; - BOOST_CHECK( ! mock::affirm.f_( i ) ); - BOOST_CHECK( mock::affirm.f_( &j ) ); + BOOST_CHECK( ! mock::affirm.c_( i ) ); + BOOST_CHECK( mock::affirm.c_( &j ) ); } BOOST_AUTO_TEST_CASE( negate ) { int* i = 0; int j; - BOOST_CHECK( mock::negate.f_( i ) ); - BOOST_CHECK( ! mock::negate.f_( &j ) ); + BOOST_CHECK( mock::negate.c_( i ) ); + BOOST_CHECK( ! mock::negate.c_( &j ) ); } namespace @@ -258,22 +258,22 @@ namespace BOOST_AUTO_TEST_CASE( call ) { - BOOST_CHECK( mock::call( &return_true ).f_() ); - BOOST_CHECK( ! mock::call( &return_false ).f_() ); + BOOST_CHECK( mock::call( &return_true ).c_() ); + BOOST_CHECK( ! mock::call( &return_false ).c_() ); } BOOST_AUTO_TEST_CASE( evaluate ) { - BOOST_CHECK( mock::evaluate.f_( &return_true ) ); - BOOST_CHECK( ! mock::evaluate.f_( &return_false ) ); + BOOST_CHECK( mock::evaluate.c_( &return_true ) ); + BOOST_CHECK( ! mock::evaluate.c_( &return_false ) ); } BOOST_AUTO_TEST_CASE( contain_with_const_char_ptr ) { - BOOST_CHECK( mock::contain( "string" ).f_( "this is a string" ) ); - BOOST_CHECK( mock::contain( "string" ).f_( std::string( "this is a string" ) ) ); - BOOST_CHECK( ! mock::contain( "not found" ).f_( "this is a string" ) ); - BOOST_CHECK( ! mock::contain( "not found" ).f_( std::string( "this is a string" ) ) ); + BOOST_CHECK( mock::contain( "string" ).c_( "this is a string" ) ); + BOOST_CHECK( mock::contain( "string" ).c_( std::string( "this is a string" ) ) ); + BOOST_CHECK( ! mock::contain( "not found" ).c_( "this is a string" ) ); + BOOST_CHECK( ! mock::contain( "not found" ).c_( std::string( "this is a string" ) ) ); { const char* s = 0; mock::constraint< @@ -282,20 +282,20 @@ BOOST_AUTO_TEST_CASE( contain_with_const_char_ptr ) > > c = mock::contain( boost::cref( s ) ); s = "string"; - BOOST_CHECK( c.f_( "this is a string" ) ); - BOOST_CHECK( c.f_( std::string( "this is a string" ) ) ); + BOOST_CHECK( c.c_( "this is a string" ) ); + BOOST_CHECK( c.c_( std::string( "this is a string" ) ) ); s = "not found"; - BOOST_CHECK( ! c.f_( "this is a string" ) ); - BOOST_CHECK( ! c.f_( std::string( "this is a string" ) ) ); + BOOST_CHECK( ! c.c_( "this is a string" ) ); + BOOST_CHECK( ! c.c_( std::string( "this is a string" ) ) ); } } BOOST_AUTO_TEST_CASE( contain_with_strings ) { - BOOST_CHECK( mock::contain( std::string( "string" ) ).f_( "this is a string" ) ); - BOOST_CHECK( mock::contain( std::string( "string" ) ).f_( std::string( "this is a string" ) ) ); - BOOST_CHECK( ! mock::contain( std::string( "not found" ) ).f_( "this is a string" ) ); - BOOST_CHECK( ! mock::contain( std::string( "not found" ) ).f_( std::string( "this is a string" ) ) ); + BOOST_CHECK( mock::contain( std::string( "string" ) ).c_( "this is a string" ) ); + BOOST_CHECK( mock::contain( std::string( "string" ) ).c_( std::string( "this is a string" ) ) ); + BOOST_CHECK( ! mock::contain( std::string( "not found" ) ).c_( "this is a string" ) ); + BOOST_CHECK( ! mock::contain( std::string( "not found" ) ).c_( std::string( "this is a string" ) ) ); { std::string s; mock::constraint< @@ -304,11 +304,11 @@ BOOST_AUTO_TEST_CASE( contain_with_strings ) > > c = mock::contain( boost::cref( s ) ); s = "string"; - BOOST_CHECK( c.f_( "this is a string" ) ); - BOOST_CHECK( c.f_( std::string( "this is a string" ) ) ); + BOOST_CHECK( c.c_( "this is a string" ) ); + BOOST_CHECK( c.c_( std::string( "this is a string" ) ) ); s = "not found"; - BOOST_CHECK( ! c.f_( "this is a string" ) ); - BOOST_CHECK( ! c.f_( std::string( "this is a string" ) ) ); + BOOST_CHECK( ! c.c_( "this is a string" ) ); + BOOST_CHECK( ! c.c_( std::string( "this is a string" ) ) ); } } @@ -324,8 +324,8 @@ namespace BOOST_AUTO_TEST_CASE( type_with_overloaded_address_operator_can_be_used_in_constraints ) { type_with_overloaded_address_operator t; - mock::same( t ).f_( t ); - mock::retrieve( t ).f_( t ); + mock::same( t ).c_( t ); + mock::retrieve( t ).c_( t ); type_with_overloaded_address_operator* pt; - mock::retrieve( pt ).f_( t ); + mock::retrieve( pt ).c_( t ); } diff --git a/turtle/constraint.hpp b/turtle/constraint.hpp index 01648db..5dc6da2 100644 --- a/turtle/constraint.hpp +++ b/turtle/constraint.hpp @@ -18,9 +18,9 @@ namespace mock struct constraint { constraint( const Constraint& c ) - : f_( c ) + : c_( c ) {} - Constraint f_; + Constraint c_; }; namespace detail @@ -75,20 +75,20 @@ namespace detail class not_ { public: - explicit not_( const Constraint& f ) - : f_( f ) + explicit not_( const Constraint& c ) + : c_( c ) {} template< typename Actual > bool operator()( const Actual& actual ) const { - return ! f_( actual ); + return ! c_( actual ); } friend std::ostream& operator<<( std::ostream& s, const not_& n ) { - return s << "! " << mock::format( n.f_ ); + return s << "! " << mock::format( n.c_ ); } private: - Constraint f_; + Constraint c_; }; } @@ -97,7 +97,7 @@ namespace detail operator||( const constraint< Constraint1 >& lhs, const constraint< Constraint2 >& rhs ) { - return detail::or_< Constraint1, Constraint2 >( lhs.f_, rhs.f_ ); + return detail::or_< Constraint1, Constraint2 >( lhs.c_, rhs.c_ ); } template< typename Constraint1, typename Constraint2 > @@ -105,14 +105,14 @@ namespace detail operator&&( const constraint< Constraint1 >& lhs, const constraint< Constraint2 >& rhs ) { - return detail::and_< Constraint1, Constraint2 >( lhs.f_, rhs.f_ ); + return detail::and_< Constraint1, Constraint2 >( lhs.c_, rhs.c_ ); } template< typename Constraint > const constraint< detail::not_< Constraint > > operator!( const constraint< Constraint >& c ) { - return detail::not_< Constraint >( c.f_ ); + return detail::not_< Constraint >( c.c_ ); } } // mock @@ -137,7 +137,7 @@ namespace detail { \ constraint() \ {} \ - detail::N f_; \ + detail::N c_; \ }; \ const constraint< detail::N > N; diff --git a/turtle/detail/action.hpp b/turtle/detail/action.hpp index abd3780..38a1982 100644 --- a/turtle/detail/action.hpp +++ b/turtle/detail/action.hpp @@ -50,7 +50,7 @@ namespace detail void calls( const functor_type& f ) { - if( !f ) + if( ! f ) throw std::invalid_argument( "null functor" ); f_ = f; } @@ -92,7 +92,7 @@ namespace detail void calls( const functor_type& f ) { - if( !f ) + if( ! f ) throw std::invalid_argument( "null functor" ); f_ = f; } @@ -127,7 +127,7 @@ namespace detail void calls( const functor_type& f ) { - if( !f ) + if( ! f ) throw std::invalid_argument( "null functor" ); f_ = f; } @@ -173,7 +173,7 @@ namespace detail void calls( const functor_type& f ) { - if( !f ) + if( ! f ) throw std::invalid_argument( "null functor" ); f_ = f; } diff --git a/turtle/detail/expectation_template.hpp b/turtle/detail/expectation_template.hpp index 880b19c..a1ca5e6 100644 --- a/turtle/detail/expectation_template.hpp +++ b/turtle/detail/expectation_template.hpp @@ -128,4 +128,3 @@ namespace detail #undef MOCK_EXPECTATION_ARGS #undef MOCK_EXPECTATION_IS_VALID #undef MOCK_EXPECTATION_SERIALIZE -#undef MOCK_EXPECTATION diff --git a/turtle/detail/function_impl_template.hpp b/turtle/detail/function_impl_template.hpp index 41f4d4f..f53ded0 100644 --- a/turtle/detail/function_impl_template.hpp +++ b/turtle/detail/function_impl_template.hpp @@ -70,7 +70,7 @@ namespace detail { for( expectations_cit it = expectations_.begin(); it != expectations_.end(); ++it ) - if( !it->verify() ) + if( ! it->verify() ) { valid_ = false; error_type::fail( "verification failed", @@ -133,9 +133,9 @@ namespace detail } friend std::ostream& operator<<( - std::ostream& s, const function_impl& e ) + std::ostream& s, const function_impl& impl ) { - return s << lazy_context( &e ) << lazy_expectations( &e ); + return s << lazy_context( &impl ) << lazy_expectations( &impl ); } struct lazy_context diff --git a/turtle/detail/invocation.hpp b/turtle/detail/invocation.hpp index e9ec6b3..77a7b10 100644 --- a/turtle/detail/invocation.hpp +++ b/turtle/detail/invocation.hpp @@ -30,8 +30,7 @@ namespace detail virtual bool invoked() const = 0; virtual bool exhausted() const = 0; - friend inline std::ostream& operator<<( - std::ostream& s, const invocation& i ) + friend std::ostream& operator<<( std::ostream& s, const invocation& i ) { return i.serialize( s ); } diff --git a/turtle/error.hpp b/turtle/error.hpp index eaa8207..e7e6fa6 100644 --- a/turtle/error.hpp +++ b/turtle/error.hpp @@ -52,8 +52,7 @@ namespace mock } template< typename Context > - static void call( const Context& context, - const char* file, int line ) + static void call( const Context& context, const char* file, int line ) { boost::unit_test::framework::assertion_result( true ); boost::unit_test::unit_test_log diff --git a/turtle/matcher.hpp b/turtle/matcher.hpp index 53a4802..34bd83b 100644 --- a/turtle/matcher.hpp +++ b/turtle/matcher.hpp @@ -66,7 +66,7 @@ namespace mock { public: explicit matcher( const constraint< Constraint >& c ) - : c_( c.f_ ) + : c_( c.c_ ) {} virtual bool operator()( Actual actual ) { @@ -90,19 +90,19 @@ namespace mock { public: explicit matcher( const Functor& f ) - : f_( f ) + : c_( f ) {} virtual bool operator()( Actual actual ) { - return f_( actual ); + return c_( actual ); } private: virtual void serialize( std::ostream& s ) const { - s << mock::format( f_ ); + s << mock::format( c_ ); } private: - Functor f_; + Functor c_; }; } // mock