Renamed mock::detail::check to mock::matcher

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@567 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2012-09-21 22:19:52 +00:00
parent 3e3746dce5
commit a84c66c714
9 changed files with 88 additions and 65 deletions

View file

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

@ -13,7 +13,7 @@
#include "../error.hpp"
#include "../log.hpp"
#include "../constraints.hpp"
#include "check.hpp"
#include "../matcher.hpp"
#include "action.hpp"
#include "verifiable.hpp"
#include "type_name.hpp"

View file

@ -0,0 +1,38 @@
// http://turtle.sourceforge.net
//
// Copyright Mathieu Champlon 2012
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef MOCK_MATCHER_BASE_HPP_INCLUDED
#define MOCK_MATCHER_BASE_HPP_INCLUDED
#include <boost/noncopyable.hpp>
#include <iosfwd>
namespace mock
{
namespace detail
{
template< typename Actual >
class matcher_base : boost::noncopyable
{
public:
virtual ~matcher_base() {}
virtual bool operator()( Actual ) = 0;
friend std::ostream& operator<<( std::ostream& s, const matcher_base& c )
{
c.serialize( s );
return s;
}
private:
virtual void serialize( std::ostream& ) const = 0;
};
}
} // mock
#endif // MOCK_MATCHER_BASE_HPP_INCLUDED

View file

@ -6,43 +6,24 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef MOCK_CHECK_HPP_INCLUDED
#define MOCK_CHECK_HPP_INCLUDED
#ifndef MOCK_MATCHER_HPP_INCLUDED
#define MOCK_MATCHER_HPP_INCLUDED
#include "is_functor.hpp"
#include "../log.hpp"
#include "../constraint.hpp"
#include "log.hpp"
#include "constraint.hpp"
#include "detail/is_functor.hpp"
#include "detail/matcher_base.hpp"
#include <boost/utility/enable_if.hpp>
#include <boost/noncopyable.hpp>
#include <boost/ref.hpp>
#include <cstring>
namespace mock
{
namespace detail
{
template< typename Actual >
class check_base : boost::noncopyable
{
public:
virtual ~check_base() {}
virtual bool operator()( Actual ) = 0;
friend std::ostream& operator<<( std::ostream& s, const check_base& c )
{
c.serialize( s );
return s;
}
private:
virtual void serialize( std::ostream& ) const = 0;
};
template< typename Actual, typename Expected, typename Enable = void >
class check : public check_base< Actual >
class matcher : public detail::matcher_base< Actual >
{
public:
explicit check( Expected expected )
explicit matcher( Expected expected )
: expected_( expected )
{}
virtual bool operator()( Actual actual )
@ -59,10 +40,11 @@ namespace detail
};
template<>
class check< const char*, const char* > : public check_base< const char* >
class matcher< const char*, const char* >
: public detail::matcher_base< const char* >
{
public:
explicit check( const char* expected )
explicit matcher( const char* expected )
: expected_( expected )
{}
virtual bool operator()( const char* actual )
@ -79,11 +61,11 @@ namespace detail
};
template< typename Actual, typename Constraint >
class check< Actual, mock::constraint< Constraint > >
: public check_base< Actual >
class matcher< Actual, mock::constraint< Constraint > >
: public detail::matcher_base< Actual >
{
public:
explicit check( const constraint< Constraint >& c )
explicit matcher( const constraint< Constraint >& c )
: c_( c.f_ )
{}
virtual bool operator()( Actual actual )
@ -100,14 +82,14 @@ namespace detail
};
template< typename Actual, typename Functor >
class check< Actual, Functor,
class matcher< Actual, Functor,
BOOST_DEDUCED_TYPENAME boost::enable_if<
is_functor< Functor >
detail::is_functor< Functor >
>::type
> : public check_base< Actual >
> : public detail::matcher_base< Actual >
{
public:
explicit check( const Functor& f )
explicit matcher( const Functor& f )
: f_( f )
{}
virtual bool operator()( Actual actual )
@ -122,7 +104,6 @@ namespace detail
private:
Functor f_;
};
}
} // mock
#endif // MOCK_CHECK_HPP_INCLUDED
#endif // MOCK_MATCHER_HPP_INCLUDED