1 // This file was GENERATED by command:
2 // pump.py gmock-generated-function-mockers.h.pump
3 // DO NOT EDIT BY HAND!!!
5 // Copyright 2007, Google Inc.
6 // All rights reserved.
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above
15 // copyright notice, this list of conditions and the following disclaimer
16 // in the documentation and/or other materials provided with the
18 // * Neither the name of Google Inc. nor the names of its
19 // contributors may be used to endorse or promote products derived from
20 // this software without specific prior written permission.
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 // Author: wan@google.com (Zhanyong Wan)
36 // Google Mock - a framework for writing C++ mock classes.
38 // This file implements function mockers of various arities.
40 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
41 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
43 #include "gmock/gmock-spec-builders.h"
44 #include "gmock/internal/gmock-internal-utils.h"
46 #if GTEST_HAS_STD_FUNCTION_
47 # include <functional>
54 class FunctionMockerBase;
56 // Note: class FunctionMocker really belongs to the ::testing
57 // namespace. However if we define it in ::testing, MSVC will
58 // complain when classes in ::testing::internal declare it as a
59 // friend class template. To workaround this compiler bug, we define
60 // FunctionMocker in ::testing::internal and import it into ::testing.
65 class FunctionMocker<R()> : public
66 internal::FunctionMockerBase<R()> {
69 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
72 return this->current_spec();
76 // Even though gcc and MSVC don't enforce it, 'this->' is required
77 // by the C++ standard [14.6.4] here, as the base class type is
78 // dependent on the template argument (and thus shouldn't be
79 // looked into when resolving InvokeWith).
80 return this->InvokeWith(ArgumentTuple());
84 template <typename R, typename A1>
85 class FunctionMocker<R(A1)> : public
86 internal::FunctionMockerBase<R(A1)> {
89 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
91 MockSpec<F>& With(const Matcher<A1>& m1) {
92 this->current_spec().SetMatchers(::testing::make_tuple(m1));
93 return this->current_spec();
97 // Even though gcc and MSVC don't enforce it, 'this->' is required
98 // by the C++ standard [14.6.4] here, as the base class type is
99 // dependent on the template argument (and thus shouldn't be
100 // looked into when resolving InvokeWith).
101 return this->InvokeWith(ArgumentTuple(a1));
105 template <typename R, typename A1, typename A2>
106 class FunctionMocker<R(A1, A2)> : public
107 internal::FunctionMockerBase<R(A1, A2)> {
110 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
112 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2) {
113 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2));
114 return this->current_spec();
117 R Invoke(A1 a1, A2 a2) {
118 // Even though gcc and MSVC don't enforce it, 'this->' is required
119 // by the C++ standard [14.6.4] here, as the base class type is
120 // dependent on the template argument (and thus shouldn't be
121 // looked into when resolving InvokeWith).
122 return this->InvokeWith(ArgumentTuple(a1, a2));
126 template <typename R, typename A1, typename A2, typename A3>
127 class FunctionMocker<R(A1, A2, A3)> : public
128 internal::FunctionMockerBase<R(A1, A2, A3)> {
130 typedef R F(A1, A2, A3);
131 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
133 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
134 const Matcher<A3>& m3) {
135 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3));
136 return this->current_spec();
139 R Invoke(A1 a1, A2 a2, A3 a3) {
140 // Even though gcc and MSVC don't enforce it, 'this->' is required
141 // by the C++ standard [14.6.4] here, as the base class type is
142 // dependent on the template argument (and thus shouldn't be
143 // looked into when resolving InvokeWith).
144 return this->InvokeWith(ArgumentTuple(a1, a2, a3));
148 template <typename R, typename A1, typename A2, typename A3, typename A4>
149 class FunctionMocker<R(A1, A2, A3, A4)> : public
150 internal::FunctionMockerBase<R(A1, A2, A3, A4)> {
152 typedef R F(A1, A2, A3, A4);
153 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
155 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
156 const Matcher<A3>& m3, const Matcher<A4>& m4) {
157 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4));
158 return this->current_spec();
161 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) {
162 // Even though gcc and MSVC don't enforce it, 'this->' is required
163 // by the C++ standard [14.6.4] here, as the base class type is
164 // dependent on the template argument (and thus shouldn't be
165 // looked into when resolving InvokeWith).
166 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4));
170 template <typename R, typename A1, typename A2, typename A3, typename A4,
172 class FunctionMocker<R(A1, A2, A3, A4, A5)> : public
173 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)> {
175 typedef R F(A1, A2, A3, A4, A5);
176 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
178 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
179 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5) {
180 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5));
181 return this->current_spec();
184 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
185 // Even though gcc and MSVC don't enforce it, 'this->' is required
186 // by the C++ standard [14.6.4] here, as the base class type is
187 // dependent on the template argument (and thus shouldn't be
188 // looked into when resolving InvokeWith).
189 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5));
193 template <typename R, typename A1, typename A2, typename A3, typename A4,
194 typename A5, typename A6>
195 class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public
196 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6)> {
198 typedef R F(A1, A2, A3, A4, A5, A6);
199 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
201 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
202 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
203 const Matcher<A6>& m6) {
204 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
206 return this->current_spec();
209 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
210 // Even though gcc and MSVC don't enforce it, 'this->' is required
211 // by the C++ standard [14.6.4] here, as the base class type is
212 // dependent on the template argument (and thus shouldn't be
213 // looked into when resolving InvokeWith).
214 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6));
218 template <typename R, typename A1, typename A2, typename A3, typename A4,
219 typename A5, typename A6, typename A7>
220 class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public
221 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)> {
223 typedef R F(A1, A2, A3, A4, A5, A6, A7);
224 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
226 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
227 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
228 const Matcher<A6>& m6, const Matcher<A7>& m7) {
229 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
231 return this->current_spec();
234 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
235 // Even though gcc and MSVC don't enforce it, 'this->' is required
236 // by the C++ standard [14.6.4] here, as the base class type is
237 // dependent on the template argument (and thus shouldn't be
238 // looked into when resolving InvokeWith).
239 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7));
243 template <typename R, typename A1, typename A2, typename A3, typename A4,
244 typename A5, typename A6, typename A7, typename A8>
245 class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public
246 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
248 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8);
249 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
251 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
252 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
253 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8) {
254 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
256 return this->current_spec();
259 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) {
260 // Even though gcc and MSVC don't enforce it, 'this->' is required
261 // by the C++ standard [14.6.4] here, as the base class type is
262 // dependent on the template argument (and thus shouldn't be
263 // looked into when resolving InvokeWith).
264 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8));
268 template <typename R, typename A1, typename A2, typename A3, typename A4,
269 typename A5, typename A6, typename A7, typename A8, typename A9>
270 class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public
271 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
273 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9);
274 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
276 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
277 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
278 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
279 const Matcher<A9>& m9) {
280 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
282 return this->current_spec();
285 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) {
286 // Even though gcc and MSVC don't enforce it, 'this->' is required
287 // by the C++ standard [14.6.4] here, as the base class type is
288 // dependent on the template argument (and thus shouldn't be
289 // looked into when resolving InvokeWith).
290 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9));
294 template <typename R, typename A1, typename A2, typename A3, typename A4,
295 typename A5, typename A6, typename A7, typename A8, typename A9,
297 class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
298 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> {
300 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
301 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
303 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
304 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
305 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
306 const Matcher<A9>& m9, const Matcher<A10>& m10) {
307 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
308 m6, m7, m8, m9, m10));
309 return this->current_spec();
312 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
314 // Even though gcc and MSVC don't enforce it, 'this->' is required
315 // by the C++ standard [14.6.4] here, as the base class type is
316 // dependent on the template argument (and thus shouldn't be
317 // looked into when resolving InvokeWith).
318 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9,
323 } // namespace internal
325 // The style guide prohibits "using" statements in a namespace scope
326 // inside a header file. However, the FunctionMocker class template
327 // is meant to be defined in the ::testing namespace. The following
328 // line is just a trick for working around a bug in MSVC 8.0, which
329 // cannot handle it if we define FunctionMocker in ::testing.
330 using internal::FunctionMocker;
332 // GMOCK_RESULT_(tn, F) expands to the result type of function type F.
333 // We define this as a variadic macro in case F contains unprotected
334 // commas (the same reason that we use variadic macros in other places
336 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
337 #define GMOCK_RESULT_(tn, ...) \
338 tn ::testing::internal::Function<__VA_ARGS__>::Result
340 // The type of argument N of the given function type.
341 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
342 #define GMOCK_ARG_(tn, N, ...) \
343 tn ::testing::internal::Function<__VA_ARGS__>::Argument##N
345 // The matcher type for argument N of the given function type.
346 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
347 #define GMOCK_MATCHER_(tn, N, ...) \
348 const ::testing::Matcher<GMOCK_ARG_(tn, N, __VA_ARGS__)>&
350 // The variable for mocking the given method.
351 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
352 #define GMOCK_MOCKER_(arity, constness, Method) \
353 GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
355 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
356 #define GMOCK_METHOD0_(tn, constness, ct, Method, ...) \
357 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
359 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
360 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
362 this_method_does_not_take_0_arguments); \
363 GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \
364 return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
366 ::testing::MockSpec<__VA_ARGS__>& \
367 gmock_##Method() constness { \
368 GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \
369 return GMOCK_MOCKER_(0, constness, Method).With(); \
371 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(0, constness, \
374 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
375 #define GMOCK_METHOD1_(tn, constness, ct, Method, ...) \
376 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
377 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
378 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
379 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
381 this_method_does_not_take_1_argument); \
382 GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \
383 return GMOCK_MOCKER_(1, constness, Method).Invoke(gmock_a1); \
385 ::testing::MockSpec<__VA_ARGS__>& \
386 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
387 GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \
388 return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \
390 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(1, constness, \
393 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
394 #define GMOCK_METHOD2_(tn, constness, ct, Method, ...) \
395 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
396 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
397 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
398 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
399 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
401 this_method_does_not_take_2_arguments); \
402 GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \
403 return GMOCK_MOCKER_(2, constness, Method).Invoke(gmock_a1, gmock_a2); \
405 ::testing::MockSpec<__VA_ARGS__>& \
406 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
407 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
408 GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \
409 return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \
411 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(2, constness, \
414 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
415 #define GMOCK_METHOD3_(tn, constness, ct, Method, ...) \
416 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
417 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
418 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
419 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
420 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
421 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
423 this_method_does_not_take_3_arguments); \
424 GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \
425 return GMOCK_MOCKER_(3, constness, Method).Invoke(gmock_a1, gmock_a2, \
428 ::testing::MockSpec<__VA_ARGS__>& \
429 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
430 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
431 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
432 GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \
433 return GMOCK_MOCKER_(3, constness, Method).With(gmock_a1, gmock_a2, \
436 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(3, constness, \
439 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
440 #define GMOCK_METHOD4_(tn, constness, ct, Method, ...) \
441 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
442 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
443 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
444 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
445 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
446 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
447 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
449 this_method_does_not_take_4_arguments); \
450 GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \
451 return GMOCK_MOCKER_(4, constness, Method).Invoke(gmock_a1, gmock_a2, \
452 gmock_a3, gmock_a4); \
454 ::testing::MockSpec<__VA_ARGS__>& \
455 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
456 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
457 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
458 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
459 GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \
460 return GMOCK_MOCKER_(4, constness, Method).With(gmock_a1, gmock_a2, \
461 gmock_a3, gmock_a4); \
463 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(4, constness, \
466 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
467 #define GMOCK_METHOD5_(tn, constness, ct, Method, ...) \
468 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
469 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
470 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
471 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
472 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
473 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
474 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
475 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
477 this_method_does_not_take_5_arguments); \
478 GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \
479 return GMOCK_MOCKER_(5, constness, Method).Invoke(gmock_a1, gmock_a2, \
480 gmock_a3, gmock_a4, gmock_a5); \
482 ::testing::MockSpec<__VA_ARGS__>& \
483 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
484 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
485 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
486 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
487 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
488 GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \
489 return GMOCK_MOCKER_(5, constness, Method).With(gmock_a1, gmock_a2, \
490 gmock_a3, gmock_a4, gmock_a5); \
492 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(5, constness, \
495 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
496 #define GMOCK_METHOD6_(tn, constness, ct, Method, ...) \
497 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
498 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
499 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
500 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
501 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
502 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
503 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
504 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
505 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
507 this_method_does_not_take_6_arguments); \
508 GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \
509 return GMOCK_MOCKER_(6, constness, Method).Invoke(gmock_a1, gmock_a2, \
510 gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
512 ::testing::MockSpec<__VA_ARGS__>& \
513 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
514 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
515 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
516 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
517 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
518 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
519 GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \
520 return GMOCK_MOCKER_(6, constness, Method).With(gmock_a1, gmock_a2, \
521 gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
523 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(6, constness, \
526 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
527 #define GMOCK_METHOD7_(tn, constness, ct, Method, ...) \
528 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
529 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
530 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
531 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
532 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
533 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
534 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
535 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
536 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
537 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
539 this_method_does_not_take_7_arguments); \
540 GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \
541 return GMOCK_MOCKER_(7, constness, Method).Invoke(gmock_a1, gmock_a2, \
542 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
544 ::testing::MockSpec<__VA_ARGS__>& \
545 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
546 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
547 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
548 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
549 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
550 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
551 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
552 GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \
553 return GMOCK_MOCKER_(7, constness, Method).With(gmock_a1, gmock_a2, \
554 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
556 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(7, constness, \
559 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
560 #define GMOCK_METHOD8_(tn, constness, ct, Method, ...) \
561 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
562 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
563 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
564 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
565 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
566 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
567 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
568 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
569 GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
570 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
571 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
573 this_method_does_not_take_8_arguments); \
574 GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \
575 return GMOCK_MOCKER_(8, constness, Method).Invoke(gmock_a1, gmock_a2, \
576 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
578 ::testing::MockSpec<__VA_ARGS__>& \
579 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
580 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
581 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
582 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
583 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
584 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
585 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
586 GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
587 GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \
588 return GMOCK_MOCKER_(8, constness, Method).With(gmock_a1, gmock_a2, \
589 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
591 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(8, constness, \
594 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
595 #define GMOCK_METHOD9_(tn, constness, ct, Method, ...) \
596 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
597 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
598 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
599 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
600 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
601 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
602 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
603 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
604 GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
605 GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
606 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
607 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
609 this_method_does_not_take_9_arguments); \
610 GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \
611 return GMOCK_MOCKER_(9, constness, Method).Invoke(gmock_a1, gmock_a2, \
612 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
615 ::testing::MockSpec<__VA_ARGS__>& \
616 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
617 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
618 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
619 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
620 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
621 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
622 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
623 GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
624 GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
625 GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \
626 return GMOCK_MOCKER_(9, constness, Method).With(gmock_a1, gmock_a2, \
627 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
630 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(9, constness, \
633 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
634 #define GMOCK_METHOD10_(tn, constness, ct, Method, ...) \
635 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
636 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
637 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
638 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
639 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
640 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
641 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
642 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
643 GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
644 GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9, \
645 GMOCK_ARG_(tn, 10, __VA_ARGS__) gmock_a10) constness { \
646 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
647 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
649 this_method_does_not_take_10_arguments); \
650 GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \
651 return GMOCK_MOCKER_(10, constness, Method).Invoke(gmock_a1, gmock_a2, \
652 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
655 ::testing::MockSpec<__VA_ARGS__>& \
656 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
657 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
658 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
659 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
660 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
661 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
662 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
663 GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
664 GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9, \
665 GMOCK_MATCHER_(tn, 10, \
666 __VA_ARGS__) gmock_a10) constness { \
667 GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \
668 return GMOCK_MOCKER_(10, constness, Method).With(gmock_a1, gmock_a2, \
669 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
672 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(10, constness, \
675 #define MOCK_METHOD0(m, ...) GMOCK_METHOD0_(, , , m, __VA_ARGS__)
676 #define MOCK_METHOD1(m, ...) GMOCK_METHOD1_(, , , m, __VA_ARGS__)
677 #define MOCK_METHOD2(m, ...) GMOCK_METHOD2_(, , , m, __VA_ARGS__)
678 #define MOCK_METHOD3(m, ...) GMOCK_METHOD3_(, , , m, __VA_ARGS__)
679 #define MOCK_METHOD4(m, ...) GMOCK_METHOD4_(, , , m, __VA_ARGS__)
680 #define MOCK_METHOD5(m, ...) GMOCK_METHOD5_(, , , m, __VA_ARGS__)
681 #define MOCK_METHOD6(m, ...) GMOCK_METHOD6_(, , , m, __VA_ARGS__)
682 #define MOCK_METHOD7(m, ...) GMOCK_METHOD7_(, , , m, __VA_ARGS__)
683 #define MOCK_METHOD8(m, ...) GMOCK_METHOD8_(, , , m, __VA_ARGS__)
684 #define MOCK_METHOD9(m, ...) GMOCK_METHOD9_(, , , m, __VA_ARGS__)
685 #define MOCK_METHOD10(m, ...) GMOCK_METHOD10_(, , , m, __VA_ARGS__)
687 #define MOCK_CONST_METHOD0(m, ...) GMOCK_METHOD0_(, const, , m, __VA_ARGS__)
688 #define MOCK_CONST_METHOD1(m, ...) GMOCK_METHOD1_(, const, , m, __VA_ARGS__)
689 #define MOCK_CONST_METHOD2(m, ...) GMOCK_METHOD2_(, const, , m, __VA_ARGS__)
690 #define MOCK_CONST_METHOD3(m, ...) GMOCK_METHOD3_(, const, , m, __VA_ARGS__)
691 #define MOCK_CONST_METHOD4(m, ...) GMOCK_METHOD4_(, const, , m, __VA_ARGS__)
692 #define MOCK_CONST_METHOD5(m, ...) GMOCK_METHOD5_(, const, , m, __VA_ARGS__)
693 #define MOCK_CONST_METHOD6(m, ...) GMOCK_METHOD6_(, const, , m, __VA_ARGS__)
694 #define MOCK_CONST_METHOD7(m, ...) GMOCK_METHOD7_(, const, , m, __VA_ARGS__)
695 #define MOCK_CONST_METHOD8(m, ...) GMOCK_METHOD8_(, const, , m, __VA_ARGS__)
696 #define MOCK_CONST_METHOD9(m, ...) GMOCK_METHOD9_(, const, , m, __VA_ARGS__)
697 #define MOCK_CONST_METHOD10(m, ...) GMOCK_METHOD10_(, const, , m, __VA_ARGS__)
699 #define MOCK_METHOD0_T(m, ...) GMOCK_METHOD0_(typename, , , m, __VA_ARGS__)
700 #define MOCK_METHOD1_T(m, ...) GMOCK_METHOD1_(typename, , , m, __VA_ARGS__)
701 #define MOCK_METHOD2_T(m, ...) GMOCK_METHOD2_(typename, , , m, __VA_ARGS__)
702 #define MOCK_METHOD3_T(m, ...) GMOCK_METHOD3_(typename, , , m, __VA_ARGS__)
703 #define MOCK_METHOD4_T(m, ...) GMOCK_METHOD4_(typename, , , m, __VA_ARGS__)
704 #define MOCK_METHOD5_T(m, ...) GMOCK_METHOD5_(typename, , , m, __VA_ARGS__)
705 #define MOCK_METHOD6_T(m, ...) GMOCK_METHOD6_(typename, , , m, __VA_ARGS__)
706 #define MOCK_METHOD7_T(m, ...) GMOCK_METHOD7_(typename, , , m, __VA_ARGS__)
707 #define MOCK_METHOD8_T(m, ...) GMOCK_METHOD8_(typename, , , m, __VA_ARGS__)
708 #define MOCK_METHOD9_T(m, ...) GMOCK_METHOD9_(typename, , , m, __VA_ARGS__)
709 #define MOCK_METHOD10_T(m, ...) GMOCK_METHOD10_(typename, , , m, __VA_ARGS__)
711 #define MOCK_CONST_METHOD0_T(m, ...) \
712 GMOCK_METHOD0_(typename, const, , m, __VA_ARGS__)
713 #define MOCK_CONST_METHOD1_T(m, ...) \
714 GMOCK_METHOD1_(typename, const, , m, __VA_ARGS__)
715 #define MOCK_CONST_METHOD2_T(m, ...) \
716 GMOCK_METHOD2_(typename, const, , m, __VA_ARGS__)
717 #define MOCK_CONST_METHOD3_T(m, ...) \
718 GMOCK_METHOD3_(typename, const, , m, __VA_ARGS__)
719 #define MOCK_CONST_METHOD4_T(m, ...) \
720 GMOCK_METHOD4_(typename, const, , m, __VA_ARGS__)
721 #define MOCK_CONST_METHOD5_T(m, ...) \
722 GMOCK_METHOD5_(typename, const, , m, __VA_ARGS__)
723 #define MOCK_CONST_METHOD6_T(m, ...) \
724 GMOCK_METHOD6_(typename, const, , m, __VA_ARGS__)
725 #define MOCK_CONST_METHOD7_T(m, ...) \
726 GMOCK_METHOD7_(typename, const, , m, __VA_ARGS__)
727 #define MOCK_CONST_METHOD8_T(m, ...) \
728 GMOCK_METHOD8_(typename, const, , m, __VA_ARGS__)
729 #define MOCK_CONST_METHOD9_T(m, ...) \
730 GMOCK_METHOD9_(typename, const, , m, __VA_ARGS__)
731 #define MOCK_CONST_METHOD10_T(m, ...) \
732 GMOCK_METHOD10_(typename, const, , m, __VA_ARGS__)
734 #define MOCK_METHOD0_WITH_CALLTYPE(ct, m, ...) \
735 GMOCK_METHOD0_(, , ct, m, __VA_ARGS__)
736 #define MOCK_METHOD1_WITH_CALLTYPE(ct, m, ...) \
737 GMOCK_METHOD1_(, , ct, m, __VA_ARGS__)
738 #define MOCK_METHOD2_WITH_CALLTYPE(ct, m, ...) \
739 GMOCK_METHOD2_(, , ct, m, __VA_ARGS__)
740 #define MOCK_METHOD3_WITH_CALLTYPE(ct, m, ...) \
741 GMOCK_METHOD3_(, , ct, m, __VA_ARGS__)
742 #define MOCK_METHOD4_WITH_CALLTYPE(ct, m, ...) \
743 GMOCK_METHOD4_(, , ct, m, __VA_ARGS__)
744 #define MOCK_METHOD5_WITH_CALLTYPE(ct, m, ...) \
745 GMOCK_METHOD5_(, , ct, m, __VA_ARGS__)
746 #define MOCK_METHOD6_WITH_CALLTYPE(ct, m, ...) \
747 GMOCK_METHOD6_(, , ct, m, __VA_ARGS__)
748 #define MOCK_METHOD7_WITH_CALLTYPE(ct, m, ...) \
749 GMOCK_METHOD7_(, , ct, m, __VA_ARGS__)
750 #define MOCK_METHOD8_WITH_CALLTYPE(ct, m, ...) \
751 GMOCK_METHOD8_(, , ct, m, __VA_ARGS__)
752 #define MOCK_METHOD9_WITH_CALLTYPE(ct, m, ...) \
753 GMOCK_METHOD9_(, , ct, m, __VA_ARGS__)
754 #define MOCK_METHOD10_WITH_CALLTYPE(ct, m, ...) \
755 GMOCK_METHOD10_(, , ct, m, __VA_ARGS__)
757 #define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, ...) \
758 GMOCK_METHOD0_(, const, ct, m, __VA_ARGS__)
759 #define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, ...) \
760 GMOCK_METHOD1_(, const, ct, m, __VA_ARGS__)
761 #define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, ...) \
762 GMOCK_METHOD2_(, const, ct, m, __VA_ARGS__)
763 #define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, ...) \
764 GMOCK_METHOD3_(, const, ct, m, __VA_ARGS__)
765 #define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, ...) \
766 GMOCK_METHOD4_(, const, ct, m, __VA_ARGS__)
767 #define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, ...) \
768 GMOCK_METHOD5_(, const, ct, m, __VA_ARGS__)
769 #define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, ...) \
770 GMOCK_METHOD6_(, const, ct, m, __VA_ARGS__)
771 #define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, ...) \
772 GMOCK_METHOD7_(, const, ct, m, __VA_ARGS__)
773 #define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, ...) \
774 GMOCK_METHOD8_(, const, ct, m, __VA_ARGS__)
775 #define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, ...) \
776 GMOCK_METHOD9_(, const, ct, m, __VA_ARGS__)
777 #define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, ...) \
778 GMOCK_METHOD10_(, const, ct, m, __VA_ARGS__)
780 #define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
781 GMOCK_METHOD0_(typename, , ct, m, __VA_ARGS__)
782 #define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
783 GMOCK_METHOD1_(typename, , ct, m, __VA_ARGS__)
784 #define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
785 GMOCK_METHOD2_(typename, , ct, m, __VA_ARGS__)
786 #define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
787 GMOCK_METHOD3_(typename, , ct, m, __VA_ARGS__)
788 #define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
789 GMOCK_METHOD4_(typename, , ct, m, __VA_ARGS__)
790 #define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
791 GMOCK_METHOD5_(typename, , ct, m, __VA_ARGS__)
792 #define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
793 GMOCK_METHOD6_(typename, , ct, m, __VA_ARGS__)
794 #define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
795 GMOCK_METHOD7_(typename, , ct, m, __VA_ARGS__)
796 #define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
797 GMOCK_METHOD8_(typename, , ct, m, __VA_ARGS__)
798 #define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
799 GMOCK_METHOD9_(typename, , ct, m, __VA_ARGS__)
800 #define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
801 GMOCK_METHOD10_(typename, , ct, m, __VA_ARGS__)
803 #define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
804 GMOCK_METHOD0_(typename, const, ct, m, __VA_ARGS__)
805 #define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
806 GMOCK_METHOD1_(typename, const, ct, m, __VA_ARGS__)
807 #define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
808 GMOCK_METHOD2_(typename, const, ct, m, __VA_ARGS__)
809 #define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
810 GMOCK_METHOD3_(typename, const, ct, m, __VA_ARGS__)
811 #define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
812 GMOCK_METHOD4_(typename, const, ct, m, __VA_ARGS__)
813 #define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
814 GMOCK_METHOD5_(typename, const, ct, m, __VA_ARGS__)
815 #define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
816 GMOCK_METHOD6_(typename, const, ct, m, __VA_ARGS__)
817 #define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
818 GMOCK_METHOD7_(typename, const, ct, m, __VA_ARGS__)
819 #define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
820 GMOCK_METHOD8_(typename, const, ct, m, __VA_ARGS__)
821 #define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
822 GMOCK_METHOD9_(typename, const, ct, m, __VA_ARGS__)
823 #define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
824 GMOCK_METHOD10_(typename, const, ct, m, __VA_ARGS__)
826 // A MockFunction<F> class has one mock method whose type is F. It is
827 // useful when you just want your test code to emit some messages and
828 // have Google Mock verify the right messages are sent (and perhaps at
829 // the right times). For example, if you are exercising code:
835 // and want to verify that Foo(1) and Foo(3) both invoke
836 // mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
838 // TEST(FooTest, InvokesBarCorrectly) {
840 // MockFunction<void(string check_point_name)> check;
844 // EXPECT_CALL(mock, Bar("a"));
845 // EXPECT_CALL(check, Call("1"));
846 // EXPECT_CALL(check, Call("2"));
847 // EXPECT_CALL(mock, Bar("a"));
856 // The expectation spec says that the first Bar("a") must happen
857 // before check point "1", the second Bar("a") must happen after check
858 // point "2", and nothing should happen between the two check
859 // points. The explicit check points make it easy to tell which
860 // Bar("a") is called by which call to Foo().
862 // MockFunction<F> can also be used to exercise code that accepts
863 // std::function<F> callbacks. To do so, use AsStdFunction() method
864 // to create std::function proxy forwarding to original object's Call.
867 // TEST(FooTest, RunsCallbackWithBarArgument) {
868 // MockFunction<int(string)> callback;
869 // EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1));
870 // Foo(callback.AsStdFunction());
872 template <typename F>
875 template <typename R>
876 class MockFunction<R()> {
880 MOCK_METHOD0_T(Call, R());
882 #if GTEST_HAS_STD_FUNCTION_
883 std::function<R()> AsStdFunction() {
884 return [this]() -> R {
888 #endif // GTEST_HAS_STD_FUNCTION_
891 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
894 template <typename R, typename A0>
895 class MockFunction<R(A0)> {
899 MOCK_METHOD1_T(Call, R(A0));
901 #if GTEST_HAS_STD_FUNCTION_
902 std::function<R(A0)> AsStdFunction() {
903 return [this](A0 a0) -> R {
904 return this->Call(a0);
907 #endif // GTEST_HAS_STD_FUNCTION_
910 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
913 template <typename R, typename A0, typename A1>
914 class MockFunction<R(A0, A1)> {
918 MOCK_METHOD2_T(Call, R(A0, A1));
920 #if GTEST_HAS_STD_FUNCTION_
921 std::function<R(A0, A1)> AsStdFunction() {
922 return [this](A0 a0, A1 a1) -> R {
923 return this->Call(a0, a1);
926 #endif // GTEST_HAS_STD_FUNCTION_
929 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
932 template <typename R, typename A0, typename A1, typename A2>
933 class MockFunction<R(A0, A1, A2)> {
937 MOCK_METHOD3_T(Call, R(A0, A1, A2));
939 #if GTEST_HAS_STD_FUNCTION_
940 std::function<R(A0, A1, A2)> AsStdFunction() {
941 return [this](A0 a0, A1 a1, A2 a2) -> R {
942 return this->Call(a0, a1, a2);
945 #endif // GTEST_HAS_STD_FUNCTION_
948 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
951 template <typename R, typename A0, typename A1, typename A2, typename A3>
952 class MockFunction<R(A0, A1, A2, A3)> {
956 MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));
958 #if GTEST_HAS_STD_FUNCTION_
959 std::function<R(A0, A1, A2, A3)> AsStdFunction() {
960 return [this](A0 a0, A1 a1, A2 a2, A3 a3) -> R {
961 return this->Call(a0, a1, a2, a3);
964 #endif // GTEST_HAS_STD_FUNCTION_
967 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
970 template <typename R, typename A0, typename A1, typename A2, typename A3,
972 class MockFunction<R(A0, A1, A2, A3, A4)> {
976 MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));
978 #if GTEST_HAS_STD_FUNCTION_
979 std::function<R(A0, A1, A2, A3, A4)> AsStdFunction() {
980 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) -> R {
981 return this->Call(a0, a1, a2, a3, a4);
984 #endif // GTEST_HAS_STD_FUNCTION_
987 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
990 template <typename R, typename A0, typename A1, typename A2, typename A3,
991 typename A4, typename A5>
992 class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
996 MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));
998 #if GTEST_HAS_STD_FUNCTION_
999 std::function<R(A0, A1, A2, A3, A4, A5)> AsStdFunction() {
1000 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) -> R {
1001 return this->Call(a0, a1, a2, a3, a4, a5);
1004 #endif // GTEST_HAS_STD_FUNCTION_
1007 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1010 template <typename R, typename A0, typename A1, typename A2, typename A3,
1011 typename A4, typename A5, typename A6>
1012 class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
1016 MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));
1018 #if GTEST_HAS_STD_FUNCTION_
1019 std::function<R(A0, A1, A2, A3, A4, A5, A6)> AsStdFunction() {
1020 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) -> R {
1021 return this->Call(a0, a1, a2, a3, a4, a5, a6);
1024 #endif // GTEST_HAS_STD_FUNCTION_
1027 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1030 template <typename R, typename A0, typename A1, typename A2, typename A3,
1031 typename A4, typename A5, typename A6, typename A7>
1032 class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
1036 MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));
1038 #if GTEST_HAS_STD_FUNCTION_
1039 std::function<R(A0, A1, A2, A3, A4, A5, A6, A7)> AsStdFunction() {
1040 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) -> R {
1041 return this->Call(a0, a1, a2, a3, a4, a5, a6, a7);
1044 #endif // GTEST_HAS_STD_FUNCTION_
1047 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1050 template <typename R, typename A0, typename A1, typename A2, typename A3,
1051 typename A4, typename A5, typename A6, typename A7, typename A8>
1052 class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
1056 MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));
1058 #if GTEST_HAS_STD_FUNCTION_
1059 std::function<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> AsStdFunction() {
1060 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7,
1062 return this->Call(a0, a1, a2, a3, a4, a5, a6, a7, a8);
1065 #endif // GTEST_HAS_STD_FUNCTION_
1068 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1071 template <typename R, typename A0, typename A1, typename A2, typename A3,
1072 typename A4, typename A5, typename A6, typename A7, typename A8,
1074 class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
1078 MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
1080 #if GTEST_HAS_STD_FUNCTION_
1081 std::function<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> AsStdFunction() {
1082 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7,
1083 A8 a8, A9 a9) -> R {
1084 return this->Call(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
1087 #endif // GTEST_HAS_STD_FUNCTION_
1090 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1093 } // namespace testing
1095 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_