mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Fixed a bug in sequence specification
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@25 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
1d13a3fcde
commit
64ef3b48dc
2 changed files with 31 additions and 11 deletions
|
|
@ -66,13 +66,6 @@ namespace detail
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
matcher_base& in( sequence& s )
|
|
||||||
{
|
|
||||||
s.add( *this );
|
|
||||||
sequences_.push_back( &s );
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& file() const
|
const std::string& file() const
|
||||||
{
|
{
|
||||||
return file_;
|
return file_;
|
||||||
|
|
@ -90,6 +83,12 @@ namespace detail
|
||||||
i_.reset( i );
|
i_.reset( i );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add( sequence& s )
|
||||||
|
{
|
||||||
|
s.add( *this );
|
||||||
|
sequences_.push_back( &s );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void remove( sequence& s )
|
virtual void remove( sequence& s )
|
||||||
{
|
{
|
||||||
|
|
@ -110,7 +109,12 @@ namespace detail
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MOCK_INVOCATIONS \
|
#define MOCK_MATCHER_METHODS \
|
||||||
|
matcher& in( sequence& s ) \
|
||||||
|
{ \
|
||||||
|
add( s ); \
|
||||||
|
return *this; \
|
||||||
|
} \
|
||||||
matcher& once() \
|
matcher& once() \
|
||||||
{ \
|
{ \
|
||||||
expect( new detail::once() ); \
|
expect( new detail::once() ); \
|
||||||
|
|
@ -152,7 +156,7 @@ namespace detail
|
||||||
return i_->is_valid();
|
return i_->is_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
MOCK_INVOCATIONS
|
MOCK_MATCHER_METHODS
|
||||||
|
|
||||||
friend std::ostream& operator<<( std::ostream& s, const matcher& m )
|
friend std::ostream& operator<<( std::ostream& s, const matcher& m )
|
||||||
{
|
{
|
||||||
|
|
@ -192,7 +196,7 @@ namespace detail
|
||||||
return i_->is_valid() \
|
return i_->is_valid() \
|
||||||
BOOST_PP_REPEAT_FROM_TO(0, n, MOCK_MATCHER_IS_VALID, BOOST_PP_EMPTY); \
|
BOOST_PP_REPEAT_FROM_TO(0, n, MOCK_MATCHER_IS_VALID, BOOST_PP_EMPTY); \
|
||||||
} \
|
} \
|
||||||
MOCK_INVOCATIONS \
|
MOCK_MATCHER_METHODS \
|
||||||
friend std::ostream& operator<<( std::ostream& s, const matcher& m ) \
|
friend std::ostream& operator<<( std::ostream& s, const matcher& m ) \
|
||||||
{ \
|
{ \
|
||||||
return s << (m.i_->is_valid() ? '.' : 'v') \
|
return s << (m.i_->is_valid() ? '.' : 'v') \
|
||||||
|
|
@ -206,7 +210,7 @@ namespace detail
|
||||||
};
|
};
|
||||||
BOOST_PP_REPEAT_FROM_TO(1, MOCK_MAX_ARGS, MOCK_MATCHER, BOOST_PP_EMPTY)
|
BOOST_PP_REPEAT_FROM_TO(1, MOCK_MAX_ARGS, MOCK_MATCHER, BOOST_PP_EMPTY)
|
||||||
|
|
||||||
#undef MOCK_INVOCATIONS
|
#undef MOCK_MATCHER_METHODS
|
||||||
#undef MOCK_MATCHER_TYPEDEF
|
#undef MOCK_MATCHER_TYPEDEF
|
||||||
#undef MOCK_MATCHER_CONSTRUCTOR
|
#undef MOCK_MATCHER_CONSTRUCTOR
|
||||||
#undef MOCK_MATCHER_WITH
|
#undef MOCK_MATCHER_WITH
|
||||||
|
|
|
||||||
|
|
@ -76,3 +76,19 @@ BOOST_AUTO_TEST_CASE( resetting_an_expectation_removes_it_from_order_call_enforc
|
||||||
e1.reset();
|
e1.reset();
|
||||||
BOOST_CHECK_NO_THROW( e2() );
|
BOOST_CHECK_NO_THROW( e2() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( an_expectation_can_be_used_in_several_sequences )
|
||||||
|
{
|
||||||
|
mock::sequence s1, s2;
|
||||||
|
mock::expectation< void() > e;
|
||||||
|
e.expect().once().in( s1 ).in( s2 );
|
||||||
|
BOOST_CHECK_NO_THROW( e() );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( a_result_specification_is_set_after_a_sequence )
|
||||||
|
{
|
||||||
|
mock::sequence s;
|
||||||
|
mock::expectation< int() > e;
|
||||||
|
e.expect().once().in( s ).returns( 3 );
|
||||||
|
BOOST_CHECK_EQUAL( 3, e() );
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue