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@498 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
f1cc1321e8
commit
8cdf6f5934
8 changed files with 28 additions and 42 deletions
|
|
@ -81,7 +81,7 @@ namespace detail
|
||||||
template< typename Actual, typename Functor >
|
template< typename Actual, typename Functor >
|
||||||
class check< Actual, Functor,
|
class check< Actual, Functor,
|
||||||
BOOST_DEDUCED_TYPENAME boost::enable_if<
|
BOOST_DEDUCED_TYPENAME boost::enable_if<
|
||||||
detail::is_functor< Functor >
|
is_functor< Functor >
|
||||||
>::type
|
>::type
|
||||||
> : public check_base< Actual >
|
> : public check_base< Actual >
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace detail
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
expectation_base()
|
expectation_base()
|
||||||
: i_( new detail::unlimited() )
|
: i_( new unlimited() )
|
||||||
, file_( "unknown location" )
|
, file_( "unknown location" )
|
||||||
, line_( 0 )
|
, line_( 0 )
|
||||||
{}
|
{}
|
||||||
|
|
@ -72,22 +72,22 @@ namespace detail
|
||||||
(*it)->remove( this );
|
(*it)->remove( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void expect( detail::invocation* i )
|
void expect( invocation* i )
|
||||||
{
|
{
|
||||||
i_.reset( i );
|
i_.reset( i );
|
||||||
}
|
}
|
||||||
|
|
||||||
void add( boost::shared_ptr< detail::sequence_impl > s )
|
void add( boost::shared_ptr< sequence_impl > s )
|
||||||
{
|
{
|
||||||
s->add( this );
|
s->add( this );
|
||||||
sequences_.push_back( s );
|
sequences_.push_back( s );
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr< detail::invocation > i_;
|
boost::shared_ptr< invocation > i_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::vector<
|
typedef std::vector<
|
||||||
boost::shared_ptr< detail::sequence_impl >
|
boost::shared_ptr< sequence_impl >
|
||||||
> sequences_type;
|
> sequences_type;
|
||||||
typedef sequences_type::const_iterator sequences_cit;
|
typedef sequences_type::const_iterator sequences_cit;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,20 +11,13 @@
|
||||||
|
|
||||||
#define MOCK_EXPECTATION_INITIALIZE(z, n, d) \
|
#define MOCK_EXPECTATION_INITIALIZE(z, n, d) \
|
||||||
BOOST_PP_COMMA_IF(n) c##n##_( \
|
BOOST_PP_COMMA_IF(n) c##n##_( \
|
||||||
new detail::check< \
|
new check< arg##n##_type, constraint< any > >( mock::any ) )
|
||||||
arg##n##_type, \
|
|
||||||
constraint< detail::any > \
|
|
||||||
>( mock::any ) )
|
|
||||||
|
|
||||||
#define MOCK_EXPECTATION_WITH(z, n, d) \
|
#define MOCK_EXPECTATION_WITH(z, n, d) \
|
||||||
c##n##_.reset( \
|
c##n##_.reset( new check< arg##n##_type, Constraint_##n >( c##n ) );
|
||||||
new detail::check< \
|
|
||||||
arg##n##_type, \
|
|
||||||
Constraint_##n \
|
|
||||||
>( c##n ) );
|
|
||||||
|
|
||||||
#define MOCK_EXPECTATION_MEMBER(z, n, d) \
|
#define MOCK_EXPECTATION_MEMBER(z, n, d) \
|
||||||
boost::shared_ptr< detail::check_base< arg##n##_type > > c##n##_;
|
boost::shared_ptr< check_base< arg##n##_type > > c##n##_;
|
||||||
|
|
||||||
#define MOCK_EXPECTATION_ARGS(z, n, d) \
|
#define MOCK_EXPECTATION_ARGS(z, n, d) \
|
||||||
BOOST_PP_COMMA_IF(n) arg##n##_type a##n
|
BOOST_PP_COMMA_IF(n) arg##n##_type a##n
|
||||||
|
|
|
||||||
|
|
@ -29,15 +29,13 @@ namespace detail
|
||||||
template< typename R BOOST_PP_COMMA_IF(MOCK_NUM_ARGS)
|
template< typename R BOOST_PP_COMMA_IF(MOCK_NUM_ARGS)
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T) >
|
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T) >
|
||||||
class function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
|
class function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
|
||||||
: public detail::verifiable,
|
: public verifiable, public boost::enable_shared_from_this<
|
||||||
public boost::enable_shared_from_this<
|
|
||||||
function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )> >
|
function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef MOCK_ERROR_POLICY< R > error_type;
|
typedef MOCK_ERROR_POLICY< R > error_type;
|
||||||
|
|
||||||
typedef detail::expectation<
|
typedef expectation< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
||||||
R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
|
||||||
> expectation_type;
|
> expectation_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -174,7 +172,7 @@ namespace detail
|
||||||
expectations_type::const_iterator expectations_cit;
|
expectations_type::const_iterator expectations_cit;
|
||||||
|
|
||||||
expectations_type expectations_;
|
expectations_type expectations_;
|
||||||
detail::context* context_;
|
context* context_;
|
||||||
mutable bool valid_;
|
mutable bool valid_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,20 +78,20 @@ namespace detail
|
||||||
return s << *e.impl_;
|
return s << *e.impl_;
|
||||||
}
|
}
|
||||||
|
|
||||||
function& operator()( detail::context& c,
|
function& operator()( context& c,
|
||||||
boost::unit_test::const_string instance )
|
boost::unit_test::const_string instance )
|
||||||
{
|
{
|
||||||
if( ! impl_->context_ )
|
if( ! impl_->context_ )
|
||||||
c.add( *impl_ );
|
c.add( *impl_ );
|
||||||
c.add( impl_.get(), *impl_, instance,
|
c.add( impl_.get(), *impl_, instance,
|
||||||
boost::optional< detail::type_name >(), "" );
|
boost::optional< type_name >(), "" );
|
||||||
impl_->context_ = &c;
|
impl_->context_ = &c;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void configure( detail::context& c, const void* p,
|
void configure( context& c, const void* p,
|
||||||
boost::unit_test::const_string instance,
|
boost::unit_test::const_string instance,
|
||||||
boost::optional< detail::type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name ) const
|
boost::unit_test::const_string name ) const
|
||||||
{
|
{
|
||||||
if( ! impl_->context_ )
|
if( ! impl_->context_ )
|
||||||
|
|
|
||||||
|
|
@ -23,24 +23,24 @@ namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class object_impl : public detail::context, public detail::verifiable,
|
class object_impl : public context, public verifiable,
|
||||||
public boost::enable_shared_from_this< object_impl >
|
public boost::enable_shared_from_this< object_impl >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void add( const void* /*p*/, detail::verifiable& v,
|
virtual void add( const void* /*p*/, verifiable& v,
|
||||||
boost::unit_test::const_string instance,
|
boost::unit_test::const_string instance,
|
||||||
boost::optional< detail::type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name )
|
boost::unit_test::const_string name )
|
||||||
{
|
{
|
||||||
if( children_.empty() )
|
if( children_.empty() )
|
||||||
mock::detail::root.add( *this );
|
mock::detail::root.add( *this );
|
||||||
children_[ &v ].update( parent_, instance, type, name );
|
children_[ &v ].update( parent_, instance, type, name );
|
||||||
}
|
}
|
||||||
virtual void add( detail::verifiable& v )
|
virtual void add( verifiable& v )
|
||||||
{
|
{
|
||||||
group_.add( v );
|
group_.add( v );
|
||||||
}
|
}
|
||||||
virtual void remove( detail::verifiable& v )
|
virtual void remove( verifiable& v )
|
||||||
{
|
{
|
||||||
group_.remove( v );
|
group_.remove( v );
|
||||||
children_.erase( &v );
|
children_.erase( &v );
|
||||||
|
|
@ -48,8 +48,7 @@ namespace detail
|
||||||
mock::detail::root.remove( *this );
|
mock::detail::root.remove( *this );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void serialize( std::ostream& s,
|
virtual void serialize( std::ostream& s, const verifiable& v ) const
|
||||||
const detail::verifiable& v ) const
|
|
||||||
{
|
{
|
||||||
children_cit it = children_.find( &v );
|
children_cit it = children_.find( &v );
|
||||||
if( it != children_.end() )
|
if( it != children_.end() )
|
||||||
|
|
@ -69,14 +68,11 @@ namespace detail
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<
|
typedef std::map< const verifiable*, child > children_t;
|
||||||
const detail::verifiable*,
|
|
||||||
detail::child
|
|
||||||
> children_t;
|
|
||||||
typedef children_t::const_iterator children_cit;
|
typedef children_t::const_iterator children_cit;
|
||||||
|
|
||||||
detail::group group_;
|
group group_;
|
||||||
detail::parent parent_;
|
parent parent_;
|
||||||
children_t children_;
|
children_t children_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,7 @@ namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class root_t : public boost::unit_test::singleton< root_t >,
|
class root_t : public boost::unit_test::singleton< root_t >, public context
|
||||||
public detail::context
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void add( const void* p, verifiable& v,
|
virtual void add( const void* p, verifiable& v,
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace detail
|
||||||
template< typename E >
|
template< typename E >
|
||||||
E& configure( const object& o, E& e,
|
E& configure( const object& o, E& e,
|
||||||
boost::unit_test::const_string instance,
|
boost::unit_test::const_string instance,
|
||||||
boost::optional< detail::type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name )
|
boost::unit_test::const_string name )
|
||||||
{
|
{
|
||||||
e.configure( *o.impl_, o.impl_.get(), instance, type, name );
|
e.configure( *o.impl_, o.impl_.get(), instance, type, name );
|
||||||
|
|
@ -48,7 +48,7 @@ namespace detail
|
||||||
template< typename T, typename E >
|
template< typename T, typename E >
|
||||||
E& configure( const T& t, E& e,
|
E& configure( const T& t, E& e,
|
||||||
boost::unit_test::const_string instance,
|
boost::unit_test::const_string instance,
|
||||||
boost::optional< detail::type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name,
|
boost::unit_test::const_string name,
|
||||||
BOOST_DEDUCED_TYPENAME boost::disable_if<
|
BOOST_DEDUCED_TYPENAME boost::disable_if<
|
||||||
BOOST_DEDUCED_TYPENAME boost::is_base_of< object, T >
|
BOOST_DEDUCED_TYPENAME boost::is_base_of< object, T >
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue