mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Cleanup
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@300 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
817334e069
commit
c7169dd8c4
4 changed files with 29 additions and 42 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) \
|
||||
<< " )"; \
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue