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@202 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
87d34f4137
commit
9934924853
3 changed files with 17 additions and 42 deletions
|
|
@ -13,9 +13,7 @@
|
||||||
#ifdef MOCK_USE_BOOST_BIND
|
#ifdef MOCK_USE_BOOST_BIND
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#else
|
#else
|
||||||
#include <boost/spirit/home/phoenix/statement/throw.hpp>
|
#include <boost/spirit/home/phoenix/bind.hpp>
|
||||||
#include <boost/spirit/home/phoenix/operator/self.hpp>
|
|
||||||
#include <boost/spirit/home/phoenix/core/nothing.hpp>
|
|
||||||
#endif
|
#endif
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
|
||||||
|
|
@ -23,8 +21,12 @@ namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef MOCK_USE_BOOST_BIND
|
#ifdef MOCK_USE_BOOST_BIND
|
||||||
|
using boost::bind;
|
||||||
|
#else
|
||||||
|
using boost::phoenix::bind;
|
||||||
|
#endif
|
||||||
|
|
||||||
template< typename Result, typename Signature >
|
template< typename Result, typename Signature >
|
||||||
struct lambda
|
struct lambda
|
||||||
{
|
{
|
||||||
|
|
@ -34,21 +36,21 @@ namespace detail
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static functor_type make_val( T t )
|
static functor_type make_val( T t )
|
||||||
{
|
{
|
||||||
return boost::bind( &do_identity< T >, t );
|
return bind( &do_identity< T >, t );
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static functor_type make_val( boost::reference_wrapper< T > t )
|
static functor_type make_val( boost::reference_wrapper< T > t )
|
||||||
{
|
{
|
||||||
return boost::bind( &do_ref_identity< T >, t.get_pointer() );
|
return bind( &do_ref_identity< T >, t.get_pointer() );
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static functor_type make_throw( T t )
|
static functor_type make_throw( T t )
|
||||||
{
|
{
|
||||||
return boost::bind( &do_throw< T >, t );
|
return bind( &do_throw< T >, t );
|
||||||
}
|
}
|
||||||
static functor_type make_nothing()
|
static functor_type make_nothing()
|
||||||
{
|
{
|
||||||
return boost::bind( &do_nothing );
|
return bind( &do_nothing );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
|
|
@ -70,37 +72,6 @@ namespace detail
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
template< typename Result, typename Signature >
|
|
||||||
struct lambda
|
|
||||||
{
|
|
||||||
typedef BOOST_DEDUCED_TYPENAME
|
|
||||||
boost::function< Signature > functor_type;
|
|
||||||
|
|
||||||
template< typename T >
|
|
||||||
static functor_type make_val( T t )
|
|
||||||
{
|
|
||||||
return boost::phoenix::val( t );
|
|
||||||
}
|
|
||||||
template< typename T >
|
|
||||||
static functor_type make_val( boost::reference_wrapper< T > t )
|
|
||||||
{
|
|
||||||
return *boost::phoenix::val( t.get_pointer() );
|
|
||||||
}
|
|
||||||
template< typename T >
|
|
||||||
static functor_type make_throw( T t )
|
|
||||||
{
|
|
||||||
return boost::phoenix::throw_( t );
|
|
||||||
}
|
|
||||||
static functor_type make_nothing()
|
|
||||||
{
|
|
||||||
return boost::phoenix::nothing;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include <boost/function_types/parameter_types.hpp>
|
#include <boost/function_types/parameter_types.hpp>
|
||||||
#include <boost/function_types/function_type.hpp>
|
#include <boost/function_types/function_type.hpp>
|
||||||
#include <boost/function_types/result_type.hpp>
|
#include <boost/function_types/result_type.hpp>
|
||||||
|
#include <boost/type_traits/is_base_of.hpp>
|
||||||
#include <boost/mpl/equal_to.hpp>
|
#include <boost/mpl/equal_to.hpp>
|
||||||
#include <boost/mpl/size_t.hpp>
|
#include <boost/mpl/size_t.hpp>
|
||||||
#include <boost/mpl/vector.hpp>
|
#include <boost/mpl/vector.hpp>
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <boost/ref.hpp>
|
#include <boost/ref.hpp>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
@ -346,7 +347,7 @@ namespace
|
||||||
|
|
||||||
friend std::ostream& operator<<( std::ostream& s, const near_constraint& c )
|
friend std::ostream& operator<<( std::ostream& s, const near_constraint& c )
|
||||||
{
|
{
|
||||||
return s << "std::abs( _ - " << c.expected_ << " ) < " << c.threshold_;
|
return s << "near( " << c.expected_ << ", " << c.threshold_ << " )";
|
||||||
}
|
}
|
||||||
|
|
||||||
//template< typename Actual >
|
//template< typename Actual >
|
||||||
|
|
@ -371,6 +372,8 @@ BOOST_AUTO_TEST_CASE( writing_custom_constraint )
|
||||||
MOCK_EXPECT( f, _ ).with( near( 3.f, 0.01f ) );
|
MOCK_EXPECT( f, _ ).with( near( 3.f, 0.01f ) );
|
||||||
f( 3.f );
|
f( 3.f );
|
||||||
const std::string expected = "f\n"
|
const std::string expected = "f\n"
|
||||||
". unlimited().with( std::abs( _ - 3 ) < 0.01 )";
|
". unlimited().with( near( 3, 0.01 ) )";
|
||||||
BOOST_CHECK_EQUAL( expected, mock::format( f ) );
|
std::stringstream s;
|
||||||
|
s << f;
|
||||||
|
BOOST_CHECK_EQUAL( expected, s.str() );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue