mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Reverted 206
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@208 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
81244305ce
commit
9324f8f033
1 changed files with 14 additions and 44 deletions
|
|
@ -9,20 +9,13 @@
|
||||||
#ifndef MOCK_CHECK_HPP_INCLUDED
|
#ifndef MOCK_CHECK_HPP_INCLUDED
|
||||||
#define MOCK_CHECK_HPP_INCLUDED
|
#define MOCK_CHECK_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
|
||||||
#include "is_functor.hpp"
|
#include "is_functor.hpp"
|
||||||
#include "constraints.hpp"
|
#include "constraints.hpp"
|
||||||
#include "operators.hpp"
|
#include "operators.hpp"
|
||||||
#include "format.hpp"
|
#include "format.hpp"
|
||||||
|
#include <boost/function.hpp>
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/utility/enable_if.hpp>
|
||||||
#include <boost/concept_check.hpp>
|
#include <boost/concept_check.hpp>
|
||||||
#ifdef MOCK_USE_BOOST_BIND
|
|
||||||
#include <boost/bind.hpp>
|
|
||||||
#else
|
|
||||||
#include <boost/spirit/home/phoenix/bind.hpp>
|
|
||||||
#include <boost/spirit/home/phoenix/core/argument.hpp>
|
|
||||||
#endif
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
|
@ -37,8 +30,8 @@ namespace detail
|
||||||
BOOST_CONCEPT_USAGE( FunctorCompatible )
|
BOOST_CONCEPT_USAGE( FunctorCompatible )
|
||||||
{
|
{
|
||||||
boost::require_boolean_expr(
|
boost::require_boolean_expr(
|
||||||
// if an error is generated by the line below it means
|
// if an error is generated by the line below it means an argument
|
||||||
// an argument passed to 'with' was of the wrong type.
|
// passed to 'with' was of the wrong type.
|
||||||
functor_accepts( actual_argument_type )
|
functor_accepts( actual_argument_type )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -55,8 +48,8 @@ namespace detail
|
||||||
BOOST_CONCEPT_USAGE( EqualityComparable )
|
BOOST_CONCEPT_USAGE( EqualityComparable )
|
||||||
{
|
{
|
||||||
boost::require_boolean_expr(
|
boost::require_boolean_expr(
|
||||||
// if an error is generated by the line below it means
|
// if an error is generated by the line below it means an argument
|
||||||
// an argument passed to 'with' was of the wrong type.
|
// passed to 'with' was of the wrong type.
|
||||||
actual_argument_type == expected_argument_type
|
actual_argument_type == expected_argument_type
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -66,28 +59,6 @@ namespace detail
|
||||||
Actual actual_argument_type;
|
Actual actual_argument_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename T >
|
|
||||||
void log( std::ostream& s, const T& t )
|
|
||||||
{
|
|
||||||
s << mock::format( t );
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef MOCK_USE_BOOST_BIND
|
|
||||||
template< typename T >
|
|
||||||
boost::function< void( std::ostream& ) > lazy_format( T t )
|
|
||||||
{
|
|
||||||
return boost::bind( &log< T >, _1, t );
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
template< typename T >
|
|
||||||
boost::function< void( std::ostream& ) > lazy_format( T t )
|
|
||||||
{
|
|
||||||
return boost::phoenix::bind(
|
|
||||||
&log< T >,
|
|
||||||
boost::phoenix::arg_names::_1, t );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template< typename Actual >
|
template< typename Actual >
|
||||||
class check
|
class check
|
||||||
{
|
{
|
||||||
|
|
@ -97,7 +68,7 @@ namespace detail
|
||||||
BOOST_DEDUCED_TYPENAME boost::enable_if<
|
BOOST_DEDUCED_TYPENAME boost::enable_if<
|
||||||
BOOST_DEDUCED_TYPENAME detail::is_functor< Functor >
|
BOOST_DEDUCED_TYPENAME detail::is_functor< Functor >
|
||||||
>::type* = 0 )
|
>::type* = 0 )
|
||||||
: desc_( lazy_format( f ) )
|
: desc_( mock::format( f ) )
|
||||||
{
|
{
|
||||||
BOOST_CONCEPT_ASSERT(( FunctorCompatible< Functor, Actual > ));
|
BOOST_CONCEPT_ASSERT(( FunctorCompatible< Functor, Actual > ));
|
||||||
f_ = f;
|
f_ = f;
|
||||||
|
|
@ -109,19 +80,19 @@ namespace detail
|
||||||
BOOST_DEDUCED_TYPENAME boost::disable_if<
|
BOOST_DEDUCED_TYPENAME boost::disable_if<
|
||||||
BOOST_DEDUCED_TYPENAME detail::is_functor< Expected >
|
BOOST_DEDUCED_TYPENAME detail::is_functor< Expected >
|
||||||
>::type* = 0 )
|
>::type* = 0 )
|
||||||
: desc_( lazy_format( expected ) )
|
: desc_( mock::format( expected ) )
|
||||||
{
|
{
|
||||||
BOOST_CONCEPT_ASSERT(( EqualityComparable< Expected, Actual > ));
|
BOOST_CONCEPT_ASSERT(( EqualityComparable< Expected, Actual > ));
|
||||||
f_ = mock::equal( expected ).f_;
|
f_ = mock::equal( expected ).f_;
|
||||||
if( ! f_ )
|
if( ! f_ )
|
||||||
std::invalid_argument( "invalid constraint" );
|
std::invalid_argument( "invalid constraint" );
|
||||||
}
|
}
|
||||||
template< typename Constraint >
|
template< typename Functor >
|
||||||
explicit check( const constraint< Constraint >& c )
|
explicit check( const constraint< Functor >& ph )
|
||||||
: desc_( lazy_format( c.f_ ) )
|
: desc_( mock::format( ph.f_ ) )
|
||||||
{
|
{
|
||||||
BOOST_CONCEPT_ASSERT(( FunctorCompatible< Constraint, Actual > ));
|
BOOST_CONCEPT_ASSERT(( FunctorCompatible< Functor, Actual > ));
|
||||||
f_ = c.f_;
|
f_ = ph.f_;
|
||||||
if( ! f_ )
|
if( ! f_ )
|
||||||
std::invalid_argument( "invalid constraint" );
|
std::invalid_argument( "invalid constraint" );
|
||||||
}
|
}
|
||||||
|
|
@ -133,13 +104,12 @@ namespace detail
|
||||||
|
|
||||||
friend std::ostream& operator<<( std::ostream& s, const check& c )
|
friend std::ostream& operator<<( std::ostream& s, const check& c )
|
||||||
{
|
{
|
||||||
c.desc_( s );
|
return s << c.desc_;
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::function< bool( Actual ) > f_;
|
boost::function< bool( Actual ) > f_;
|
||||||
boost::function< void( std::ostream& ) > desc_;
|
std::string desc_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue