diff --git a/src/libraries/turtle/constraint.hpp b/src/libraries/turtle/constraint.hpp index 3912548..577f104 100644 --- a/src/libraries/turtle/constraint.hpp +++ b/src/libraries/turtle/constraint.hpp @@ -19,8 +19,6 @@ namespace mock {} Constraint f_; }; - template< typename T, typename Constraint > - bool operator==( const T&, const constraint< Constraint >& ); } #endif // #ifndef MOCK_CONSTRAINT_HPP_INCLUDED diff --git a/src/libraries/turtle/expectation.hpp b/src/libraries/turtle/expectation.hpp index 96afbae..63c0bc2 100644 --- a/src/libraries/turtle/expectation.hpp +++ b/src/libraries/turtle/expectation.hpp @@ -36,13 +36,6 @@ namespace detail , file_( "unknown location" ) , line_( 0 ) {} - virtual ~expectation_base() - { - for( sequences_cit it = sequences_.begin(); - it != sequences_.end(); ++it ) - (*it)->remove( this ); - } - void set_location( const std::string& file, int line ) { file_ = file; @@ -82,7 +75,12 @@ namespace detail } protected: - boost::shared_ptr< detail::invocation > i_; + ~expectation_base() + { + for( sequences_cit it = sequences_.begin(); + it != sequences_.end(); ++it ) + (*it)->remove( this ); + } void expect( detail::invocation* i ) { @@ -95,6 +93,8 @@ namespace detail sequences_.push_back( s ); } + boost::shared_ptr< detail::invocation > i_; + private: typedef std::vector< boost::shared_ptr< detail::sequence_impl > > sequences_type; typedef sequences_type::const_iterator sequences_cit; @@ -155,14 +155,14 @@ namespace detail public: bool is_valid() const { - return i_->is_valid(); + return ! i_->exhausted(); } MOCK_EXPECTATION_METHODS friend std::ostream& operator<<( std::ostream& s, const expectation& m ) { - return s << (m.i_->is_valid() ? '.' : 'v') << ' ' << *m.i_; + return s << (m.i_->exhausted() ? 'v' : '.') << ' ' << *m.i_; } }; @@ -199,13 +199,13 @@ namespace detail } \ bool is_valid( BOOST_PP_REPEAT_FROM_TO(0, n, MOCK_EXPECTATION_ARGS, BOOST_PP_EMPTY) ) const \ { \ - return i_->is_valid() \ + return ! i_->exhausted() \ BOOST_PP_REPEAT_FROM_TO(0, n, MOCK_EXPECTATION_IS_VALID, BOOST_PP_EMPTY); \ } \ MOCK_EXPECTATION_METHODS \ friend std::ostream& operator<<( std::ostream& s, const expectation& m ) \ { \ - return s << (m.i_->is_valid() ? '.' : 'v') << ' ' << *m.i_ << ".with( " \ + return s << (m.i_->exhausted() ? 'v' : '.') << ' ' << *m.i_ << ".with( " \ << \ BOOST_PP_REPEAT_FROM_TO(0, n, MOCK_EXPECTATION_SERIALIZE, BOOST_PP_EMPTY) \ << " )"; \ diff --git a/src/libraries/turtle/invocation.hpp b/src/libraries/turtle/invocation.hpp index f075320..24afefa 100644 --- a/src/libraries/turtle/invocation.hpp +++ b/src/libraries/turtle/invocation.hpp @@ -22,25 +22,14 @@ namespace detail { public: invocation() {} - virtual ~invocation() {} - // Trigger invocation - // returns false if the invocation has failed virtual bool invoke() = 0; - - // Test whether the invocation has been invoked or not - // returns true if the invocation has been invoked - virtual bool invoked() const = 0; - - // Test whether the invocation is exhausted or not - // returns false if the invocation is exhausted - virtual bool is_valid() const = 0; - - // Verify invocation - // returns false if the verification fails virtual bool verify() const = 0; + virtual bool invoked() const = 0; + virtual bool exhausted() const = 0; + friend inline std::ostream& operator<<( std::ostream& s, const invocation& i ) { return i.serialize( s ); @@ -75,9 +64,9 @@ namespace detail return count_ > 0; } - virtual bool is_valid() const + virtual bool exhausted() const { - return count_ < max_; + return count_ >= max_; } virtual bool verify() const diff --git a/src/tests/turtle_test/invocation_test.cpp b/src/tests/turtle_test/invocation_test.cpp index a85613e..aa1edda 100644 --- a/src/tests/turtle_test/invocation_test.cpp +++ b/src/tests/turtle_test/invocation_test.cpp @@ -16,10 +16,10 @@ BOOST_AUTO_TEST_CASE( unlimited ) { mock::detail::unlimited invocation; BOOST_CHECK( invocation.verify() ); - BOOST_CHECK( invocation.is_valid() ); + BOOST_CHECK( ! invocation.exhausted() ); BOOST_CHECK( invocation.invoke() ); BOOST_CHECK( invocation.verify() ); - BOOST_CHECK( invocation.is_valid() ); + BOOST_CHECK( ! invocation.exhausted() ); BOOST_CHECK( invocation.invoke() ); } @@ -27,10 +27,10 @@ BOOST_AUTO_TEST_CASE( once ) { mock::detail::once invocation; BOOST_CHECK( ! invocation.verify() ); - BOOST_CHECK( invocation.is_valid() ); + BOOST_CHECK( ! invocation.exhausted() ); BOOST_CHECK( invocation.invoke() ); BOOST_CHECK( invocation.verify() ); - BOOST_CHECK( ! invocation.is_valid() ); + BOOST_CHECK( invocation.exhausted() ); BOOST_CHECK( ! invocation.invoke() ); } @@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE( never ) { mock::detail::never invocation; BOOST_CHECK( invocation.verify() ); - BOOST_CHECK( ! invocation.is_valid() ); + BOOST_CHECK( invocation.exhausted() ); BOOST_CHECK( ! invocation.invoke() ); } @@ -46,10 +46,10 @@ BOOST_AUTO_TEST_CASE( at_most ) { mock::detail::at_most invocation( 1 ); BOOST_CHECK( invocation.verify() ); - BOOST_CHECK( invocation.is_valid() ); + BOOST_CHECK( ! invocation.exhausted() ); BOOST_CHECK( invocation.invoke() ); BOOST_CHECK( invocation.verify() ); - BOOST_CHECK( ! invocation.is_valid() ); + BOOST_CHECK( invocation.exhausted() ); BOOST_CHECK( ! invocation.invoke() ); } @@ -57,10 +57,10 @@ BOOST_AUTO_TEST_CASE( at_least ) { mock::detail::at_least invocation( 1 ); BOOST_CHECK( ! invocation.verify() ); - BOOST_CHECK( invocation.is_valid() ); + BOOST_CHECK( ! invocation.exhausted() ); BOOST_CHECK( invocation.invoke() ); BOOST_CHECK( invocation.verify() ); - BOOST_CHECK( invocation.is_valid() ); + BOOST_CHECK( ! invocation.exhausted() ); BOOST_CHECK( invocation.invoke() ); } @@ -68,12 +68,12 @@ BOOST_AUTO_TEST_CASE( between ) { mock::detail::between invocation( 1, 2 ); BOOST_CHECK( ! invocation.verify() ); - BOOST_CHECK( invocation.is_valid() ); + BOOST_CHECK( ! invocation.exhausted() ); BOOST_CHECK( invocation.invoke() ); BOOST_CHECK( invocation.verify() ); - BOOST_CHECK( invocation.is_valid() ); + BOOST_CHECK( ! invocation.exhausted() ); BOOST_CHECK( invocation.invoke() ); BOOST_CHECK( invocation.verify() ); - BOOST_CHECK( ! invocation.is_valid() ); + BOOST_CHECK( invocation.exhausted() ); BOOST_CHECK( ! invocation.invoke() ); }