From 6503e69624ce509999cba47e79b2b15bcc382ae7 Mon Sep 17 00:00:00 2001 From: mat007 Date: Sun, 1 Mar 2015 11:27:48 +0000 Subject: [PATCH] Factorized invocation configuration git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@765 860be788-9bd5-4423-9f1e-828f051e677b --- turtle/detail/expectation_template.hpp | 30 ++---------------------- turtle/detail/function_impl_template.hpp | 12 +++++----- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/turtle/detail/expectation_template.hpp b/turtle/detail/expectation_template.hpp index adcd91d..f88372a 100644 --- a/turtle/detail/expectation_template.hpp +++ b/turtle/detail/expectation_template.hpp @@ -79,35 +79,9 @@ namespace detail (*it)->remove( this ); } - expectation& once() + void invoke( const boost::shared_ptr< invocation >& i ) { - invocation_ = boost::make_shared< detail::once >(); - return *this; - } - expectation& never() - { - invocation_ = boost::make_shared< detail::never >(); - return *this; - } - expectation& exactly( std::size_t count ) - { - invocation_ = boost::make_shared< detail::exactly >( count ); - return *this; - } - expectation& at_least( std::size_t min ) - { - invocation_ = boost::make_shared< detail::at_least >( min ); - return *this; - } - expectation& at_most( std::size_t max ) - { - invocation_ = boost::make_shared< detail::at_most >( max ); - return *this; - } - expectation& between( std::size_t min, std::size_t max ) - { - invocation_ = boost::make_shared< detail::between >( min, max ); - return *this; + invocation_ = i; } #ifndef MOCK_NUM_ARGS_0 diff --git a/turtle/detail/function_impl_template.hpp b/turtle/detail/function_impl_template.hpp index 1b7d41d..65fdc53 100644 --- a/turtle/detail/function_impl_template.hpp +++ b/turtle/detail/function_impl_template.hpp @@ -100,32 +100,32 @@ namespace detail wrapper once() { - this->e_->once(); + this->e_->invoke( boost::make_shared< detail::once >() ); return *this; } wrapper never() { - this->e_->never(); + this->e_->invoke( boost::make_shared< detail::never >() ); return *this; } wrapper exactly( std::size_t count ) { - this->e_->exactly( count ); + this->e_->invoke( boost::make_shared< detail::exactly >( count ) ); return *this; } wrapper at_least( std::size_t min ) { - this->e_->at_least( min ); + this->e_->invoke( boost::make_shared< detail::at_least >( min ) ); return *this; } wrapper at_most( std::size_t max ) { - this->e_->at_most( max ); + this->e_->invoke( boost::make_shared< detail::at_most >( max ) ); return *this; } wrapper between( std::size_t min, std::size_t max ) { - this->e_->between( min, max ); + this->e_->invoke( boost::make_shared< detail::between >( min, max ) ); return *this; }