mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Removed limitation on the operator() of a custom constraint which was required to be const
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@390 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
dc27632f66
commit
ee338d40bb
4 changed files with 23 additions and 35 deletions
|
|
@ -206,10 +206,6 @@
|
||||||
RelativePath="..\..\src\tests\errors_test\constraint_value_of_wrong_type_in_builtin_constraint.cpp"
|
RelativePath="..\..\src\tests\errors_test\constraint_value_of_wrong_type_in_builtin_constraint.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\tests\errors_test\custom_constraint_call_operator_not_const.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\tests\errors_test\mismatch_type_in_returns_int_action.cpp"
|
RelativePath="..\..\src\tests\errors_test\mismatch_type_in_returns_int_action.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ namespace detail
|
||||||
public:
|
public:
|
||||||
virtual ~check_base() {}
|
virtual ~check_base() {}
|
||||||
|
|
||||||
virtual bool operator()( Actual ) const = 0;
|
virtual bool operator()( Actual ) = 0;
|
||||||
|
|
||||||
friend std::ostream& operator<<( std::ostream& s, const check_base& c )
|
friend std::ostream& operator<<( std::ostream& s, const check_base& c )
|
||||||
{
|
{
|
||||||
|
|
@ -88,7 +88,7 @@ namespace detail
|
||||||
Actual > ));
|
Actual > ));
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
virtual bool operator()( Actual actual ) const
|
virtual bool operator()( Actual actual )
|
||||||
{
|
{
|
||||||
return actual == boost::unwrap_ref( expected_ );
|
return actual == boost::unwrap_ref( expected_ );
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +111,7 @@ namespace detail
|
||||||
BOOST_CONCEPT_ASSERT(( FunctorCompatible< Constraint, Actual > ));
|
BOOST_CONCEPT_ASSERT(( FunctorCompatible< Constraint, Actual > ));
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
virtual bool operator()( Actual actual ) const
|
virtual bool operator()( Actual actual )
|
||||||
{
|
{
|
||||||
return c_( actual );
|
return c_( actual );
|
||||||
}
|
}
|
||||||
|
|
@ -137,7 +137,7 @@ namespace detail
|
||||||
BOOST_CONCEPT_ASSERT(( FunctorCompatible< Functor, Actual > ));
|
BOOST_CONCEPT_ASSERT(( FunctorCompatible< Functor, Actual > ));
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
virtual bool operator()( Actual actual ) const
|
virtual bool operator()( Actual actual )
|
||||||
{
|
{
|
||||||
return f_( actual );
|
return f_( actual );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
//
|
|
||||||
// Copyright Mathieu Champlon 2011
|
|
||||||
//
|
|
||||||
// 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)
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <turtle/mock.hpp>
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
MOCK_CLASS( my_class )
|
|
||||||
{
|
|
||||||
MOCK_METHOD_EXT( my_method, 1, void( int ), my_method )
|
|
||||||
};
|
|
||||||
struct custom_constraint
|
|
||||||
{
|
|
||||||
template< typename Actual >
|
|
||||||
bool operator()( Actual actual );
|
|
||||||
};
|
|
||||||
void test_case()
|
|
||||||
{
|
|
||||||
my_class c;
|
|
||||||
MOCK_EXPECT( c, my_method ).with( mock::constraint< custom_constraint >( custom_constraint() ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -413,6 +413,25 @@ BOOST_AUTO_TEST_CASE( using_custom_constraint )
|
||||||
BOOST_CHECK_EQUAL( expected, s.str() );
|
BOOST_CHECK_EQUAL( expected, s.str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
struct custom_constraint_with_non_const_operator
|
||||||
|
{
|
||||||
|
template< typename Actual >
|
||||||
|
bool operator()( Actual actual )
|
||||||
|
{
|
||||||
|
return actual == 42;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( custom_constraint_function_operator_does_not_need_to_be_const )
|
||||||
|
{
|
||||||
|
MOCK_FUNCTOR( void( float ) ) f;
|
||||||
|
MOCK_EXPECT( f, _ ).with( mock::constraint< custom_constraint_with_non_const_operator >( custom_constraint_with_non_const_operator() ) );
|
||||||
|
f( 42 );
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( boost_reference_wrapper_is_supported_in_value_constraint )
|
BOOST_AUTO_TEST_CASE( boost_reference_wrapper_is_supported_in_value_constraint )
|
||||||
{
|
{
|
||||||
MOCK_FUNCTOR( void( const std::string& ) ) f;
|
MOCK_FUNCTOR( void( const std::string& ) ) f;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue