• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2007, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 //     * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 //     * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 //     * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 // Google Mock - a framework for writing C++ mock classes.
31 //
32 // This file implements MOCK_METHOD.
33 
34 // IWYU pragma: private, include "gmock/gmock.h"
35 // IWYU pragma: friend gmock/.*
36 
37 #ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_
38 #define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_
39 
40 #include <type_traits>  // IWYU pragma: keep
41 #include <utility>      // IWYU pragma: keep
42 
43 #include "gmock/gmock-spec-builders.h"
44 #include "gmock/internal/gmock-internal-utils.h"
45 #include "gmock/internal/gmock-pp.h"
46 
47 namespace testing {
48 namespace internal {
49 template <typename T>
50 using identity_t = T;
51 
52 template <typename Pattern>
53 struct ThisRefAdjuster {
54   template <typename T>
55   using AdjustT = typename std::conditional<
56       std::is_const<typename std::remove_reference<Pattern>::type>::value,
57       typename std::conditional<std::is_lvalue_reference<Pattern>::value,
58                                 const T&, const T&&>::type,
59       typename std::conditional<std::is_lvalue_reference<Pattern>::value, T&,
60                                 T&&>::type>::type;
61 
62   template <typename MockType>
AdjustThisRefAdjuster63   static AdjustT<MockType> Adjust(const MockType& mock) {
64     return static_cast<AdjustT<MockType>>(const_cast<MockType&>(mock));
65   }
66 };
67 
PrefixOf(const char * a,const char * b)68 constexpr bool PrefixOf(const char* a, const char* b) {
69   return *a == 0 || (*a == *b && internal::PrefixOf(a + 1, b + 1));
70 }
71 
72 template <int N, int M>
StartsWith(const char (& prefix)[N],const char (& str)[M])73 constexpr bool StartsWith(const char (&prefix)[N], const char (&str)[M]) {
74   return N <= M && internal::PrefixOf(prefix, str);
75 }
76 
77 template <int N, int M>
EndsWith(const char (& suffix)[N],const char (& str)[M])78 constexpr bool EndsWith(const char (&suffix)[N], const char (&str)[M]) {
79   return N <= M && internal::PrefixOf(suffix, str + M - N);
80 }
81 
82 template <int N, int M>
Equals(const char (& a)[N],const char (& b)[M])83 constexpr bool Equals(const char (&a)[N], const char (&b)[M]) {
84   return N == M && internal::PrefixOf(a, b);
85 }
86 
87 template <int N>
ValidateSpec(const char (& spec)[N])88 constexpr bool ValidateSpec(const char (&spec)[N]) {
89   return internal::Equals("const", spec) ||
90          internal::Equals("override", spec) ||
91          internal::Equals("final", spec) ||
92          internal::Equals("noexcept", spec) ||
93          (internal::StartsWith("noexcept(", spec) &&
94           internal::EndsWith(")", spec)) ||
95          internal::Equals("ref(&)", spec) ||
96          internal::Equals("ref(&&)", spec) ||
97          (internal::StartsWith("Calltype(", spec) &&
98           internal::EndsWith(")", spec));
99 }
100 
101 }  // namespace internal
102 
103 // The style guide prohibits "using" statements in a namespace scope
104 // inside a header file.  However, the FunctionMocker class template
105 // is meant to be defined in the ::testing namespace.  The following
106 // line is just a trick for working around a bug in MSVC 8.0, which
107 // cannot handle it if we define FunctionMocker in ::testing.
108 using internal::FunctionMocker;
109 }  // namespace testing
110 
111 #define MOCK_METHOD(...)                                               \
112   GMOCK_INTERNAL_WARNING_PUSH()                                        \
113   GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function")    \
114   GMOCK_PP_VARIADIC_CALL(GMOCK_INTERNAL_MOCK_METHOD_ARG_, __VA_ARGS__) \
115   GMOCK_INTERNAL_WARNING_POP()
116 
117 #define GMOCK_INTERNAL_MOCK_METHOD_ARG_1(...) \
118   GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__)
119 
120 #define GMOCK_INTERNAL_MOCK_METHOD_ARG_2(...) \
121   GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__)
122 
123 #define GMOCK_INTERNAL_MOCK_METHOD_ARG_3(_Ret, _MethodName, _Args) \
124   GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, ())
125 
126 #define GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, _Spec)  \
127   GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Args);                                \
128   GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Spec);                                \
129   GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE(                                   \
130       GMOCK_PP_NARG0 _Args, GMOCK_INTERNAL_SIGNATURE(_Ret, _Args));        \
131   GMOCK_INTERNAL_ASSERT_VALID_SPEC(_Spec)                                  \
132   GMOCK_INTERNAL_MOCK_METHOD_IMPL(                                         \
133       GMOCK_PP_NARG0 _Args, _MethodName, GMOCK_INTERNAL_HAS_CONST(_Spec),  \
134       GMOCK_INTERNAL_HAS_OVERRIDE(_Spec), GMOCK_INTERNAL_HAS_FINAL(_Spec), \
135       GMOCK_INTERNAL_GET_NOEXCEPT_SPEC(_Spec),                             \
136       GMOCK_INTERNAL_GET_CALLTYPE_SPEC(_Spec),                             \
137       GMOCK_INTERNAL_GET_REF_SPEC(_Spec),                                  \
138       (GMOCK_INTERNAL_SIGNATURE(_Ret, _Args)))
139 
140 #define GMOCK_INTERNAL_MOCK_METHOD_ARG_5(...) \
141   GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__)
142 
143 #define GMOCK_INTERNAL_MOCK_METHOD_ARG_6(...) \
144   GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__)
145 
146 #define GMOCK_INTERNAL_MOCK_METHOD_ARG_7(...) \
147   GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__)
148 
149 #define GMOCK_INTERNAL_WRONG_ARITY(...)                                      \
150   static_assert(                                                             \
151       false,                                                                 \
152       "MOCK_METHOD must be called with 3 or 4 arguments. _Ret, "             \
153       "_MethodName, _Args and optionally _Spec. _Args and _Spec must be "    \
154       "enclosed in parentheses. If _Ret is a type with unprotected commas, " \
155       "it must also be enclosed in parentheses.")
156 
157 #define GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Tuple) \
158   static_assert(                                  \
159       GMOCK_PP_IS_ENCLOSED_PARENS(_Tuple),        \
160       GMOCK_PP_STRINGIZE(_Tuple) " should be enclosed in parentheses.")
161 
162 #define GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE(_N, ...)                 \
163   static_assert(                                                       \
164       std::is_function<__VA_ARGS__>::value,                            \
165       "Signature must be a function type, maybe return type contains " \
166       "unprotected comma.");                                           \
167   static_assert(                                                       \
168       ::testing::tuple_size<typename ::testing::internal::Function<    \
169               __VA_ARGS__>::ArgumentTuple>::value == _N,               \
170       "This method does not take " GMOCK_PP_STRINGIZE(                 \
171           _N) " arguments. Parenthesize all types with unprotected commas.")
172 
173 #define GMOCK_INTERNAL_ASSERT_VALID_SPEC(_Spec) \
174   GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT, ~, _Spec)
175 
176 #define GMOCK_INTERNAL_MOCK_METHOD_IMPL(_N, _MethodName, _Constness,           \
177                                         _Override, _Final, _NoexceptSpec,      \
178                                         _CallType, _RefSpec, _Signature)       \
179   typename ::testing::internal::Function<GMOCK_PP_REMOVE_PARENS(               \
180       _Signature)>::Result                                                     \
181   GMOCK_INTERNAL_EXPAND(_CallType)                                             \
182       _MethodName(GMOCK_PP_REPEAT(GMOCK_INTERNAL_PARAMETER, _Signature, _N))   \
183           GMOCK_PP_IF(_Constness, const, ) _RefSpec _NoexceptSpec              \
184           GMOCK_PP_IF(_Override, override, ) GMOCK_PP_IF(_Final, final, ) {    \
185     GMOCK_MOCKER_(_N, _Constness, _MethodName)                                 \
186         .SetOwnerAndName(this, #_MethodName);                                  \
187     return GMOCK_MOCKER_(_N, _Constness, _MethodName)                          \
188         .Invoke(GMOCK_PP_REPEAT(GMOCK_INTERNAL_FORWARD_ARG, _Signature, _N));  \
189   }                                                                            \
190   ::testing::MockSpec<GMOCK_PP_REMOVE_PARENS(_Signature)> gmock_##_MethodName( \
191       GMOCK_PP_REPEAT(GMOCK_INTERNAL_MATCHER_PARAMETER, _Signature, _N))       \
192       GMOCK_PP_IF(_Constness, const, ) _RefSpec {                              \
193     GMOCK_MOCKER_(_N, _Constness, _MethodName).RegisterOwner(this);            \
194     return GMOCK_MOCKER_(_N, _Constness, _MethodName)                          \
195         .With(GMOCK_PP_REPEAT(GMOCK_INTERNAL_MATCHER_ARGUMENT, , _N));         \
196   }                                                                            \
197   ::testing::MockSpec<GMOCK_PP_REMOVE_PARENS(_Signature)> gmock_##_MethodName( \
198       const ::testing::internal::WithoutMatchers&,                             \
199       GMOCK_PP_IF(_Constness, const, )::testing::internal::Function<           \
200           GMOCK_PP_REMOVE_PARENS(_Signature)>*) const _RefSpec _NoexceptSpec { \
201     return ::testing::internal::ThisRefAdjuster<GMOCK_PP_IF(                   \
202         _Constness, const, ) int _RefSpec>::Adjust(*this)                      \
203         .gmock_##_MethodName(GMOCK_PP_REPEAT(                                  \
204             GMOCK_INTERNAL_A_MATCHER_ARGUMENT, _Signature, _N));               \
205   }                                                                            \
206   mutable ::testing::FunctionMocker<GMOCK_PP_REMOVE_PARENS(_Signature)>        \
207   GMOCK_MOCKER_(_N, _Constness, _MethodName)
208 
209 #define GMOCK_INTERNAL_EXPAND(...) __VA_ARGS__
210 
211 // Valid modifiers.
212 #define GMOCK_INTERNAL_HAS_CONST(_Tuple) \
213   GMOCK_PP_HAS_COMMA(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_CONST, ~, _Tuple))
214 
215 #define GMOCK_INTERNAL_HAS_OVERRIDE(_Tuple) \
216   GMOCK_PP_HAS_COMMA(                       \
217       GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_OVERRIDE, ~, _Tuple))
218 
219 #define GMOCK_INTERNAL_HAS_FINAL(_Tuple) \
220   GMOCK_PP_HAS_COMMA(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_FINAL, ~, _Tuple))
221 
222 #define GMOCK_INTERNAL_GET_NOEXCEPT_SPEC(_Tuple) \
223   GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_NOEXCEPT_SPEC_IF_NOEXCEPT, ~, _Tuple)
224 
225 #define GMOCK_INTERNAL_NOEXCEPT_SPEC_IF_NOEXCEPT(_i, _, _elem)          \
226   GMOCK_PP_IF(                                                          \
227       GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem)), \
228       _elem, )
229 
230 #define GMOCK_INTERNAL_GET_CALLTYPE_SPEC(_Tuple) \
231   GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_CALLTYPE_SPEC_IF_CALLTYPE, ~, _Tuple)
232 
233 #define GMOCK_INTERNAL_CALLTYPE_SPEC_IF_CALLTYPE(_i, _, _elem)          \
234   GMOCK_PP_IF(                                                          \
235       GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_CALLTYPE(_i, _, _elem)), \
236       GMOCK_PP_CAT(GMOCK_INTERNAL_UNPACK_, _elem), )
237 
238 #define GMOCK_INTERNAL_GET_REF_SPEC(_Tuple) \
239   GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_REF_SPEC_IF_REF, ~, _Tuple)
240 
241 #define GMOCK_INTERNAL_REF_SPEC_IF_REF(_i, _, _elem)                       \
242   GMOCK_PP_IF(GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_REF(_i, _, _elem)), \
243               GMOCK_PP_CAT(GMOCK_INTERNAL_UNPACK_, _elem), )
244 
245 #ifdef GMOCK_INTERNAL_STRICT_SPEC_ASSERT
246 #define GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT(_i, _, _elem) \
247   static_assert(                                                     \
248       ::testing::internal::ValidateSpec(GMOCK_PP_STRINGIZE(_elem)),  \
249       "Token \'" GMOCK_PP_STRINGIZE(                                 \
250           _elem) "\' cannot be recognized as a valid specification " \
251                  "modifier. Is a ',' missing?");
252 #else
253 #define GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT(_i, _, _elem)                 \
254   static_assert(                                                               \
255       (GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_CONST(_i, _, _elem)) +         \
256        GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_OVERRIDE(_i, _, _elem)) +      \
257        GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_FINAL(_i, _, _elem)) +         \
258        GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem)) +      \
259        GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_REF(_i, _, _elem)) +           \
260        GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_CALLTYPE(_i, _, _elem))) == 1, \
261       GMOCK_PP_STRINGIZE(                                                      \
262           _elem) " cannot be recognized as a valid specification modifier.");
263 #endif  // GMOCK_INTERNAL_STRICT_SPEC_ASSERT
264 
265 // Modifiers implementation.
266 #define GMOCK_INTERNAL_DETECT_CONST(_i, _, _elem) \
267   GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_CONST_I_, _elem)
268 
269 #define GMOCK_INTERNAL_DETECT_CONST_I_const ,
270 
271 #define GMOCK_INTERNAL_DETECT_OVERRIDE(_i, _, _elem) \
272   GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_OVERRIDE_I_, _elem)
273 
274 #define GMOCK_INTERNAL_DETECT_OVERRIDE_I_override ,
275 
276 #define GMOCK_INTERNAL_DETECT_FINAL(_i, _, _elem) \
277   GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_FINAL_I_, _elem)
278 
279 #define GMOCK_INTERNAL_DETECT_FINAL_I_final ,
280 
281 #define GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem) \
282   GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_NOEXCEPT_I_, _elem)
283 
284 #define GMOCK_INTERNAL_DETECT_NOEXCEPT_I_noexcept ,
285 
286 #define GMOCK_INTERNAL_DETECT_REF(_i, _, _elem) \
287   GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_REF_I_, _elem)
288 
289 #define GMOCK_INTERNAL_DETECT_REF_I_ref ,
290 
291 #define GMOCK_INTERNAL_UNPACK_ref(x) x
292 
293 #define GMOCK_INTERNAL_DETECT_CALLTYPE(_i, _, _elem) \
294   GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_CALLTYPE_I_, _elem)
295 
296 #define GMOCK_INTERNAL_DETECT_CALLTYPE_I_Calltype ,
297 
298 #define GMOCK_INTERNAL_UNPACK_Calltype(...) __VA_ARGS__
299 
300 // Note: The use of `identity_t` here allows _Ret to represent return types that
301 // would normally need to be specified in a different way. For example, a method
302 // returning a function pointer must be written as
303 //
304 // fn_ptr_return_t (*method(method_args_t...))(fn_ptr_args_t...)
305 //
306 // But we only support placing the return type at the beginning. To handle this,
307 // we wrap all calls in identity_t, so that a declaration will be expanded to
308 //
309 // identity_t<fn_ptr_return_t (*)(fn_ptr_args_t...)> method(method_args_t...)
310 //
311 // This allows us to work around the syntactic oddities of function/method
312 // types.
313 #define GMOCK_INTERNAL_SIGNATURE(_Ret, _Args)                                 \
314   ::testing::internal::identity_t<GMOCK_PP_IF(GMOCK_PP_IS_BEGIN_PARENS(_Ret), \
315                                               GMOCK_PP_REMOVE_PARENS,         \
316                                               GMOCK_PP_IDENTITY)(_Ret)>(      \
317       GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_GET_TYPE, _, _Args))
318 
319 #define GMOCK_INTERNAL_GET_TYPE(_i, _, _elem)                          \
320   GMOCK_PP_COMMA_IF(_i)                                                \
321   GMOCK_PP_IF(GMOCK_PP_IS_BEGIN_PARENS(_elem), GMOCK_PP_REMOVE_PARENS, \
322               GMOCK_PP_IDENTITY)                                       \
323   (_elem)
324 
325 #define GMOCK_INTERNAL_PARAMETER(_i, _Signature, _)            \
326   GMOCK_PP_COMMA_IF(_i)                                        \
327   GMOCK_INTERNAL_ARG_O(_i, GMOCK_PP_REMOVE_PARENS(_Signature)) \
328   gmock_a##_i
329 
330 #define GMOCK_INTERNAL_FORWARD_ARG(_i, _Signature, _) \
331   GMOCK_PP_COMMA_IF(_i)                               \
332   ::std::forward<GMOCK_INTERNAL_ARG_O(                \
333       _i, GMOCK_PP_REMOVE_PARENS(_Signature))>(gmock_a##_i)
334 
335 #define GMOCK_INTERNAL_MATCHER_PARAMETER(_i, _Signature, _)        \
336   GMOCK_PP_COMMA_IF(_i)                                            \
337   GMOCK_INTERNAL_MATCHER_O(_i, GMOCK_PP_REMOVE_PARENS(_Signature)) \
338   gmock_a##_i
339 
340 #define GMOCK_INTERNAL_MATCHER_ARGUMENT(_i, _1, _2) \
341   GMOCK_PP_COMMA_IF(_i)                             \
342   gmock_a##_i
343 
344 #define GMOCK_INTERNAL_A_MATCHER_ARGUMENT(_i, _Signature, _) \
345   GMOCK_PP_COMMA_IF(_i)                                      \
346   ::testing::A<GMOCK_INTERNAL_ARG_O(_i, GMOCK_PP_REMOVE_PARENS(_Signature))>()
347 
348 #define GMOCK_INTERNAL_ARG_O(_i, ...) \
349   typename ::testing::internal::Function<__VA_ARGS__>::template Arg<_i>::type
350 
351 #define GMOCK_INTERNAL_MATCHER_O(_i, ...)                          \
352   const ::testing::Matcher<typename ::testing::internal::Function< \
353       __VA_ARGS__>::template Arg<_i>::type>&
354 
355 #define MOCK_METHOD0(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 0, __VA_ARGS__)
356 #define MOCK_METHOD1(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 1, __VA_ARGS__)
357 #define MOCK_METHOD2(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 2, __VA_ARGS__)
358 #define MOCK_METHOD3(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 3, __VA_ARGS__)
359 #define MOCK_METHOD4(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 4, __VA_ARGS__)
360 #define MOCK_METHOD5(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 5, __VA_ARGS__)
361 #define MOCK_METHOD6(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 6, __VA_ARGS__)
362 #define MOCK_METHOD7(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 7, __VA_ARGS__)
363 #define MOCK_METHOD8(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 8, __VA_ARGS__)
364 #define MOCK_METHOD9(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 9, __VA_ARGS__)
365 #define MOCK_METHOD10(m, ...) \
366   GMOCK_INTERNAL_MOCK_METHODN(, , m, 10, __VA_ARGS__)
367 #define MOCK_METHOD11(m, ...) \
368   GMOCK_INTERNAL_MOCK_METHODN(, , m, 11, __VA_ARGS__)
369 
370 #define MOCK_CONST_METHOD0(m, ...) \
371   GMOCK_INTERNAL_MOCK_METHODN(const, , m, 0, __VA_ARGS__)
372 #define MOCK_CONST_METHOD1(m, ...) \
373   GMOCK_INTERNAL_MOCK_METHODN(const, , m, 1, __VA_ARGS__)
374 #define MOCK_CONST_METHOD2(m, ...) \
375   GMOCK_INTERNAL_MOCK_METHODN(const, , m, 2, __VA_ARGS__)
376 #define MOCK_CONST_METHOD3(m, ...) \
377   GMOCK_INTERNAL_MOCK_METHODN(const, , m, 3, __VA_ARGS__)
378 #define MOCK_CONST_METHOD4(m, ...) \
379   GMOCK_INTERNAL_MOCK_METHODN(const, , m, 4, __VA_ARGS__)
380 #define MOCK_CONST_METHOD5(m, ...) \
381   GMOCK_INTERNAL_MOCK_METHODN(const, , m, 5, __VA_ARGS__)
382 #define MOCK_CONST_METHOD6(m, ...) \
383   GMOCK_INTERNAL_MOCK_METHODN(const, , m, 6, __VA_ARGS__)
384 #define MOCK_CONST_METHOD7(m, ...) \
385   GMOCK_INTERNAL_MOCK_METHODN(const, , m, 7, __VA_ARGS__)
386 #define MOCK_CONST_METHOD8(m, ...) \
387   GMOCK_INTERNAL_MOCK_METHODN(const, , m, 8, __VA_ARGS__)
388 #define MOCK_CONST_METHOD9(m, ...) \
389   GMOCK_INTERNAL_MOCK_METHODN(const, , m, 9, __VA_ARGS__)
390 #define MOCK_CONST_METHOD10(m, ...) \
391   GMOCK_INTERNAL_MOCK_METHODN(const, , m, 10, __VA_ARGS__)
392 
393 #define MOCK_METHOD0_T(m, ...) MOCK_METHOD0(m, __VA_ARGS__)
394 #define MOCK_METHOD1_T(m, ...) MOCK_METHOD1(m, __VA_ARGS__)
395 #define MOCK_METHOD2_T(m, ...) MOCK_METHOD2(m, __VA_ARGS__)
396 #define MOCK_METHOD3_T(m, ...) MOCK_METHOD3(m, __VA_ARGS__)
397 #define MOCK_METHOD4_T(m, ...) MOCK_METHOD4(m, __VA_ARGS__)
398 #define MOCK_METHOD5_T(m, ...) MOCK_METHOD5(m, __VA_ARGS__)
399 #define MOCK_METHOD6_T(m, ...) MOCK_METHOD6(m, __VA_ARGS__)
400 #define MOCK_METHOD7_T(m, ...) MOCK_METHOD7(m, __VA_ARGS__)
401 #define MOCK_METHOD8_T(m, ...) MOCK_METHOD8(m, __VA_ARGS__)
402 #define MOCK_METHOD9_T(m, ...) MOCK_METHOD9(m, __VA_ARGS__)
403 #define MOCK_METHOD10_T(m, ...) MOCK_METHOD10(m, __VA_ARGS__)
404 
405 #define MOCK_CONST_METHOD0_T(m, ...) MOCK_CONST_METHOD0(m, __VA_ARGS__)
406 #define MOCK_CONST_METHOD1_T(m, ...) MOCK_CONST_METHOD1(m, __VA_ARGS__)
407 #define MOCK_CONST_METHOD2_T(m, ...) MOCK_CONST_METHOD2(m, __VA_ARGS__)
408 #define MOCK_CONST_METHOD3_T(m, ...) MOCK_CONST_METHOD3(m, __VA_ARGS__)
409 #define MOCK_CONST_METHOD4_T(m, ...) MOCK_CONST_METHOD4(m, __VA_ARGS__)
410 #define MOCK_CONST_METHOD5_T(m, ...) MOCK_CONST_METHOD5(m, __VA_ARGS__)
411 #define MOCK_CONST_METHOD6_T(m, ...) MOCK_CONST_METHOD6(m, __VA_ARGS__)
412 #define MOCK_CONST_METHOD7_T(m, ...) MOCK_CONST_METHOD7(m, __VA_ARGS__)
413 #define MOCK_CONST_METHOD8_T(m, ...) MOCK_CONST_METHOD8(m, __VA_ARGS__)
414 #define MOCK_CONST_METHOD9_T(m, ...) MOCK_CONST_METHOD9(m, __VA_ARGS__)
415 #define MOCK_CONST_METHOD10_T(m, ...) MOCK_CONST_METHOD10(m, __VA_ARGS__)
416 
417 #define MOCK_METHOD0_WITH_CALLTYPE(ct, m, ...) \
418   GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 0, __VA_ARGS__)
419 #define MOCK_METHOD1_WITH_CALLTYPE(ct, m, ...) \
420   GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 1, __VA_ARGS__)
421 #define MOCK_METHOD2_WITH_CALLTYPE(ct, m, ...) \
422   GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 2, __VA_ARGS__)
423 #define MOCK_METHOD3_WITH_CALLTYPE(ct, m, ...) \
424   GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 3, __VA_ARGS__)
425 #define MOCK_METHOD4_WITH_CALLTYPE(ct, m, ...) \
426   GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 4, __VA_ARGS__)
427 #define MOCK_METHOD5_WITH_CALLTYPE(ct, m, ...) \
428   GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 5, __VA_ARGS__)
429 #define MOCK_METHOD6_WITH_CALLTYPE(ct, m, ...) \
430   GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 6, __VA_ARGS__)
431 #define MOCK_METHOD7_WITH_CALLTYPE(ct, m, ...) \
432   GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 7, __VA_ARGS__)
433 #define MOCK_METHOD8_WITH_CALLTYPE(ct, m, ...) \
434   GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 8, __VA_ARGS__)
435 #define MOCK_METHOD9_WITH_CALLTYPE(ct, m, ...) \
436   GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 9, __VA_ARGS__)
437 #define MOCK_METHOD10_WITH_CALLTYPE(ct, m, ...) \
438   GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 10, __VA_ARGS__)
439 
440 #define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, ...) \
441   GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 0, __VA_ARGS__)
442 #define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, ...) \
443   GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 1, __VA_ARGS__)
444 #define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, ...) \
445   GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 2, __VA_ARGS__)
446 #define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, ...) \
447   GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 3, __VA_ARGS__)
448 #define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, ...) \
449   GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 4, __VA_ARGS__)
450 #define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, ...) \
451   GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 5, __VA_ARGS__)
452 #define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, ...) \
453   GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 6, __VA_ARGS__)
454 #define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, ...) \
455   GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 7, __VA_ARGS__)
456 #define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, ...) \
457   GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 8, __VA_ARGS__)
458 #define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, ...) \
459   GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 9, __VA_ARGS__)
460 #define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, ...) \
461   GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 10, __VA_ARGS__)
462 
463 #define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
464   MOCK_METHOD0_WITH_CALLTYPE(ct, m, __VA_ARGS__)
465 #define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
466   MOCK_METHOD1_WITH_CALLTYPE(ct, m, __VA_ARGS__)
467 #define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
468   MOCK_METHOD2_WITH_CALLTYPE(ct, m, __VA_ARGS__)
469 #define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
470   MOCK_METHOD3_WITH_CALLTYPE(ct, m, __VA_ARGS__)
471 #define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
472   MOCK_METHOD4_WITH_CALLTYPE(ct, m, __VA_ARGS__)
473 #define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
474   MOCK_METHOD5_WITH_CALLTYPE(ct, m, __VA_ARGS__)
475 #define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
476   MOCK_METHOD6_WITH_CALLTYPE(ct, m, __VA_ARGS__)
477 #define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
478   MOCK_METHOD7_WITH_CALLTYPE(ct, m, __VA_ARGS__)
479 #define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
480   MOCK_METHOD8_WITH_CALLTYPE(ct, m, __VA_ARGS__)
481 #define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
482   MOCK_METHOD9_WITH_CALLTYPE(ct, m, __VA_ARGS__)
483 #define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
484   MOCK_METHOD10_WITH_CALLTYPE(ct, m, __VA_ARGS__)
485 
486 #define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
487   MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, __VA_ARGS__)
488 #define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
489   MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, __VA_ARGS__)
490 #define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
491   MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, __VA_ARGS__)
492 #define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
493   MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, __VA_ARGS__)
494 #define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
495   MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, __VA_ARGS__)
496 #define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
497   MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, __VA_ARGS__)
498 #define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
499   MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, __VA_ARGS__)
500 #define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
501   MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, __VA_ARGS__)
502 #define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
503   MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, __VA_ARGS__)
504 #define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
505   MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, __VA_ARGS__)
506 #define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
507   MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, __VA_ARGS__)
508 
509 #define GMOCK_INTERNAL_MOCK_METHODN(constness, ct, Method, args_num, ...) \
510   GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE(                                  \
511       args_num, ::testing::internal::identity_t<__VA_ARGS__>);            \
512   GMOCK_INTERNAL_MOCK_METHOD_IMPL(                                        \
513       args_num, Method, GMOCK_PP_NARG0(constness), 0, 0, , ct, ,          \
514       (::testing::internal::identity_t<__VA_ARGS__>))
515 
516 #define GMOCK_MOCKER_(arity, constness, Method) \
517   GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
518 
519 #endif  // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_
520