aboutsummaryrefslogtreecommitdiffstats
path: root/googlemock/include/gmock/gmock-actions.h
diff options
context:
space:
mode:
Diffstat (limited to 'googlemock/include/gmock/gmock-actions.h')
-rw-r--r--googlemock/include/gmock/gmock-actions.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index c08d97b9..4b8dcebb 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -1184,6 +1184,46 @@ inline ::std::reference_wrapper<T> ByRef(T& l_value) { // NOLINT
return ::std::reference_wrapper<T>(l_value);
}
+namespace internal {
+
+// A macro from the ACTION* family (defined later in gmock-generated-actions.h)
+// defines an action that can be used in a mock function. Typically,
+// these actions only care about a subset of the arguments of the mock
+// function. For example, if such an action only uses the second
+// argument, it can be used in any mock function that takes >= 2
+// arguments where the type of the second argument is compatible.
+//
+// Therefore, the action implementation must be prepared to take more
+// arguments than it needs. The ExcessiveArg type is used to
+// represent those excessive arguments. In order to keep the compiler
+// error messages tractable, we define it in the testing namespace
+// instead of testing::internal. However, this is an INTERNAL TYPE
+// and subject to change without notice, so a user MUST NOT USE THIS
+// TYPE DIRECTLY.
+struct ExcessiveArg {};
+
+// A helper class needed for implementing the ACTION* macros.
+template <typename Result, class Impl>
+class ActionHelper {
+ public:
+ template <typename... Ts>
+ static Result Perform(Impl* impl, const std::tuple<Ts...>& args) {
+ return Apply(impl, args, MakeIndexSequence<sizeof...(Ts)>{},
+ MakeIndexSequence<10 - sizeof...(Ts)>{});
+ }
+
+ private:
+ template <typename... Ts, std::size_t... tuple_ids, std::size_t... rest_ids>
+ static Result Apply(Impl* impl, const std::tuple<Ts...>& args,
+ IndexSequence<tuple_ids...>, IndexSequence<rest_ids...>) {
+ return impl->template gmock_PerformImpl<Ts...>(
+ args, std::get<tuple_ids>(args)...,
+ ((void)rest_ids, ExcessiveArg())...);
+ }
+};
+
+} // namespace internal
+
} // namespace testing
#ifdef _MSC_VER