git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@498 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2012-07-22 07:07:47 +00:00
parent f1cc1321e8
commit 8cdf6f5934
8 changed files with 28 additions and 42 deletions

View file

@ -81,7 +81,7 @@ namespace detail
template< typename Actual, typename Functor >
class check< Actual, Functor,
BOOST_DEDUCED_TYPENAME boost::enable_if<
detail::is_functor< Functor >
is_functor< Functor >
>::type
> : public check_base< Actual >
{

View file

@ -22,7 +22,7 @@ namespace detail
{
public:
expectation_base()
: i_( new detail::unlimited() )
: i_( new unlimited() )
, file_( "unknown location" )
, line_( 0 )
{}
@ -72,22 +72,22 @@ namespace detail
(*it)->remove( this );
}
void expect( detail::invocation* i )
void expect( invocation* i )
{
i_.reset( i );
}
void add( boost::shared_ptr< detail::sequence_impl > s )
void add( boost::shared_ptr< sequence_impl > s )
{
s->add( this );
sequences_.push_back( s );
}
boost::shared_ptr< detail::invocation > i_;
boost::shared_ptr< invocation > i_;
private:
typedef std::vector<
boost::shared_ptr< detail::sequence_impl >
boost::shared_ptr< sequence_impl >
> sequences_type;
typedef sequences_type::const_iterator sequences_cit;

View file

@ -11,20 +11,13 @@
#define MOCK_EXPECTATION_INITIALIZE(z, n, d) \
BOOST_PP_COMMA_IF(n) c##n##_( \
new detail::check< \
arg##n##_type, \
constraint< detail::any > \
>( mock::any ) )
new check< arg##n##_type, constraint< any > >( mock::any ) )
#define MOCK_EXPECTATION_WITH(z, n, d) \
c##n##_.reset( \
new detail::check< \
arg##n##_type, \
Constraint_##n \
>( c##n ) );
c##n##_.reset( new check< arg##n##_type, Constraint_##n >( c##n ) );
#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) \
BOOST_PP_COMMA_IF(n) arg##n##_type a##n

View file

@ -29,15 +29,13 @@ namespace detail
template< typename R BOOST_PP_COMMA_IF(MOCK_NUM_ARGS)
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T) >
class function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
: public detail::verifiable,
public boost::enable_shared_from_this<
: public verifiable, public boost::enable_shared_from_this<
function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )> >
{
public:
typedef MOCK_ERROR_POLICY< R > error_type;
typedef detail::expectation<
R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
typedef expectation< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
> expectation_type;
public:
@ -174,7 +172,7 @@ namespace detail
expectations_type::const_iterator expectations_cit;
expectations_type expectations_;
detail::context* context_;
context* context_;
mutable bool valid_;
};
}

View file

@ -78,20 +78,20 @@ namespace detail
return s << *e.impl_;
}
function& operator()( detail::context& c,
function& operator()( context& c,
boost::unit_test::const_string instance )
{
if( ! impl_->context_ )
c.add( *impl_ );
c.add( impl_.get(), *impl_, instance,
boost::optional< detail::type_name >(), "" );
boost::optional< type_name >(), "" );
impl_->context_ = &c;
return *this;
}
void configure( detail::context& c, const void* p,
void configure( context& c, const void* p,
boost::unit_test::const_string instance,
boost::optional< detail::type_name > type,
boost::optional< type_name > type,
boost::unit_test::const_string name ) const
{
if( ! impl_->context_ )

View file

@ -23,24 +23,24 @@ namespace mock
{
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:
virtual void add( const void* /*p*/, detail::verifiable& v,
virtual void add( const void* /*p*/, verifiable& v,
boost::unit_test::const_string instance,
boost::optional< detail::type_name > type,
boost::optional< type_name > type,
boost::unit_test::const_string name )
{
if( children_.empty() )
mock::detail::root.add( *this );
children_[ &v ].update( parent_, instance, type, name );
}
virtual void add( detail::verifiable& v )
virtual void add( verifiable& v )
{
group_.add( v );
}
virtual void remove( detail::verifiable& v )
virtual void remove( verifiable& v )
{
group_.remove( v );
children_.erase( &v );
@ -48,8 +48,7 @@ namespace detail
mock::detail::root.remove( *this );
}
virtual void serialize( std::ostream& s,
const detail::verifiable& v ) const
virtual void serialize( std::ostream& s, const verifiable& v ) const
{
children_cit it = children_.find( &v );
if( it != children_.end() )
@ -69,14 +68,11 @@ namespace detail
}
private:
typedef std::map<
const detail::verifiable*,
detail::child
> children_t;
typedef std::map< const verifiable*, child > children_t;
typedef children_t::const_iterator children_cit;
detail::group group_;
detail::parent parent_;
group group_;
parent parent_;
children_t children_;
};
}

View file

@ -21,8 +21,7 @@ namespace mock
{
namespace detail
{
class root_t : public boost::unit_test::singleton< root_t >,
public detail::context
class root_t : public boost::unit_test::singleton< root_t >, public context
{
public:
virtual void add( const void* p, verifiable& v,

View file

@ -38,7 +38,7 @@ namespace detail
template< typename E >
E& configure( const object& o, E& e,
boost::unit_test::const_string instance,
boost::optional< detail::type_name > type,
boost::optional< type_name > type,
boost::unit_test::const_string name )
{
e.configure( *o.impl_, o.impl_.get(), instance, type, name );
@ -48,7 +48,7 @@ namespace detail
template< typename T, typename E >
E& configure( const T& t, E& e,
boost::unit_test::const_string instance,
boost::optional< detail::type_name > type,
boost::optional< type_name > type,
boost::unit_test::const_string name,
BOOST_DEDUCED_TYPENAME boost::disable_if<
BOOST_DEDUCED_TYPENAME boost::is_base_of< object, T >