mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Most functors as constraints are detected automatically
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@6 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
22d9120dc8
commit
0d0b921d83
6 changed files with 135 additions and 5 deletions
|
|
@ -303,12 +303,12 @@ BOOST_AUTO_TEST_CASE( triggering_an_expectation_with_failing_custom_constraint_t
|
|||
{
|
||||
{
|
||||
mock::expectation< void( int ) > e;
|
||||
e.expect().with( mock::constraint( &custom_constraint ) );
|
||||
e.expect().with( &custom_constraint );
|
||||
BOOST_CHECK_EXCEPTION_CONTAINS( e( 42 ), "unexpected call" );
|
||||
}
|
||||
{
|
||||
mock::expectation< int( int, const std::string& ) > e;
|
||||
e.expect().with( mock::constraint( &custom_constraint ), "actual" );
|
||||
e.expect().with( &custom_constraint, "actual" );
|
||||
BOOST_CHECK_EXCEPTION_CONTAINS( e( 42, "actual" ), "unexpected call" );
|
||||
}
|
||||
}
|
||||
|
|
@ -655,7 +655,7 @@ BOOST_AUTO_TEST_CASE( expectation_can_be_serialized_to_be_human_readable )
|
|||
}
|
||||
{
|
||||
mock::expectation< void( int ) > e( "my expectation" );
|
||||
e.expect().once().with( mock::constraint( &custom_constraint ) );
|
||||
e.expect().once().with( &custom_constraint );
|
||||
std::stringstream s;
|
||||
s << e;
|
||||
const std::string expected = "my expectation\n"
|
||||
|
|
|
|||
59
src/tests/turtle_test/is_functor_test.cpp
Normal file
59
src/tests/turtle_test/is_functor_test.cpp
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
//
|
||||
// Copyright Mathieu Champlon 2009
|
||||
//
|
||||
// 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/is_functor.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
#define BOOST_LIB_NAME boost_unit_test_framework
|
||||
#include <boost/config/auto_link.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
template< typename T >
|
||||
void check( T )
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( mock::detail::is_functor< T >::value ));
|
||||
}
|
||||
|
||||
void f0 () {}
|
||||
bool f1( int ) { return false; }
|
||||
|
||||
struct s
|
||||
{
|
||||
typedef void result_type;
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( function_is_functor )
|
||||
{
|
||||
check( f0 );
|
||||
check( f1 );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( function_pointer_is_functor )
|
||||
{
|
||||
check( &f0 );
|
||||
check( &f1 );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( boost_bind_is_functor )
|
||||
{
|
||||
check( boost::bind( &f0 ) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( boost_function_is_functor )
|
||||
{
|
||||
check( boost::function< void() >() );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( class_with_result_type_is_functor )
|
||||
{
|
||||
check( s() );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue