130#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
131#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
142#include <type_traits>
151#pragma warning(disable : 4100)
172template <
typename T,
bool kDefaultConstructible>
174 static T
Get() {
return T(); }
179 Assert(
false, __FILE__, __LINE__,
180 "Default action undefined for the function return type.");
181 return internal::Invalid<T>();
199 static bool Exists() { return ::std::is_default_constructible<T>::value; }
203 T, ::std::is_default_constructible<T>::value>
::Get();
222 static T*
Get() {
return nullptr; }
227#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
229 class BuiltInDefaultValue<type> { \
231 static bool Exists() { return true; } \
232 static type Get() { return value; } \
227#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \ …
248#if GMOCK_WCHAR_T_IS_NATIVE_
263#undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
271 : std::integral_constant<bool, bool(!P::value)> {};
274template <
typename...>
278template <
typename P1>
283template <
typename P1,
typename... Ps>
285 : std::conditional<bool(P1::value), conjunction<Ps...>, P1>::type {};
287template <
typename...>
290template <
typename P1>
293template <
typename P1,
typename... Ps>
296 : std::conditional<!bool(P1::value), disjunction<Ps...>, P1>::type {};
298template <
typename...>
323template <
typename From,
typename To>
328 template <
typename T>
329 static void Accept(T);
332 template <
typename T>
336 template <typename T, typename = decltype(Accept<To>(Make<T>()))>
337 static std::true_type TestImplicitConversion(
int);
340 template <
typename T>
341 static std::false_type TestImplicitConversion(...);
344 using type =
decltype(TestImplicitConversion<From>(0));
345 static constexpr bool value = type::value;
351template <
typename F,
typename... Args>
354template <
typename Void,
typename R,
typename F,
typename... Args>
360template <
typename R,
typename F,
typename... Args>
363 std::is_void<R>::value,
365 is_implicitly_convertible<call_result_t<F, Args...>, R>>::type {};
369template <
typename R,
typename F,
typename... Args>
165namespace internal {
…}
419template <
typename Result,
typename... Args>
424 template <
typename Callable>
427 std::is_constructible<typename std::decay<Callable>::type, Callable>,
434 template <
typename Callable>
437 std::is_constructible<typename std::decay<Callable>::type, Callable>,
446 template <
typename Callable,
447 typename std::enable_if<
454 OnceAction,
typename std::decay<Callable>::type>>,
459 : function_(StdFunctionAdaptor<typename std::decay<Callable>::type>(
460 {}, std::forward<Callable>(callable))) {}
463 template <
typename Callable,
464 typename std::enable_if<
465 internal::conjunction<
470 internal::negation<std::is_same<
471 OnceAction,
typename std::decay<Callable>::type>>,
474 internal::negation<IsDirectlyCompatible<Callable>>,
475 IsCompatibleAfterIgnoringArguments<Callable>>::value,
480 :
OnceAction(IgnoreIncomingArguments<typename std::decay<Callable>::type>{
481 std::forward<Callable>(callable)}) {}
492 return function_(std::forward<Args>(args)...);
503 template <
typename Callable>
504 class StdFunctionAdaptor final {
509 struct CallableTag final {};
511 template <
typename F>
512 explicit StdFunctionAdaptor(CallableTag, F&& callable)
513 : callable_(std::make_shared<Callable>(std::forward<F>(callable))) {}
533 template <
typename... ArgRefs>
535 ArgRefs&&... args)
const {
536 return std::move(*callable_)(std::forward<ArgRefs>(args)...);
542 std::shared_ptr<Callable> callable_;
547 template <
typename Callable>
548 struct IgnoreIncomingArguments {
549 internal::call_result_t<Callable> operator()(Args&&...) {
550 return std::move(callable)();
556 std::function<Result(Args...)> function_;
579 producer_ =
new FixedValueProducer(x);
588 producer_ =
new FactoryValueProducer(factory);
598 static bool IsSet() {
return producer_ !=
nullptr; }
611 : producer_->Produce();
615 class ValueProducer {
617 virtual ~ValueProducer() {}
618 virtual T Produce() = 0;
621 class FixedValueProducer :
public ValueProducer {
623 explicit FixedValueProducer(T value) : value_(value) {}
624 T Produce()
override {
return value_; }
628 FixedValueProducer(
const FixedValueProducer&) =
delete;
629 FixedValueProducer& operator=(
const FixedValueProducer&) =
delete;
632 class FactoryValueProducer :
public ValueProducer {
635 : factory_(factory) {}
636 T Produce()
override {
return factory_(); }
640 FactoryValueProducer(
const FactoryValueProducer&) =
delete;
641 FactoryValueProducer& operator=(
const FactoryValueProducer&) =
delete;
644 static ValueProducer* producer_;
658 static void Clear() { address_ =
nullptr; }
661 static bool IsSet() {
return address_ !=
nullptr; }
692typename DefaultValue<T>::ValueProducer* DefaultValue<T>::producer_ =
nullptr;
696T* DefaultValue<T&>::address_ =
nullptr;
728template <
typename R,
typename... Args>
731 using F = R(Args...);
735 struct ActionAdapter {
737 ::std::shared_ptr<ActionInterface<F>> impl_;
739 template <
typename... InArgs>
741 return impl_->Perform(
742 ::std::forward_as_tuple(::std::forward<InArgs>(args)...));
746 template <
typename G>
747 using IsCompatibleFunctor = std::is_constructible<std::function<F>, G>;
763 IsCompatibleFunctor<G>, std::is_constructible<std::function<Result()>,
766 Init(::std::forward<G>(fun), IsCompatibleFunctor<G>());
776 template <
typename Func>
778 : fun_(action.fun_) {}
805 R operator()(Args... args) && {
806 return action.Perform(
807 std::forward_as_tuple(std::forward<Args>(args)...));
815 template <
typename G>
818 template <
typename G>
819 void Init(G&& g, ::std::true_type) {
820 fun_ = ::std::forward<G>(g);
823 template <
typename G>
824 void Init(G&& g, ::std::false_type) {
825 fun_ = IgnoreArgs<typename ::std::decay<G>::type>{::std::forward<G>(g)};
828 template <
typename FunctionImpl>
830 template <
typename... InArgs>
831 Result operator()(
const InArgs&...)
const {
832 return function_impl();
835 FunctionImpl function_impl;
839 ::std::function<F> fun_;
863template <
typename Impl>
868 template <
typename F>
870 return Action<F>(
new MonomorphicImpl<F>(impl_));
874 template <
typename F>
880 explicit MonomorphicImpl(
const Impl& impl) : impl_(impl) {}
882 Result Perform(
const ArgumentTuple& args)
override {
883 return impl_.template Perform<Result>(args);
907template <
typename Impl>
928 template <
typename U,
typename... Args,
933 std::is_convertible<R, U>,
934 std::is_move_constructible<U>>::value>::type>
936 return Impl<U>(std::move(value_));
939 template <
typename U,
typename... Args,
944 std::is_convertible<const R&, U>,
945 std::is_copy_constructible<U>>::value>::type>
947 return Impl<U>(value_);
952 template <
typename U>
957 explicit Impl(R&& input_value)
958 : state_(new State(std::move(input_value))) {}
962 explicit Impl(
const R& input_value) : state_(new State(input_value)) {}
964 U operator()() && {
return std::move(state_->value); }
965 U operator()() const& {
return state_->value; }
980 explicit State(
const R& input_value_in)
981 : input_value(input_value_in),
990 value(ImplicitCast_<U>(internal::
as_const(input_value))) {}
994 explicit State(R&& input_value_in)
995 : input_value(std::move(input_value_in)),
1002 value(ImplicitCast_<U>(std::move(input_value))) {}
1078 const std::shared_ptr<State> state_;
1089template <
typename T>
1093 : state_(new State(std::move(wrapper.payload))) {}
1096 GTEST_CHECK_(!state_->called)
1097 <<
"A ByMove() action must be performed at most once.";
1099 state_->called =
true;
1100 return std::move(state_->value);
1107 explicit State(T&& value_in) : value(std::move(value_in)) {}
1110 bool called =
false;
1113 const std::shared_ptr<State> state_;
1122 template <
typename Result,
typename ArgumentTuple>
1132 template <
typename Result,
typename ArgumentTuple>
1134 static_assert(std::is_void<Result>::value,
"Result should be void.");
1141template <
typename T>
1149 template <
typename F>
1155 static_assert(std::is_reference<Result>::value,
1156 "use Return instead of ReturnRef to return a value");
1162 template <
typename F>
1168 explicit Impl(T& ref) : ref_(ref) {}
1170 Result Perform(
const ArgumentTuple&)
override {
return ref_; }
1182template <
typename T>
1191 template <
typename F>
1197 static_assert(std::is_reference<Result>::value,
1198 "use Return instead of ReturnRefOfCopy to return a value");
1204 template <
typename F>
1210 explicit Impl(
const T& value) : value_(value) {}
1212 Result Perform(
const ArgumentTuple&)
override {
return value_; }
1223template <
typename T>
1227 GTEST_CHECK_(!values.empty())
1228 <<
"ReturnRoundRobin requires at least one element.";
1229 state_->values = std::move(values);
1232 template <
typename... Args>
1234 return state_->Next();
1240 T ret_val = values[i++];
1241 if (i == values.size()) i = 0;
1245 std::vector<T> values;
1248 std::shared_ptr<State> state_ = std::make_shared<State>();
1256 template <
typename F>
1264template <
typename T1,
typename T2>
1269 template <
typename Result,
typename ArgumentTuple>
1279#if !GTEST_OS_WINDOWS_MOBILE
1283template <
typename T>
1287 : errno_(errno_value), result_(result) {}
1288 template <
typename Result,
typename ArgumentTuple>
1303template <
size_t N,
typename A,
typename =
void>
1307 template <
typename... Args>
1309 *::std::get<N>(std::tie(args...)) =
value;
1314template <
class Class,
typename MethodPtr>
1319 template <
typename... Args>
1330template <
typename FunctionImpl>
1336 template <
typename... Args>
1343template <
class Class,
typename MethodPtr>
1349 decltype((std::declval<Class*>()->*std::declval<MethodPtr>())());
1351 template <
typename... Args>
1358template <
typename A>
1363 template <
typename F>
1376 static_assert(std::is_void<Result>::value,
"Result type should be void.");
1382 template <
typename F>
1388 explicit Impl(
const A& action) : action_(action) {}
1390 void Perform(
const ArgumentTuple& args)
override {
1392 action_.Perform(args);
1399 typename internal::Function<F>::MakeResultIgnoredValue OriginalFunction;
1401 const Action<OriginalFunction> action_;
1407template <
typename InnerAction,
size_t... I>
1413 template <
typename R,
typename... Args>
1415 R(
typename std::tuple_element<I, std::tuple<Args...>>::type...);
1423 template <
typename R,
typename... Args,
1424 typename std::enable_if<
1425 std::is_convertible<
1432 I, std::tuple<Args...>>::type...)>>::value,
1438 R operator()(Args&&... args) && {
1439 return std::move(inner_action)
1441 std::forward_as_tuple(std::forward<Args>(args)...))...);
1448 template <
typename R,
typename... Args,
1449 typename std::enable_if<
1450 std::is_convertible<
1456 Action<R(
typename std::tuple_element<
1457 I, std::tuple<Args...>>::type...)>>::value,
1462 return [converted](Args&&... args) -> R {
1463 return converted.Perform(std::forward_as_tuple(
1464 std::get<I>(std::forward_as_tuple(std::forward<Args>(args)...))...));
1469template <
typename... Actions>
1473template <
typename FinalAction>
1476 struct UserConstructorTag {};
1478 template <
typename T>
1480 : final_action_(std::forward<T>(action)) {}
1488 template <
typename R,
typename... Args,
1489 typename std::enable_if<
1490 std::is_convertible<FinalAction,
OnceAction<R(Args...)>>::value,
1493 return std::move(final_action_);
1497 typename R,
typename... Args,
1498 typename std::enable_if<
1499 std::is_convertible<
const FinalAction&,
Action<R(Args...)>>::value,
1502 return final_action_;
1506 FinalAction final_action_;
1511template <
typename InitialAction,
typename... OtherActions>
1562 template <
typename T>
1563 using InitialActionArgType =
1564 typename std::conditional<std::is_scalar<T>::value, T,
const T&>::type;
1567 struct UserConstructorTag {};
1569 template <
typename T,
typename... U>
1571 U&&... other_actions)
1572 :
Base({}, std::forward<U>(other_actions)...),
1573 initial_action_(std::forward<T>(initial_action)) {}
1575 template <
typename R,
typename... Args,
1576 typename std::enable_if<
1580 std::is_convertible<
1582 OnceAction<void(InitialActionArgType<Args>...)>>,
1583 std::is_convertible<Base,
OnceAction<R(Args...)>>>::value,
1590 OnceAction<void(InitialActionArgType<Args>...)> initial_action;
1593 R operator()(Args... args) && {
1594 std::move(initial_action)
1595 .Call(
static_cast<InitialActionArgType<Args>
>(args)...);
1597 return std::move(remaining_actions).Call(std::forward<Args>(args)...);
1602 std::move(initial_action_),
1603 std::move(
static_cast<Base&
>(*
this)),
1608 typename R,
typename... Args,
1609 typename std::enable_if<
1613 std::is_convertible<
const InitialAction&,
1614 Action<void(InitialActionArgType<Args>...)>>,
1615 std::is_convertible<
const Base&,
Action<R(Args...)>>>::value,
1622 Action<void(InitialActionArgType<Args>...)> initial_action;
1623 Action<R(Args...)> remaining_actions;
1625 R operator()(Args... args)
const {
1626 initial_action.Perform(std::forward_as_tuple(
1627 static_cast<InitialActionArgType<Args>
>(args)...));
1629 return remaining_actions.Perform(
1630 std::forward_as_tuple(std::forward<Args>(args)...));
1636 static_cast<const Base&
>(*this),
1641 InitialAction initial_action_;
1644template <
typename T,
typename... Params>
1648 [](
const Params&... unpacked_params) {
1649 return new T(unpacked_params...);
1658 template <
typename... Args,
1659 typename =
typename std::enable_if<(k <
sizeof...(Args))>::type>
1661 std::forward_as_tuple(std::forward<Args>(args)...))) {
1662 return std::get<k>(std::forward_as_tuple(std::forward<Args>(args)...));
1666template <
size_t k,
typename Ptr>
1670 template <
typename... Args>
1672 *pointer = std::get<k>(std::tie(args...));
1676template <
size_t k,
typename Ptr>
1680 template <
typename... Args>
1682 *
pointer = *std::get<k>(std::tie(args...));
1686template <
size_t k,
typename T>
1690 template <
typename... Args>
1693 typename ::std::tuple_element<k, std::tuple<Args...>>::type;
1694 static_assert(std::is_lvalue_reference<argk_type>::value,
1695 "Argument must be a reference type.");
1696 std::get<k>(std::tie(args...)) =
value;
1700template <
size_t k,
typename I1,
typename I2>
1705 template <
typename... Args>
1707 auto value = std::get<k>(std::tie(args...));
1708 for (
auto it =
first; it !=
last; ++it, (void)++value) {
1716 template <
typename... Args>
1718 delete std::get<k>(std::tie(args...));
1722template <
typename Ptr>
1725 template <
typename... Args>
1731#if GTEST_HAS_EXCEPTIONS
1732template <
typename T>
1736 template <
typename R,
typename... Args>
1737 operator Action<R(Args...)>()
const {
1739 return [copy](Args...) -> R {
throw copy; };
1781template <
typename...
Action>
1785 {}, std::forward<Action>(action)...);
1793template <
size_t k,
typename InnerAction>
1795 InnerAction&& action) {
1796 return {std::forward<InnerAction>(action)};
1803template <
size_t k,
size_t... ks,
typename InnerAction>
1804internal::WithArgsAction<typename std::decay<InnerAction>::type, k, ks...>
1806 return {std::forward<InnerAction>(action)};
1813template <
typename InnerAction>
1815 InnerAction&& action) {
1816 return {std::forward<InnerAction>(action)};
1843template <
typename R>
1859template <
typename R>
1865template <
typename R, R* =
nullptr>
1871template <
typename R>
1882template <
typename R>
1890template <
typename T>
1898template <
typename T>
1900 std::initializer_list<T> vals) {
1911template <
size_t N,
typename T>
1913 return {std::move(value)};
1917template <
size_t N,
typename T>
1919 return {std::move(value)};
1923template <
typename T1,
typename T2>
1928#if !GTEST_OS_WINDOWS_MOBILE
1931template <
typename T>
1933 int errval, T result) {
1946template <
typename FunctionImpl>
1947typename std::decay<FunctionImpl>::type
Invoke(FunctionImpl&& function_impl) {
1948 return std::forward<FunctionImpl>(function_impl);
1947typename std::decay<FunctionImpl>::type
Invoke(FunctionImpl&& function_impl) {
…}
1953template <
class Class,
typename MethodPtr>
1955 MethodPtr method_ptr) {
1956 return {obj_ptr, method_ptr};
1960template <
typename FunctionImpl>
1961internal::InvokeWithoutArgsAction<typename std::decay<FunctionImpl>::type>
1963 return {std::move(function_impl)};
1968template <
class Class,
typename MethodPtr>
1970 Class* obj_ptr, MethodPtr method_ptr) {
1971 return {obj_ptr, method_ptr};
1977template <
typename A>
1992template <
typename T>
1993inline ::std::reference_wrapper<T>
ByRef(T& l_value) {
1994 return ::std::reference_wrapper<T>(l_value);
1993inline ::std::reference_wrapper<T>
ByRef(T& l_value) { {
…}
2000template <
typename T,
typename... Params>
2002 Params&&... params) {
2003 return {std::forward_as_tuple(std::forward<Params>(params)...)};
2014template <
size_t k,
typename Ptr>
2021template <
size_t k,
typename Ptr>
2028template <
size_t k,
typename T>
2031 return {std::forward<T>(value)};
2039template <
size_t k,
typename I1,
typename I2>
2042 return {first, last};
2053template <
typename Ptr>
2060#if GTEST_HAS_EXCEPTIONS
2061template <
typename T>
2062internal::ThrowAction<typename std::decay<T>::type> Throw(T&& exception) {
2063 return {std::forward<T>(exception)};
2087template <
typename F,
typename Impl>
2090template <
typename Impl>
2094 explicit operator const Impl&()
const {
return *
ptr; }
2097 using type =
typename std::conditional<std::is_constructible<Impl>::value,
2101template <
typename R,
typename... Args,
typename Impl>
2111 static constexpr size_t kMaxArgs =
2112 sizeof...(Args) <= 10 ?
sizeof...(Args) : 10;
2113 return Apply(MakeIndexSequence<kMaxArgs>{},
2114 MakeIndexSequence<10 - kMaxArgs>{},
2118 template <std::size_t... arg_id, std::size_t... excess_id>
2119 R
Apply(IndexSequence<arg_id...>, IndexSequence<excess_id...>,
2127 return static_cast<const Impl&
>(*this)
2128 .template gmock_PerformImpl<
2132 typename std::tuple_element<arg_id, args_type>::type...>(
2133 args, std::get<arg_id>(args)...,
2134 ((void)excess_id, kExcessArg)...);
2119 R
Apply(IndexSequence<arg_id...>, IndexSequence<excess_id...>, {
…}
2140template <
typename F,
typename Impl>
2146template <
typename F,
typename Impl>
2151#define GMOCK_INTERNAL_ARG_UNUSED(i, data, el) \
2152 , const arg##i##_type& arg##i GTEST_ATTRIBUTE_UNUSED_
2151#define GMOCK_INTERNAL_ARG_UNUSED(i, data, el) \ …
2153#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_ \
2154 const args_type& args GTEST_ATTRIBUTE_UNUSED_ GMOCK_PP_REPEAT( \
2155 GMOCK_INTERNAL_ARG_UNUSED, , 10)
2153#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_ \ …
2157#define GMOCK_INTERNAL_ARG(i, data, el) , const arg##i##_type& arg##i
2158#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_ \
2159 const args_type& args GMOCK_PP_REPEAT(GMOCK_INTERNAL_ARG, , 10)
2158#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_ \ …
2161#define GMOCK_INTERNAL_TEMPLATE_ARG(i, data, el) , typename arg##i##_type
2162#define GMOCK_ACTION_TEMPLATE_ARGS_NAMES_ \
2163 GMOCK_PP_TAIL(GMOCK_PP_REPEAT(GMOCK_INTERNAL_TEMPLATE_ARG, , 10))
2162#define GMOCK_ACTION_TEMPLATE_ARGS_NAMES_ \ …
2165#define GMOCK_INTERNAL_TYPENAME_PARAM(i, data, param) , typename param##_type
2166#define GMOCK_ACTION_TYPENAME_PARAMS_(params) \
2167 GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_TYPENAME_PARAM, , params))
2166#define GMOCK_ACTION_TYPENAME_PARAMS_(params) \ …
2169#define GMOCK_INTERNAL_TYPE_PARAM(i, data, param) , param##_type
2170#define GMOCK_ACTION_TYPE_PARAMS_(params) \
2171 GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_TYPE_PARAM, , params))
2170#define GMOCK_ACTION_TYPE_PARAMS_(params) \ …
2173#define GMOCK_INTERNAL_TYPE_GVALUE_PARAM(i, data, param) \
2174 , param##_type gmock_p##i
2173#define GMOCK_INTERNAL_TYPE_GVALUE_PARAM(i, data, param) \ …
2175#define GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params) \
2176 GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_TYPE_GVALUE_PARAM, , params))
2175#define GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params) \ …
2178#define GMOCK_INTERNAL_GVALUE_PARAM(i, data, param) \
2179 , std::forward<param##_type>(gmock_p##i)
2178#define GMOCK_INTERNAL_GVALUE_PARAM(i, data, param) \ …
2180#define GMOCK_ACTION_GVALUE_PARAMS_(params) \
2181 GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_GVALUE_PARAM, , params))
2180#define GMOCK_ACTION_GVALUE_PARAMS_(params) \ …
2183#define GMOCK_INTERNAL_INIT_PARAM(i, data, param) \
2184 , param(::std::forward<param##_type>(gmock_p##i))
2183#define GMOCK_INTERNAL_INIT_PARAM(i, data, param) \ …
2185#define GMOCK_ACTION_INIT_PARAMS_(params) \
2186 GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_INIT_PARAM, , params))
2185#define GMOCK_ACTION_INIT_PARAMS_(params) \ …
2188#define GMOCK_INTERNAL_FIELD_PARAM(i, data, param) param##_type param;
2189#define GMOCK_ACTION_FIELD_PARAMS_(params) \
2190 GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_FIELD_PARAM, , params)
2189#define GMOCK_ACTION_FIELD_PARAMS_(params) \ …
2192#define GMOCK_INTERNAL_ACTION(name, full_name, params) \
2193 template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
2196 explicit full_name(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) \
2197 : impl_(std::make_shared<gmock_Impl>( \
2198 GMOCK_ACTION_GVALUE_PARAMS_(params))) {} \
2199 full_name(const full_name&) = default; \
2200 full_name(full_name&&) noexcept = default; \
2201 template <typename F> \
2202 operator ::testing::Action<F>() const { \
2203 return ::testing::internal::MakeAction<F>(impl_); \
2207 class gmock_Impl { \
2209 explicit gmock_Impl(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) \
2210 : GMOCK_ACTION_INIT_PARAMS_(params) {} \
2211 template <typename function_type, typename return_type, \
2212 typename args_type, GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
2213 return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \
2214 GMOCK_ACTION_FIELD_PARAMS_(params) \
2216 std::shared_ptr<const gmock_Impl> impl_; \
2218 template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
2219 inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \
2220 GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) GTEST_MUST_USE_RESULT_; \
2221 template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
2222 inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \
2223 GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) { \
2224 return full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>( \
2225 GMOCK_ACTION_GVALUE_PARAMS_(params)); \
2227 template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
2228 template <typename function_type, typename return_type, typename args_type, \
2229 GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
2231 full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>::gmock_Impl::gmock_PerformImpl( \
2232 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
2192#define GMOCK_INTERNAL_ACTION(name, full_name, params) \ …
2237#define ACTION(name) \
2238 class name##Action { \
2240 explicit name##Action() noexcept {} \
2241 name##Action(const name##Action&) noexcept {} \
2242 template <typename F> \
2243 operator ::testing::Action<F>() const { \
2244 return ::testing::internal::MakeAction<F, gmock_Impl>(); \
2248 class gmock_Impl { \
2250 template <typename function_type, typename return_type, \
2251 typename args_type, GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
2252 return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \
2255 inline name##Action name() GTEST_MUST_USE_RESULT_; \
2256 inline name##Action name() { return name##Action(); } \
2257 template <typename function_type, typename return_type, typename args_type, \
2258 GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
2259 return_type name##Action::gmock_Impl::gmock_PerformImpl( \
2260 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
2237#define ACTION(name) \ …
2262#define ACTION_P(name, ...) \
2263 GMOCK_INTERNAL_ACTION(name, name##ActionP, (__VA_ARGS__))
2262#define ACTION_P(name, ...) \ …
2265#define ACTION_P2(name, ...) \
2266 GMOCK_INTERNAL_ACTION(name, name##ActionP2, (__VA_ARGS__))
2265#define ACTION_P2(name, ...) \ …
2268#define ACTION_P3(name, ...) \
2269 GMOCK_INTERNAL_ACTION(name, name##ActionP3, (__VA_ARGS__))
2268#define ACTION_P3(name, ...) \ …
2271#define ACTION_P4(name, ...) \
2272 GMOCK_INTERNAL_ACTION(name, name##ActionP4, (__VA_ARGS__))
2271#define ACTION_P4(name, ...) \ …
2274#define ACTION_P5(name, ...) \
2275 GMOCK_INTERNAL_ACTION(name, name##ActionP5, (__VA_ARGS__))
2274#define ACTION_P5(name, ...) \ …
2277#define ACTION_P6(name, ...) \
2278 GMOCK_INTERNAL_ACTION(name, name##ActionP6, (__VA_ARGS__))
2277#define ACTION_P6(name, ...) \ …
2280#define ACTION_P7(name, ...) \
2281 GMOCK_INTERNAL_ACTION(name, name##ActionP7, (__VA_ARGS__))
2280#define ACTION_P7(name, ...) \ …
2283#define ACTION_P8(name, ...) \
2284 GMOCK_INTERNAL_ACTION(name, name##ActionP8, (__VA_ARGS__))
2283#define ACTION_P8(name, ...) \ …
2286#define ACTION_P9(name, ...) \
2287 GMOCK_INTERNAL_ACTION(name, name##ActionP9, (__VA_ARGS__))
2286#define ACTION_P9(name, ...) \ …
2289#define ACTION_P10(name, ...) \
2290 GMOCK_INTERNAL_ACTION(name, name##ActionP10, (__VA_ARGS__))
2289#define ACTION_P10(name, ...) \ …
Action(const Action< Func > &action)
Result Perform(ArgumentTuple args) const
internal::Function< F >::ArgumentTuple ArgumentTuple
internal::Function< F >::Result Result
Action(ActionInterface< F > *impl)
virtual Result Perform(const ArgumentTuple &args)=0
internal::Function< F >::Result Result
virtual ~ActionInterface()
internal::Function< F >::ArgumentTuple ArgumentTuple
static void SetFactory(FactoryFunction factory)
OnceAction(OnceAction &&)=default
Result Call(Args... args) &&
OnceAction(const OnceAction &)=delete
OnceAction & operator=(const OnceAction &)=delete
OnceAction(Callable &&callable)
PolymorphicAction(const Impl &impl)
void Perform(const ArgumentTuple &) const
AssignAction(T1 *ptr, T2 value)
DoAllAction(UserConstructorTag, T &&action)
DoAllAction(UserConstructorTag, T &&initial_action, U &&... other_actions)
IgnoreResultAction(const A &action)
ReturnAction(ByMoveWrapper< T > wrapper)
static Result Perform(const ArgumentTuple &)
ReturnRefOfCopyAction(const T &value)
T operator()(Args &&...) const
ReturnRoundRobinAction(std::vector< T > values)
static void Perform(const ArgumentTuple &)
Result Perform(const ArgumentTuple &) const
SetErrnoAndReturnAction(int errno_value, T result)
decltype(std::declval< F >()(std::declval< Args >()...)) call_result_t
auto Apply(F &&f, Tuple &&args) -> decltype(ApplyImpl(std::forward< F >(f), std::forward< Tuple >(args), MakeIndexSequence< std::tuple_size< typename std::remove_reference< Tuple >::type >::value >()))
::testing::Action< F > MakeAction()
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void,)
void Assert(bool condition, const char *file, int line, const std::string &msg)
GTEST_API_ void IllegalDoDefault(const char *file, int line)
std::add_const< T >::type & as_const(T &t)
internal::DeleteArgAction< k > DeleteArg()
internal::WithArgsAction< typename std::decay< InnerAction >::type > WithoutArgs(InnerAction &&action)
internal::SaveArgAction< k, Ptr > SaveArg(Ptr pointer)
internal::ReturnRoundRobinAction< T > ReturnRoundRobin(std::vector< T > vals)
internal::SaveArgPointeeAction< k, Ptr > SaveArgPointee(Ptr pointer)
internal::IgnoreResultAction< A > IgnoreResult(const A &an_action)
internal::SetArrayArgumentAction< k, I1, I2 > SetArrayArgument(I1 first, I2 last)
internal::SetArgRefereeAction< k, typename std::decay< T >::type > SetArgReferee(T &&value)
internal::ReturnPointeeAction< Ptr > ReturnPointee(Ptr pointer)
inline ::std::reference_wrapper< T > ByRef(T &l_value)
internal::DoAllAction< typename std::decay< Action >::type... > DoAll(Action &&... action)
internal::ByMoveWrapper< R > ByMove(R x)
PolymorphicAction< Impl > MakePolymorphicAction(const Impl &impl)
PolymorphicAction< internal::ReturnVoidAction > Return()
internal::WithArgsAction< typename std::decay< InnerAction >::type, k, ks... > WithArgs(InnerAction &&action)
internal::IgnoredValue Unused
PolymorphicAction< internal::AssignAction< T1, T2 > > Assign(T1 *ptr, T2 val)
internal::SetArgumentPointeeAction< N, T > SetArgPointee(T value)
PolymorphicAction< internal::SetErrnoAndReturnAction< T > > SetErrnoAndReturn(int errval, T result)
Action< F > MakeAction(ActionInterface< F > *impl)
internal::InvokeWithoutArgsAction< typename std::decay< FunctionImpl >::type > InvokeWithoutArgs(FunctionImpl function_impl)
internal::ReturnArgAction< k > ReturnArg()
internal::WithArgsAction< typename std::decay< InnerAction >::type, k > WithArg(InnerAction &&action)
internal::ReturnRefOfCopyAction< R > ReturnRefOfCopy(const R &x)
internal::ReturnRefAction< R > ReturnRef(R &x)
internal::SetArgumentPointeeAction< N, T > SetArgumentPointee(T value)
internal::ReturnNewAction< T, typename std::decay< Params >::type... > ReturnNew(Params &&... params)
internal::DoDefaultAction DoDefault()
PolymorphicAction< internal::ReturnNullAction > ReturnNull()
std::decay< FunctionImpl >::type Invoke(FunctionImpl &&function_impl)
std::tuple< Args... > args_type
typename ImplBase< Impl >::type Base
R operator()(Args &&... arg) const
R Apply(IndexSequence< arg_id... >, IndexSequence< excess_id... >, const args_type &args) const
ActionImpl(std::shared_ptr< Impl > impl)
void operator()(const Args &... args) const
std::shared_ptr< Impl > ptr
typename std::conditional< std::is_constructible< Impl >::value, Impl, Holder >::type type
auto operator()(Args &&... args) const -> decltype((obj_ptr-> *method_ptr)(std::forward< Args >(args)...))
const MethodPtr method_ptr
ReturnType operator()(const Args &...) const
decltype((std::declval< Class * >() -> *std::declval< MethodPtr >())()) ReturnType
const MethodPtr method_ptr
FunctionImpl function_impl
auto operator()(const Args &...) -> decltype(function_impl())
auto operator()(Args &&... args) const -> decltype(std::get< k >(std::forward_as_tuple(std::forward< Args >(args)...)))
std::tuple< Params... > params
auto operator()(const Args &...) const -> decltype(*pointer)
void operator()(const Args &... args) const
void operator()(const Args &... args) const
void operator()(Args &&... args) const
void operator()(const Args &... args) const
void operator()(const Args &... args) const
R(typename std::tuple_element< I, std::tuple< Args... > >::type...) InnerSignature
decltype(TestImplicitConversion< From >(0)) type