mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Removed alternate experimental macros
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@334 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
10eed34ad7
commit
9336d101ec
3 changed files with 4 additions and 144 deletions
|
|
@ -38,9 +38,6 @@ namespace mock
|
||||||
public:
|
public:
|
||||||
typedef BOOST_DEDUCED_TYPENAME
|
typedef BOOST_DEDUCED_TYPENAME
|
||||||
boost::function_types::result_type< Signature >::type result_type;
|
boost::function_types::result_type< Signature >::type result_type;
|
||||||
typedef Signature signature_type;
|
|
||||||
typedef BOOST_DEDUCED_TYPENAME
|
|
||||||
boost::function_types::function_arity< Signature > arity;
|
|
||||||
|
|
||||||
template< typename Args >
|
template< typename Args >
|
||||||
struct sig
|
struct sig
|
||||||
|
|
@ -49,6 +46,8 @@ namespace mock
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME
|
||||||
|
boost::function_types::function_arity< Signature > arity;
|
||||||
typedef BOOST_DEDUCED_TYPENAME
|
typedef BOOST_DEDUCED_TYPENAME
|
||||||
detail::expectation< Signature, arity::value > expectation_type;
|
detail::expectation< Signature, arity::value > expectation_type;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@
|
||||||
#include <boost/mpl/joint_view.hpp>
|
#include <boost/mpl/joint_view.hpp>
|
||||||
#include <boost/mpl/single_view.hpp>
|
#include <boost/mpl/single_view.hpp>
|
||||||
#include <boost/mpl/pop_front.hpp>
|
#include <boost/mpl/pop_front.hpp>
|
||||||
#include <boost/mpl/equal_to.hpp>
|
|
||||||
#include <boost/mpl/size_t.hpp>
|
|
||||||
#define BOOST_TYPEOF_SILENT
|
#define BOOST_TYPEOF_SILENT
|
||||||
#include <boost/typeof/typeof.hpp>
|
#include <boost/typeof/typeof.hpp>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
@ -125,23 +123,6 @@ namespace detail
|
||||||
{
|
{
|
||||||
typedef T base_type;
|
typedef T base_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename E, int N >
|
|
||||||
struct has_arity : boost::mpl::equal_to< BOOST_DEDUCED_TYPENAME E::arity, boost::mpl::size_t< N > >
|
|
||||||
{};
|
|
||||||
|
|
||||||
#define MOCK_CALL(z, n, d) \
|
|
||||||
template< typename E > \
|
|
||||||
BOOST_DEDUCED_TYPENAME boost::enable_if< \
|
|
||||||
BOOST_DEDUCED_TYPENAME has_arity< E, n >::type, \
|
|
||||||
BOOST_DEDUCED_TYPENAME E::result_type \
|
|
||||||
>::type \
|
|
||||||
call( E e BOOST_PP_COMMA_IF(n) MOCK_ARGS(n, BOOST_DEDUCED_TYPENAME E::signature_type, BOOST_DEDUCED_TYPENAME ) ) \
|
|
||||||
{ \
|
|
||||||
return e( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
|
||||||
}
|
|
||||||
BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_CALL, BOOST_PP_EMPTY)
|
|
||||||
#undef MOCK_CALL
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,8 +149,8 @@ namespace detail
|
||||||
#define MOCK_METHOD_STUB(M, n, S, t, c, tpn) \
|
#define MOCK_METHOD_STUB(M, n, S, t, c, tpn) \
|
||||||
MOCK_DECL(M, n, S, c, tpn) \
|
MOCK_DECL(M, n, S, c, tpn) \
|
||||||
{ \
|
{ \
|
||||||
return mock::detail::call( MOCK_ANONYMOUS_MOCKER(this, t, t) \
|
return MOCK_ANONYMOUS_MOCKER(this, t, t)( \
|
||||||
BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, p) ); \
|
BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MOCK_METHOD_EXT(M, n, S, t) \
|
#define MOCK_METHOD_EXT(M, n, S, t) \
|
||||||
|
|
@ -215,49 +196,4 @@ namespace detail
|
||||||
#define MOCK_RESET(o,t) MOCK_MOCKER(o,t).reset()
|
#define MOCK_RESET(o,t) MOCK_MOCKER(o,t).reset()
|
||||||
#define MOCK_VERIFY(o,t) MOCK_MOCKER(o,t).verify()
|
#define MOCK_VERIFY(o,t) MOCK_MOCKER(o,t).verify()
|
||||||
|
|
||||||
// alternate experimental macros below, way too slow to compile to be really usable
|
|
||||||
|
|
||||||
namespace mock
|
|
||||||
{
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
#define MOCK_CALL_INVALID_TYPE(z, n, d) invalid_type
|
|
||||||
#define MOCK_CALL(z, n, d) \
|
|
||||||
template< typename E > \
|
|
||||||
BOOST_DEDUCED_TYPENAME boost::disable_if< \
|
|
||||||
BOOST_DEDUCED_TYPENAME has_arity< E, n >::type, \
|
|
||||||
BOOST_DEDUCED_TYPENAME E::result_type \
|
|
||||||
>::type \
|
|
||||||
call( E BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM(n, MOCK_CALL_INVALID_TYPE, BOOST_PP_EMPTY) ) \
|
|
||||||
{}
|
|
||||||
BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_CALL, BOOST_PP_EMPTY)
|
|
||||||
#undef MOCK_CALL
|
|
||||||
#undef MOCK_CALL_INVALID_TYPE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MOCK_METHOD_STUB_PROXY(z, n, d) \
|
|
||||||
MOCK_METHOD_STUB( \
|
|
||||||
BOOST_PP_ARRAY_ELEM(0, d), \
|
|
||||||
n, \
|
|
||||||
BOOST_PP_ARRAY_ELEM(1, d), \
|
|
||||||
BOOST_PP_ARRAY_ELEM(2, d), \
|
|
||||||
BOOST_PP_ARRAY_ELEM(3, d), \
|
|
||||||
BOOST_PP_ARRAY_ELEM(4, d))
|
|
||||||
|
|
||||||
#define MOCK_METHOD_STUB_ALT(M, S, t, c, tpn) \
|
|
||||||
BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_METHOD_STUB_PROXY, (5,(M, S, t, c, tpn)))
|
|
||||||
|
|
||||||
#define MOCK_METHOD_EXT_ALT(M, S, t) \
|
|
||||||
MOCK_METHOD_STUB_ALT(M, S, t,,) \
|
|
||||||
MOCK_METHOD_STUB_ALT(M, S, t, const,) \
|
|
||||||
MOCK_METHOD_EXPECTATION(S, t)
|
|
||||||
#define MOCK_METHOD_ALT(M) \
|
|
||||||
MOCK_METHOD_EXT_ALT(M, MOCK_SIGNATURE(M), M)
|
|
||||||
|
|
||||||
#define MOCK_METHOD_EXT_TPL_ALT(M, S, t) \
|
|
||||||
MOCK_METHOD_STUB_ALT(M, S, t,, BOOST_DEDUCED_TYPENAME) \
|
|
||||||
MOCK_METHOD_STUB_ALT(M, S, t, const, BOOST_DEDUCED_TYPENAME) \
|
|
||||||
MOCK_METHOD_EXPECTATION(S, t)
|
|
||||||
|
|
||||||
#endif // MOCK_MOCK_HPP_INCLUDED
|
#endif // MOCK_MOCK_HPP_INCLUDED
|
||||||
|
|
|
||||||
|
|
@ -266,78 +266,3 @@ BOOST_MPL_ASSERT(( boost::is_same< mock::detail::invalid_type, mock::detail::arg
|
||||||
BOOST_MPL_ASSERT(( boost::is_same< mock::detail::invalid_type, mock::detail::arg< void( float, int ), 1, 1 >::type > ));
|
BOOST_MPL_ASSERT(( boost::is_same< mock::detail::invalid_type, mock::detail::arg< void( float, int ), 1, 1 >::type > ));
|
||||||
BOOST_MPL_ASSERT(( boost::is_same< mock::detail::invalid_type, mock::detail::arg< void( float, int ), 1, 3 >::type > ));
|
BOOST_MPL_ASSERT(( boost::is_same< mock::detail::invalid_type, mock::detail::arg< void( float, int ), 1, 3 >::type > ));
|
||||||
BOOST_MPL_ASSERT(( boost::is_same< mock::detail::invalid_type, mock::detail::arg< void( float, int ), 2, 3 >::type > ));
|
BOOST_MPL_ASSERT(( boost::is_same< mock::detail::invalid_type, mock::detail::arg< void( float, int ), 2, 3 >::type > ));
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( call_selects_proper_form )
|
|
||||||
{
|
|
||||||
{
|
|
||||||
mock::function< void() > e;
|
|
||||||
e.expect().once();
|
|
||||||
mock::detail::call( e );
|
|
||||||
}
|
|
||||||
{
|
|
||||||
mock::function< void( int ) > e;
|
|
||||||
e.expect().once();
|
|
||||||
mock::detail::call( e, 3 );
|
|
||||||
}
|
|
||||||
{
|
|
||||||
mock::function< int() > e;
|
|
||||||
e.expect().once().returns( 0 );
|
|
||||||
mock::detail::call( e );
|
|
||||||
}
|
|
||||||
{
|
|
||||||
mock::function< int( int ) > e;
|
|
||||||
e.expect().once().returns( 0 );
|
|
||||||
mock::detail::call( e, 3 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
struct mock_class_0
|
|
||||||
{
|
|
||||||
MOCK_METHOD_EXT_ALT( method, void(), method )
|
|
||||||
};
|
|
||||||
struct mock_class_1
|
|
||||||
{
|
|
||||||
MOCK_METHOD_EXT_ALT( method, void( float ), method )
|
|
||||||
};
|
|
||||||
|
|
||||||
struct mock_class_r0
|
|
||||||
{
|
|
||||||
MOCK_METHOD_EXT_ALT( method, int(), method )
|
|
||||||
};
|
|
||||||
struct mock_class_r1
|
|
||||||
{
|
|
||||||
MOCK_METHOD_EXT_ALT( method, int( float ), method )
|
|
||||||
};
|
|
||||||
|
|
||||||
struct forward_declared_only;
|
|
||||||
struct defined_but_non_copiable : private boost::noncopyable
|
|
||||||
{
|
|
||||||
};
|
|
||||||
struct base_class
|
|
||||||
{
|
|
||||||
virtual ~base_class() {}
|
|
||||||
virtual void some_method( int, float&, const std::string& ) = 0;
|
|
||||||
virtual void some_other_method() = 0;
|
|
||||||
virtual int another_method() = 0;
|
|
||||||
virtual void yet_another_method( forward_declared_only& ) = 0;
|
|
||||||
virtual void yet_again_some_other_method( defined_but_non_copiable& ) = 0;
|
|
||||||
};
|
|
||||||
MOCK_BASE_CLASS( mock_base_class, base_class )
|
|
||||||
{
|
|
||||||
MOCK_METHOD_ALT( some_method )
|
|
||||||
MOCK_METHOD_ALT( some_other_method )
|
|
||||||
MOCK_METHOD_ALT( another_method )
|
|
||||||
MOCK_METHOD_ALT( yet_another_method )
|
|
||||||
MOCK_METHOD_ALT( yet_again_some_other_method )
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( experimental_macros_slow_as_hell_to_compile )
|
|
||||||
{
|
|
||||||
mock_base_class c;
|
|
||||||
MOCK_EXPECT( c, some_method ).once();
|
|
||||||
float f = 4.f;
|
|
||||||
c.some_method( 3, f, "" );
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue