Added multi-constraint

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@772 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2015-03-01 11:29:03 +00:00
parent 09b6bddb25
commit 02468ee43a
11 changed files with 251 additions and 102 deletions

View file

@ -651,3 +651,42 @@ BOOST_FIXTURE_TEST_CASE( mock_class_is_thread_safe, mock_error_fixture )
}
#endif // MOCK_THREAD_SAFE
namespace
{
MOCK_CLASS( my_multi_mock )
{
MOCK_METHOD_EXT( m1, 1, void( int ), m1 );
MOCK_METHOD_EXT( m2, 2, void( int, int ), m2 );
};
}
BOOST_FIXTURE_TEST_CASE( mock_method_accepts_multi_constraint, mock_error_fixture )
{
my_multi_mock m;
MOCK_FUNCTOR( f, bool( int, int ) );
MOCK_EXPECT( m.m2 ).once().with( f );
MOCK_EXPECT( f ).once().with( 1, 2 ).returns( true );
m.m2( 1, 2 );
CHECK_CALLS( 2 );
}
namespace
{
struct my_polymorphic_constraint
{
template< typename T1, typename T2 >
bool operator()( T1, T2 ) const
{
return true;
}
};
}
BOOST_FIXTURE_TEST_CASE( mock_method_accepts_polymorphic_multi_constraint, mock_error_fixture )
{
my_multi_mock m;
MOCK_EXPECT( m.m2 ).once().with( my_polymorphic_constraint() );
m.m2( 1, 2 );
CHECK_CALLS( 1 );
}

View file

@ -6,7 +6,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <turtle/matcher.hpp>
#include <turtle/detail/function.hpp>
#include <boost/test/auto_unit_test.hpp>
namespace