1// This file was GENERATED by command:
2// pump.py gmock-generated-function-mockers.h.pump
3// DO NOT EDIT BY HAND!!!
4
5// Copyright 2007, Google Inc.
6// All rights reserved.
7//
8// Redistribution and use in source and binary forms, with or without
9// modification, are permitted provided that the following conditions are
10// met:
11//
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
17// distribution.
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.
21//
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.
33
34
35// Google Mock - a framework for writing C++ mock classes.
36//
37// This file implements function mockers of various arities.
38
39// GOOGLETEST_CM0002 DO NOT DELETE
40
41#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
42#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
43
44#include "gmock/gmock-spec-builders.h"
45#include "gmock/internal/gmock-internal-utils.h"
46
47#if GTEST_HAS_STD_FUNCTION_
48# include <functional>
49#endif
50
51namespace testing {
52namespace internal {
53
54template <typename F>
55class FunctionMockerBase;
56
57// Note: class FunctionMocker really belongs to the ::testing
58// namespace. However if we define it in ::testing, MSVC will
59// complain when classes in ::testing::internal declare it as a
60// friend class template. To workaround this compiler bug, we define
61// FunctionMocker in ::testing::internal and import it into ::testing.
62template <typename F>
63class FunctionMocker;
64
65template <typename R>
66class FunctionMocker<R()> : public
67 internal::FunctionMockerBase<R()> {
68 public:
69 typedef R F();
70 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
71
72 MockSpec<F> With() {
73 return MockSpec<F>(this, ::testing::make_tuple());
74 }
75
76 R Invoke() {
77 // Even though gcc and MSVC don't enforce it, 'this->' is required
78 // by the C++ standard [14.6.4] here, as the base class type is
79 // dependent on the template argument (and thus shouldn't be
80 // looked into when resolving InvokeWith).
81 return this->InvokeWith(ArgumentTuple());
82 }
83};
84
85template <typename R, typename A1>
86class FunctionMocker<R(A1)> : public
87 internal::FunctionMockerBase<R(A1)> {
88 public:
89 typedef R F(A1);
90 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
91
92 MockSpec<F> With(const Matcher<A1>& m1) {
93 return MockSpec<F>(this, ::testing::make_tuple(m1));
94 }
95
96 R Invoke(A1 a1) {
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(internal::forward<A1>(a1)));
102 }
103};
104
105template <typename R, typename A1, typename A2>
106class FunctionMocker<R(A1, A2)> : public
107 internal::FunctionMockerBase<R(A1, A2)> {
108 public:
109 typedef R F(A1, A2);
110 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
111
112 MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2) {
113 return MockSpec<F>(this, ::testing::make_tuple(m1, m2));
114 }
115
116 R Invoke(A1 a1, A2 a2) {
117 // Even though gcc and MSVC don't enforce it, 'this->' is required
118 // by the C++ standard [14.6.4] here, as the base class type is
119 // dependent on the template argument (and thus shouldn't be
120 // looked into when resolving InvokeWith).
121 return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
122 internal::forward<A2>(a2)));
123 }
124};
125
126template <typename R, typename A1, typename A2, typename A3>
127class FunctionMocker<R(A1, A2, A3)> : public
128 internal::FunctionMockerBase<R(A1, A2, A3)> {
129 public:
130 typedef R F(A1, A2, A3);
131 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
132
133 MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
134 const Matcher<A3>& m3) {
135 return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3));
136 }
137
138 R Invoke(A1 a1, A2 a2, A3 a3) {
139 // Even though gcc and MSVC don't enforce it, 'this->' is required
140 // by the C++ standard [14.6.4] here, as the base class type is
141 // dependent on the template argument (and thus shouldn't be
142 // looked into when resolving InvokeWith).
143 return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
144 internal::forward<A2>(a2), internal::forward<A3>(a3)));
145 }
146};
147
148template <typename R, typename A1, typename A2, typename A3, typename A4>
149class FunctionMocker<R(A1, A2, A3, A4)> : public
150 internal::FunctionMockerBase<R(A1, A2, A3, A4)> {
151 public:
152 typedef R F(A1, A2, A3, A4);
153 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
154
155 MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
156 const Matcher<A3>& m3, const Matcher<A4>& m4) {
157 return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4));
158 }
159
160 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) {
161 // Even though gcc and MSVC don't enforce it, 'this->' is required
162 // by the C++ standard [14.6.4] here, as the base class type is
163 // dependent on the template argument (and thus shouldn't be
164 // looked into when resolving InvokeWith).
165 return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
166 internal::forward<A2>(a2), internal::forward<A3>(a3),
167 internal::forward<A4>(a4)));
168 }
169};
170
171template <typename R, typename A1, typename A2, typename A3, typename A4,
172 typename A5>
173class FunctionMocker<R(A1, A2, A3, A4, A5)> : public
174 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)> {
175 public:
176 typedef R F(A1, A2, A3, A4, A5);
177 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
178
179 MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
180 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5) {
181 return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4, m5));
182 }
183
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(internal::forward<A1>(a1),
190 internal::forward<A2>(a2), internal::forward<A3>(a3),
191 internal::forward<A4>(a4), internal::forward<A5>(a5)));
192 }
193};
194
195template <typename R, typename A1, typename A2, typename A3, typename A4,
196 typename A5, typename A6>
197class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public
198 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6)> {
199 public:
200 typedef R F(A1, A2, A3, A4, A5, A6);
201 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
202
203 MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
204 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
205 const Matcher<A6>& m6) {
206 return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4, m5, m6));
207 }
208
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(internal::forward<A1>(a1),
215 internal::forward<A2>(a2), internal::forward<A3>(a3),
216 internal::forward<A4>(a4), internal::forward<A5>(a5),
217 internal::forward<A6>(a6)));
218 }
219};
220
221template <typename R, typename A1, typename A2, typename A3, typename A4,
222 typename A5, typename A6, typename A7>
223class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public
224 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)> {
225 public:
226 typedef R F(A1, A2, A3, A4, A5, A6, A7);
227 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
228
229 MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
230 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
231 const Matcher<A6>& m6, const Matcher<A7>& m7) {
232 return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4, m5, m6, m7));
233 }
234
235 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
236 // Even though gcc and MSVC don't enforce it, 'this->' is required
237 // by the C++ standard [14.6.4] here, as the base class type is
238 // dependent on the template argument (and thus shouldn't be
239 // looked into when resolving InvokeWith).
240 return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
241 internal::forward<A2>(a2), internal::forward<A3>(a3),
242 internal::forward<A4>(a4), internal::forward<A5>(a5),
243 internal::forward<A6>(a6), internal::forward<A7>(a7)));
244 }
245};
246
247template <typename R, typename A1, typename A2, typename A3, typename A4,
248 typename A5, typename A6, typename A7, typename A8>
249class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public
250 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
251 public:
252 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8);
253 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
254
255 MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
256 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
257 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8) {
258 return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4, m5, m6, m7,
259 m8));
260 }
261
262 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) {
263 // Even though gcc and MSVC don't enforce it, 'this->' is required
264 // by the C++ standard [14.6.4] here, as the base class type is
265 // dependent on the template argument (and thus shouldn't be
266 // looked into when resolving InvokeWith).
267 return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
268 internal::forward<A2>(a2), internal::forward<A3>(a3),
269 internal::forward<A4>(a4), internal::forward<A5>(a5),
270 internal::forward<A6>(a6), internal::forward<A7>(a7),
271 internal::forward<A8>(a8)));
272 }
273};
274
275template <typename R, typename A1, typename A2, typename A3, typename A4,
276 typename A5, typename A6, typename A7, typename A8, typename A9>
277class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public
278 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
279 public:
280 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9);
281 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
282
283 MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
284 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
285 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
286 const Matcher<A9>& m9) {
287 return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4, m5, m6, m7,
288 m8, m9));
289 }
290
291 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) {
292 // Even though gcc and MSVC don't enforce it, 'this->' is required
293 // by the C++ standard [14.6.4] here, as the base class type is
294 // dependent on the template argument (and thus shouldn't be
295 // looked into when resolving InvokeWith).
296 return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
297 internal::forward<A2>(a2), internal::forward<A3>(a3),
298 internal::forward<A4>(a4), internal::forward<A5>(a5),
299 internal::forward<A6>(a6), internal::forward<A7>(a7),
300 internal::forward<A8>(a8), internal::forward<A9>(a9)));
301 }
302};
303
304template <typename R, typename A1, typename A2, typename A3, typename A4,
305 typename A5, typename A6, typename A7, typename A8, typename A9,
306 typename A10>
307class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
308 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> {
309 public:
310 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
311 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
312
313 MockSpec<F> With(const Matcher<A1>& m1, const Matcher<A2>& m2,
314 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
315 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
316 const Matcher<A9>& m9, const Matcher<A10>& m10) {
317 return MockSpec<F>(this, ::testing::make_tuple(m1, m2, m3, m4, m5, m6, m7,
318 m8, m9, m10));
319 }
320
321 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
322 A10 a10) {
323 // Even though gcc and MSVC don't enforce it, 'this->' is required
324 // by the C++ standard [14.6.4] here, as the base class type is
325 // dependent on the template argument (and thus shouldn't be
326 // looked into when resolving InvokeWith).
327 return this->InvokeWith(ArgumentTuple(internal::forward<A1>(a1),
328 internal::forward<A2>(a2), internal::forward<A3>(a3),
329 internal::forward<A4>(a4), internal::forward<A5>(a5),
330 internal::forward<A6>(a6), internal::forward<A7>(a7),
331 internal::forward<A8>(a8), internal::forward<A9>(a9),
332 internal::forward<A10>(a10)));
333 }
334};
335
336// Removes the given pointer; this is a helper for the expectation setter method
337// for parameterless matchers.
338//
339// We want to make sure that the user cannot set a parameterless expectation on
340// overloaded methods, including methods which are overloaded on const. Example:
341//
342// class MockClass {
343// MOCK_METHOD0(GetName, string&());
344// MOCK_CONST_METHOD0(GetName, const string&());
345// };
346//
347// TEST() {
348// // This should be an error, as it's not clear which overload is expected.
349// EXPECT_CALL(mock, GetName).WillOnce(ReturnRef(value));
350// }
351//
352// Here are the generated expectation-setter methods:
353//
354// class MockClass {
355// // Overload 1
356// MockSpec<string&()> gmock_GetName() { ... }
357// // Overload 2. Declared const so that the compiler will generate an
358// // error when trying to resolve between this and overload 4 in
359// // 'gmock_GetName(WithoutMatchers(), nullptr)'.
360// MockSpec<string&()> gmock_GetName(
361// const WithoutMatchers&, const Function<string&()>*) const {
362// // Removes const from this, calls overload 1
363// return AdjustConstness_(this)->gmock_GetName();
364// }
365//
366// // Overload 3
367// const string& gmock_GetName() const { ... }
368// // Overload 4
369// MockSpec<const string&()> gmock_GetName(
370// const WithoutMatchers&, const Function<const string&()>*) const {
371// // Does not remove const, calls overload 3
372// return AdjustConstness_const(this)->gmock_GetName();
373// }
374// }
375//
376template <typename MockType>
377const MockType* AdjustConstness_const(const MockType* mock) {
378 return mock;
379}
380
381// Removes const from and returns the given pointer; this is a helper for the
382// expectation setter method for parameterless matchers.
383template <typename MockType>
384MockType* AdjustConstness_(const MockType* mock) {
385 return const_cast<MockType*>(mock);
386}
387
388} // namespace internal
389
390// The style guide prohibits "using" statements in a namespace scope
391// inside a header file. However, the FunctionMocker class template
392// is meant to be defined in the ::testing namespace. The following
393// line is just a trick for working around a bug in MSVC 8.0, which
394// cannot handle it if we define FunctionMocker in ::testing.
395using internal::FunctionMocker;
396
397// GMOCK_RESULT_(tn, F) expands to the result type of function type F.
398// We define this as a variadic macro in case F contains unprotected
399// commas (the same reason that we use variadic macros in other places
400// in this file).
401// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
402#define GMOCK_RESULT_(tn, ...) \
403 tn ::testing::internal::Function<__VA_ARGS__>::Result
404
405// The type of argument N of the given function type.
406// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
407#define GMOCK_ARG_(tn, N, ...) \
408 tn ::testing::internal::Function<__VA_ARGS__>::Argument##N
409
410// The matcher type for argument N of the given function type.
411// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
412#define GMOCK_MATCHER_(tn, N, ...) \
413 const ::testing::Matcher<GMOCK_ARG_(tn, N, __VA_ARGS__)>&
414
415// The variable for mocking the given method.
416// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
417#define GMOCK_MOCKER_(arity, constness, Method) \
418 GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
419
420// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
421#define GMOCK_METHOD0_(tn, constness, ct, Method, ...) \
422 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method() constness { \
423 GTEST_COMPILE_ASSERT_( \
424 (::testing::tuple_size<tn ::testing::internal::Function< \
425 __VA_ARGS__>::ArgumentTuple>::value == 0), \
426 this_method_does_not_take_0_arguments); \
427 GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \
428 return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
429 } \
430 ::testing::MockSpec<__VA_ARGS__> gmock_##Method() constness { \
431 GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \
432 return GMOCK_MOCKER_(0, constness, Method).With(); \
433 } \
434 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
435 const ::testing::internal::WithoutMatchers&, \
436 constness ::testing::internal::Function<__VA_ARGS__>*) const { \
437 return ::testing::internal::AdjustConstness_##constness(this) \
438 ->gmock_##Method(); \
439 } \
440 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(0, constness, \
441 Method)
442
443// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
444#define GMOCK_METHOD1_(tn, constness, ct, Method, ...) \
445 GMOCK_RESULT_(tn, __VA_ARGS__) \
446 ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
447 GTEST_COMPILE_ASSERT_( \
448 (::testing::tuple_size<tn ::testing::internal::Function< \
449 __VA_ARGS__>::ArgumentTuple>::value == 1), \
450 this_method_does_not_take_1_argument); \
451 GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \
452 return GMOCK_MOCKER_(1, constness, Method) \
453 .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
454 gmock_a1)); \
455 } \
456 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
457 GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
458 GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \
459 return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \
460 } \
461 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
462 const ::testing::internal::WithoutMatchers&, \
463 constness ::testing::internal::Function<__VA_ARGS__>*) const { \
464 return ::testing::internal::AdjustConstness_##constness(this) \
465 ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>()); \
466 } \
467 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(1, constness, \
468 Method)
469
470// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
471#define GMOCK_METHOD2_(tn, constness, ct, Method, ...) \
472 GMOCK_RESULT_(tn, __VA_ARGS__) \
473 ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
474 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
475 GTEST_COMPILE_ASSERT_( \
476 (::testing::tuple_size<tn ::testing::internal::Function< \
477 __VA_ARGS__>::ArgumentTuple>::value == 2), \
478 this_method_does_not_take_2_arguments); \
479 GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \
480 return GMOCK_MOCKER_(2, constness, Method) \
481 .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
482 gmock_a1), \
483 ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
484 gmock_a2)); \
485 } \
486 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
487 GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
488 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
489 GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \
490 return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \
491 } \
492 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
493 const ::testing::internal::WithoutMatchers&, \
494 constness ::testing::internal::Function<__VA_ARGS__>*) const { \
495 return ::testing::internal::AdjustConstness_##constness(this) \
496 ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
497 ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>()); \
498 } \
499 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(2, constness, \
500 Method)
501
502// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
503#define GMOCK_METHOD3_(tn, constness, ct, Method, ...) \
504 GMOCK_RESULT_(tn, __VA_ARGS__) \
505 ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
506 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
507 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
508 GTEST_COMPILE_ASSERT_( \
509 (::testing::tuple_size<tn ::testing::internal::Function< \
510 __VA_ARGS__>::ArgumentTuple>::value == 3), \
511 this_method_does_not_take_3_arguments); \
512 GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \
513 return GMOCK_MOCKER_(3, constness, Method) \
514 .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
515 gmock_a1), \
516 ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
517 gmock_a2), \
518 ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
519 gmock_a3)); \
520 } \
521 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
522 GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
523 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
524 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
525 GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \
526 return GMOCK_MOCKER_(3, constness, Method) \
527 .With(gmock_a1, gmock_a2, gmock_a3); \
528 } \
529 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
530 const ::testing::internal::WithoutMatchers&, \
531 constness ::testing::internal::Function<__VA_ARGS__>*) const { \
532 return ::testing::internal::AdjustConstness_##constness(this) \
533 ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
534 ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
535 ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>()); \
536 } \
537 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(3, constness, \
538 Method)
539
540// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
541#define GMOCK_METHOD4_(tn, constness, ct, Method, ...) \
542 GMOCK_RESULT_(tn, __VA_ARGS__) \
543 ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
544 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
545 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
546 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
547 GTEST_COMPILE_ASSERT_( \
548 (::testing::tuple_size<tn ::testing::internal::Function< \
549 __VA_ARGS__>::ArgumentTuple>::value == 4), \
550 this_method_does_not_take_4_arguments); \
551 GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \
552 return GMOCK_MOCKER_(4, constness, Method) \
553 .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
554 gmock_a1), \
555 ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
556 gmock_a2), \
557 ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
558 gmock_a3), \
559 ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
560 gmock_a4)); \
561 } \
562 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
563 GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
564 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
565 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
566 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
567 GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \
568 return GMOCK_MOCKER_(4, constness, Method) \
569 .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4); \
570 } \
571 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
572 const ::testing::internal::WithoutMatchers&, \
573 constness ::testing::internal::Function<__VA_ARGS__>*) const { \
574 return ::testing::internal::AdjustConstness_##constness(this) \
575 ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
576 ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
577 ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
578 ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>()); \
579 } \
580 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(4, constness, \
581 Method)
582
583// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
584#define GMOCK_METHOD5_(tn, constness, ct, Method, ...) \
585 GMOCK_RESULT_(tn, __VA_ARGS__) \
586 ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
587 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
588 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
589 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
590 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
591 GTEST_COMPILE_ASSERT_( \
592 (::testing::tuple_size<tn ::testing::internal::Function< \
593 __VA_ARGS__>::ArgumentTuple>::value == 5), \
594 this_method_does_not_take_5_arguments); \
595 GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \
596 return GMOCK_MOCKER_(5, constness, Method) \
597 .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
598 gmock_a1), \
599 ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
600 gmock_a2), \
601 ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
602 gmock_a3), \
603 ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
604 gmock_a4), \
605 ::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
606 gmock_a5)); \
607 } \
608 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
609 GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
610 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
611 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
612 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
613 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
614 GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \
615 return GMOCK_MOCKER_(5, constness, Method) \
616 .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5); \
617 } \
618 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
619 const ::testing::internal::WithoutMatchers&, \
620 constness ::testing::internal::Function<__VA_ARGS__>*) const { \
621 return ::testing::internal::AdjustConstness_##constness(this) \
622 ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
623 ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
624 ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
625 ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
626 ::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>()); \
627 } \
628 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(5, constness, \
629 Method)
630
631// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
632#define GMOCK_METHOD6_(tn, constness, ct, Method, ...) \
633 GMOCK_RESULT_(tn, __VA_ARGS__) \
634 ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
635 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
636 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
637 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
638 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
639 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
640 GTEST_COMPILE_ASSERT_( \
641 (::testing::tuple_size<tn ::testing::internal::Function< \
642 __VA_ARGS__>::ArgumentTuple>::value == 6), \
643 this_method_does_not_take_6_arguments); \
644 GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \
645 return GMOCK_MOCKER_(6, constness, Method) \
646 .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
647 gmock_a1), \
648 ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
649 gmock_a2), \
650 ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
651 gmock_a3), \
652 ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
653 gmock_a4), \
654 ::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
655 gmock_a5), \
656 ::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
657 gmock_a6)); \
658 } \
659 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
660 GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
661 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
662 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
663 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
664 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
665 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
666 GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \
667 return GMOCK_MOCKER_(6, constness, Method) \
668 .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
669 } \
670 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
671 const ::testing::internal::WithoutMatchers&, \
672 constness ::testing::internal::Function<__VA_ARGS__>*) const { \
673 return ::testing::internal::AdjustConstness_##constness(this) \
674 ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
675 ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
676 ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
677 ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
678 ::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
679 ::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>()); \
680 } \
681 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(6, constness, \
682 Method)
683
684// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
685#define GMOCK_METHOD7_(tn, constness, ct, Method, ...) \
686 GMOCK_RESULT_(tn, __VA_ARGS__) \
687 ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
688 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
689 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
690 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
691 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
692 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
693 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
694 GTEST_COMPILE_ASSERT_( \
695 (::testing::tuple_size<tn ::testing::internal::Function< \
696 __VA_ARGS__>::ArgumentTuple>::value == 7), \
697 this_method_does_not_take_7_arguments); \
698 GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \
699 return GMOCK_MOCKER_(7, constness, Method) \
700 .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
701 gmock_a1), \
702 ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
703 gmock_a2), \
704 ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
705 gmock_a3), \
706 ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
707 gmock_a4), \
708 ::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
709 gmock_a5), \
710 ::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
711 gmock_a6), \
712 ::testing::internal::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>( \
713 gmock_a7)); \
714 } \
715 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
716 GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
717 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
718 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
719 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
720 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
721 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
722 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
723 GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \
724 return GMOCK_MOCKER_(7, constness, Method) \
725 .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6, \
726 gmock_a7); \
727 } \
728 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
729 const ::testing::internal::WithoutMatchers&, \
730 constness ::testing::internal::Function<__VA_ARGS__>*) const { \
731 return ::testing::internal::AdjustConstness_##constness(this) \
732 ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
733 ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
734 ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
735 ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
736 ::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
737 ::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
738 ::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>()); \
739 } \
740 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(7, constness, \
741 Method)
742
743// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
744#define GMOCK_METHOD8_(tn, constness, ct, Method, ...) \
745 GMOCK_RESULT_(tn, __VA_ARGS__) \
746 ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
747 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
748 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
749 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
750 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
751 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
752 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
753 GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
754 GTEST_COMPILE_ASSERT_( \
755 (::testing::tuple_size<tn ::testing::internal::Function< \
756 __VA_ARGS__>::ArgumentTuple>::value == 8), \
757 this_method_does_not_take_8_arguments); \
758 GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \
759 return GMOCK_MOCKER_(8, constness, Method) \
760 .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
761 gmock_a1), \
762 ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
763 gmock_a2), \
764 ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
765 gmock_a3), \
766 ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
767 gmock_a4), \
768 ::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
769 gmock_a5), \
770 ::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
771 gmock_a6), \
772 ::testing::internal::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>( \
773 gmock_a7), \
774 ::testing::internal::forward<GMOCK_ARG_(tn, 8, __VA_ARGS__)>( \
775 gmock_a8)); \
776 } \
777 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
778 GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
779 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
780 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
781 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
782 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
783 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
784 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
785 GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
786 GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \
787 return GMOCK_MOCKER_(8, constness, Method) \
788 .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6, \
789 gmock_a7, gmock_a8); \
790 } \
791 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
792 const ::testing::internal::WithoutMatchers&, \
793 constness ::testing::internal::Function<__VA_ARGS__>*) const { \
794 return ::testing::internal::AdjustConstness_##constness(this) \
795 ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
796 ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
797 ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
798 ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
799 ::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
800 ::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
801 ::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(), \
802 ::testing::A<GMOCK_ARG_(tn, 8, __VA_ARGS__)>()); \
803 } \
804 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(8, constness, \
805 Method)
806
807// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
808#define GMOCK_METHOD9_(tn, constness, ct, Method, ...) \
809 GMOCK_RESULT_(tn, __VA_ARGS__) \
810 ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
811 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
812 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
813 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
814 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
815 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
816 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
817 GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
818 GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
819 GTEST_COMPILE_ASSERT_( \
820 (::testing::tuple_size<tn ::testing::internal::Function< \
821 __VA_ARGS__>::ArgumentTuple>::value == 9), \
822 this_method_does_not_take_9_arguments); \
823 GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \
824 return GMOCK_MOCKER_(9, constness, Method) \
825 .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
826 gmock_a1), \
827 ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
828 gmock_a2), \
829 ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
830 gmock_a3), \
831 ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
832 gmock_a4), \
833 ::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
834 gmock_a5), \
835 ::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
836 gmock_a6), \
837 ::testing::internal::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>( \
838 gmock_a7), \
839 ::testing::internal::forward<GMOCK_ARG_(tn, 8, __VA_ARGS__)>( \
840 gmock_a8), \
841 ::testing::internal::forward<GMOCK_ARG_(tn, 9, __VA_ARGS__)>( \
842 gmock_a9)); \
843 } \
844 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
845 GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
846 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
847 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
848 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
849 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
850 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
851 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
852 GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
853 GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
854 GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \
855 return GMOCK_MOCKER_(9, constness, Method) \
856 .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6, \
857 gmock_a7, gmock_a8, gmock_a9); \
858 } \
859 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
860 const ::testing::internal::WithoutMatchers&, \
861 constness ::testing::internal::Function<__VA_ARGS__>*) const { \
862 return ::testing::internal::AdjustConstness_##constness(this) \
863 ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
864 ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
865 ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
866 ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
867 ::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
868 ::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
869 ::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(), \
870 ::testing::A<GMOCK_ARG_(tn, 8, __VA_ARGS__)>(), \
871 ::testing::A<GMOCK_ARG_(tn, 9, __VA_ARGS__)>()); \
872 } \
873 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(9, constness, \
874 Method)
875
876// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
877#define GMOCK_METHOD10_(tn, constness, ct, Method, ...) \
878 GMOCK_RESULT_(tn, __VA_ARGS__) \
879 ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
880 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
881 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
882 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
883 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
884 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
885 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
886 GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
887 GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9, \
888 GMOCK_ARG_(tn, 10, __VA_ARGS__) gmock_a10) constness { \
889 GTEST_COMPILE_ASSERT_( \
890 (::testing::tuple_size<tn ::testing::internal::Function< \
891 __VA_ARGS__>::ArgumentTuple>::value == 10), \
892 this_method_does_not_take_10_arguments); \
893 GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \
894 return GMOCK_MOCKER_(10, constness, Method) \
895 .Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
896 gmock_a1), \
897 ::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
898 gmock_a2), \
899 ::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
900 gmock_a3), \
901 ::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
902 gmock_a4), \
903 ::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
904 gmock_a5), \
905 ::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
906 gmock_a6), \
907 ::testing::internal::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>( \
908 gmock_a7), \
909 ::testing::internal::forward<GMOCK_ARG_(tn, 8, __VA_ARGS__)>( \
910 gmock_a8), \
911 ::testing::internal::forward<GMOCK_ARG_(tn, 9, __VA_ARGS__)>( \
912 gmock_a9), \
913 ::testing::internal::forward<GMOCK_ARG_(tn, 10, __VA_ARGS__)>( \
914 gmock_a10)); \
915 } \
916 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
917 GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
918 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
919 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
920 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
921 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
922 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
923 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
924 GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
925 GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9, \
926 GMOCK_MATCHER_(tn, 10, __VA_ARGS__) gmock_a10) constness { \
927 GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \
928 return GMOCK_MOCKER_(10, constness, Method) \
929 .With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6, \
930 gmock_a7, gmock_a8, gmock_a9, gmock_a10); \
931 } \
932 ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
933 const ::testing::internal::WithoutMatchers&, \
934 constness ::testing::internal::Function<__VA_ARGS__>*) const { \
935 return ::testing::internal::AdjustConstness_##constness(this) \
936 ->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
937 ::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
938 ::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
939 ::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
940 ::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
941 ::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
942 ::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(), \
943 ::testing::A<GMOCK_ARG_(tn, 8, __VA_ARGS__)>(), \
944 ::testing::A<GMOCK_ARG_(tn, 9, __VA_ARGS__)>(), \
945 ::testing::A<GMOCK_ARG_(tn, 10, __VA_ARGS__)>()); \
946 } \
947 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(10, constness, \
948 Method)
949
950#define MOCK_METHOD0(m, ...) GMOCK_METHOD0_(, , , m, __VA_ARGS__)
951#define MOCK_METHOD1(m, ...) GMOCK_METHOD1_(, , , m, __VA_ARGS__)
952#define MOCK_METHOD2(m, ...) GMOCK_METHOD2_(, , , m, __VA_ARGS__)
953#define MOCK_METHOD3(m, ...) GMOCK_METHOD3_(, , , m, __VA_ARGS__)
954#define MOCK_METHOD4(m, ...) GMOCK_METHOD4_(, , , m, __VA_ARGS__)
955#define MOCK_METHOD5(m, ...) GMOCK_METHOD5_(, , , m, __VA_ARGS__)
956#define MOCK_METHOD6(m, ...) GMOCK_METHOD6_(, , , m, __VA_ARGS__)
957#define MOCK_METHOD7(m, ...) GMOCK_METHOD7_(, , , m, __VA_ARGS__)
958#define MOCK_METHOD8(m, ...) GMOCK_METHOD8_(, , , m, __VA_ARGS__)
959#define MOCK_METHOD9(m, ...) GMOCK_METHOD9_(, , , m, __VA_ARGS__)
960#define MOCK_METHOD10(m, ...) GMOCK_METHOD10_(, , , m, __VA_ARGS__)
961
962#define MOCK_CONST_METHOD0(m, ...) GMOCK_METHOD0_(, const, , m, __VA_ARGS__)
963#define MOCK_CONST_METHOD1(m, ...) GMOCK_METHOD1_(, const, , m, __VA_ARGS__)
964#define MOCK_CONST_METHOD2(m, ...) GMOCK_METHOD2_(, const, , m, __VA_ARGS__)
965#define MOCK_CONST_METHOD3(m, ...) GMOCK_METHOD3_(, const, , m, __VA_ARGS__)
966#define MOCK_CONST_METHOD4(m, ...) GMOCK_METHOD4_(, const, , m, __VA_ARGS__)
967#define MOCK_CONST_METHOD5(m, ...) GMOCK_METHOD5_(, const, , m, __VA_ARGS__)
968#define MOCK_CONST_METHOD6(m, ...) GMOCK_METHOD6_(, const, , m, __VA_ARGS__)
969#define MOCK_CONST_METHOD7(m, ...) GMOCK_METHOD7_(, const, , m, __VA_ARGS__)
970#define MOCK_CONST_METHOD8(m, ...) GMOCK_METHOD8_(, const, , m, __VA_ARGS__)
971#define MOCK_CONST_METHOD9(m, ...) GMOCK_METHOD9_(, const, , m, __VA_ARGS__)
972#define MOCK_CONST_METHOD10(m, ...) GMOCK_METHOD10_(, const, , m, __VA_ARGS__)
973
974#define MOCK_METHOD0_T(m, ...) GMOCK_METHOD0_(typename, , , m, __VA_ARGS__)
975#define MOCK_METHOD1_T(m, ...) GMOCK_METHOD1_(typename, , , m, __VA_ARGS__)
976#define MOCK_METHOD2_T(m, ...) GMOCK_METHOD2_(typename, , , m, __VA_ARGS__)
977#define MOCK_METHOD3_T(m, ...) GMOCK_METHOD3_(typename, , , m, __VA_ARGS__)
978#define MOCK_METHOD4_T(m, ...) GMOCK_METHOD4_(typename, , , m, __VA_ARGS__)
979#define MOCK_METHOD5_T(m, ...) GMOCK_METHOD5_(typename, , , m, __VA_ARGS__)
980#define MOCK_METHOD6_T(m, ...) GMOCK_METHOD6_(typename, , , m, __VA_ARGS__)
981#define MOCK_METHOD7_T(m, ...) GMOCK_METHOD7_(typename, , , m, __VA_ARGS__)
982#define MOCK_METHOD8_T(m, ...) GMOCK_METHOD8_(typename, , , m, __VA_ARGS__)
983#define MOCK_METHOD9_T(m, ...) GMOCK_METHOD9_(typename, , , m, __VA_ARGS__)
984#define MOCK_METHOD10_T(m, ...) GMOCK_METHOD10_(typename, , , m, __VA_ARGS__)
985
986#define MOCK_CONST_METHOD0_T(m, ...) \
987 GMOCK_METHOD0_(typename, const, , m, __VA_ARGS__)
988#define MOCK_CONST_METHOD1_T(m, ...) \
989 GMOCK_METHOD1_(typename, const, , m, __VA_ARGS__)
990#define MOCK_CONST_METHOD2_T(m, ...) \
991 GMOCK_METHOD2_(typename, const, , m, __VA_ARGS__)
992#define MOCK_CONST_METHOD3_T(m, ...) \
993 GMOCK_METHOD3_(typename, const, , m, __VA_ARGS__)
994#define MOCK_CONST_METHOD4_T(m, ...) \
995 GMOCK_METHOD4_(typename, const, , m, __VA_ARGS__)
996#define MOCK_CONST_METHOD5_T(m, ...) \
997 GMOCK_METHOD5_(typename, const, , m, __VA_ARGS__)
998#define MOCK_CONST_METHOD6_T(m, ...) \
999 GMOCK_METHOD6_(typename, const, , m, __VA_ARGS__)
1000#define MOCK_CONST_METHOD7_T(m, ...) \
1001 GMOCK_METHOD7_(typename, const, , m, __VA_ARGS__)
1002#define MOCK_CONST_METHOD8_T(m, ...) \
1003 GMOCK_METHOD8_(typename, const, , m, __VA_ARGS__)
1004#define MOCK_CONST_METHOD9_T(m, ...) \
1005 GMOCK_METHOD9_(typename, const, , m, __VA_ARGS__)
1006#define MOCK_CONST_METHOD10_T(m, ...) \
1007 GMOCK_METHOD10_(typename, const, , m, __VA_ARGS__)
1008
1009#define MOCK_METHOD0_WITH_CALLTYPE(ct, m, ...) \
1010 GMOCK_METHOD0_(, , ct, m, __VA_ARGS__)
1011#define MOCK_METHOD1_WITH_CALLTYPE(ct, m, ...) \
1012 GMOCK_METHOD1_(, , ct, m, __VA_ARGS__)
1013#define MOCK_METHOD2_WITH_CALLTYPE(ct, m, ...) \
1014 GMOCK_METHOD2_(, , ct, m, __VA_ARGS__)
1015#define MOCK_METHOD3_WITH_CALLTYPE(ct, m, ...) \
1016 GMOCK_METHOD3_(, , ct, m, __VA_ARGS__)
1017#define MOCK_METHOD4_WITH_CALLTYPE(ct, m, ...) \
1018 GMOCK_METHOD4_(, , ct, m, __VA_ARGS__)
1019#define MOCK_METHOD5_WITH_CALLTYPE(ct, m, ...) \
1020 GMOCK_METHOD5_(, , ct, m, __VA_ARGS__)
1021#define MOCK_METHOD6_WITH_CALLTYPE(ct, m, ...) \
1022 GMOCK_METHOD6_(, , ct, m, __VA_ARGS__)
1023#define MOCK_METHOD7_WITH_CALLTYPE(ct, m, ...) \
1024 GMOCK_METHOD7_(, , ct, m, __VA_ARGS__)
1025#define MOCK_METHOD8_WITH_CALLTYPE(ct, m, ...) \
1026 GMOCK_METHOD8_(, , ct, m, __VA_ARGS__)
1027#define MOCK_METHOD9_WITH_CALLTYPE(ct, m, ...) \
1028 GMOCK_METHOD9_(, , ct, m, __VA_ARGS__)
1029#define MOCK_METHOD10_WITH_CALLTYPE(ct, m, ...) \
1030 GMOCK_METHOD10_(, , ct, m, __VA_ARGS__)
1031
1032#define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, ...) \
1033 GMOCK_METHOD0_(, const, ct, m, __VA_ARGS__)
1034#define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, ...) \
1035 GMOCK_METHOD1_(, const, ct, m, __VA_ARGS__)
1036#define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, ...) \
1037 GMOCK_METHOD2_(, const, ct, m, __VA_ARGS__)
1038#define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, ...) \
1039 GMOCK_METHOD3_(, const, ct, m, __VA_ARGS__)
1040#define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, ...) \
1041 GMOCK_METHOD4_(, const, ct, m, __VA_ARGS__)
1042#define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, ...) \
1043 GMOCK_METHOD5_(, const, ct, m, __VA_ARGS__)
1044#define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, ...) \
1045 GMOCK_METHOD6_(, const, ct, m, __VA_ARGS__)
1046#define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, ...) \
1047 GMOCK_METHOD7_(, const, ct, m, __VA_ARGS__)
1048#define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, ...) \
1049 GMOCK_METHOD8_(, const, ct, m, __VA_ARGS__)
1050#define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, ...) \
1051 GMOCK_METHOD9_(, const, ct, m, __VA_ARGS__)
1052#define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, ...) \
1053 GMOCK_METHOD10_(, const, ct, m, __VA_ARGS__)
1054
1055#define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
1056 GMOCK_METHOD0_(typename, , ct, m, __VA_ARGS__)
1057#define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
1058 GMOCK_METHOD1_(typename, , ct, m, __VA_ARGS__)
1059#define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
1060 GMOCK_METHOD2_(typename, , ct, m, __VA_ARGS__)
1061#define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
1062 GMOCK_METHOD3_(typename, , ct, m, __VA_ARGS__)
1063#define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
1064 GMOCK_METHOD4_(typename, , ct, m, __VA_ARGS__)
1065#define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
1066 GMOCK_METHOD5_(typename, , ct, m, __VA_ARGS__)
1067#define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
1068 GMOCK_METHOD6_(typename, , ct, m, __VA_ARGS__)
1069#define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
1070 GMOCK_METHOD7_(typename, , ct, m, __VA_ARGS__)
1071#define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
1072 GMOCK_METHOD8_(typename, , ct, m, __VA_ARGS__)
1073#define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
1074 GMOCK_METHOD9_(typename, , ct, m, __VA_ARGS__)
1075#define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
1076 GMOCK_METHOD10_(typename, , ct, m, __VA_ARGS__)
1077
1078#define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
1079 GMOCK_METHOD0_(typename, const, ct, m, __VA_ARGS__)
1080#define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
1081 GMOCK_METHOD1_(typename, const, ct, m, __VA_ARGS__)
1082#define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
1083 GMOCK_METHOD2_(typename, const, ct, m, __VA_ARGS__)
1084#define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
1085 GMOCK_METHOD3_(typename, const, ct, m, __VA_ARGS__)
1086#define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
1087 GMOCK_METHOD4_(typename, const, ct, m, __VA_ARGS__)
1088#define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
1089 GMOCK_METHOD5_(typename, const, ct, m, __VA_ARGS__)
1090#define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
1091 GMOCK_METHOD6_(typename, const, ct, m, __VA_ARGS__)
1092#define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
1093 GMOCK_METHOD7_(typename, const, ct, m, __VA_ARGS__)
1094#define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
1095 GMOCK_METHOD8_(typename, const, ct, m, __VA_ARGS__)
1096#define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
1097 GMOCK_METHOD9_(typename, const, ct, m, __VA_ARGS__)
1098#define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
1099 GMOCK_METHOD10_(typename, const, ct, m, __VA_ARGS__)
1100
1101// A MockFunction<F> class has one mock method whose type is F. It is
1102// useful when you just want your test code to emit some messages and
1103// have Google Mock verify the right messages are sent (and perhaps at
1104// the right times). For example, if you are exercising code:
1105//
1106// Foo(1);
1107// Foo(2);
1108// Foo(3);
1109//
1110// and want to verify that Foo(1) and Foo(3) both invoke
1111// mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
1112//
1113// TEST(FooTest, InvokesBarCorrectly) {
1114// MyMock mock;
1115// MockFunction<void(string check_point_name)> check;
1116// {
1117// InSequence s;
1118//
1119// EXPECT_CALL(mock, Bar("a"));
1120// EXPECT_CALL(check, Call("1"));
1121// EXPECT_CALL(check, Call("2"));
1122// EXPECT_CALL(mock, Bar("a"));
1123// }
1124// Foo(1);
1125// check.Call("1");
1126// Foo(2);
1127// check.Call("2");
1128// Foo(3);
1129// }
1130//
1131// The expectation spec says that the first Bar("a") must happen
1132// before check point "1", the second Bar("a") must happen after check
1133// point "2", and nothing should happen between the two check
1134// points. The explicit check points make it easy to tell which
1135// Bar("a") is called by which call to Foo().
1136//
1137// MockFunction<F> can also be used to exercise code that accepts
1138// std::function<F> callbacks. To do so, use AsStdFunction() method
1139// to create std::function proxy forwarding to original object's Call.
1140// Example:
1141//
1142// TEST(FooTest, RunsCallbackWithBarArgument) {
1143// MockFunction<int(string)> callback;
1144// EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1));
1145// Foo(callback.AsStdFunction());
1146// }
1147template <typename F>
1148class MockFunction;
1149
1150template <typename R>
1151class MockFunction<R()> {
1152 public:
1153 MockFunction() {}
1154
1155 MOCK_METHOD0_T(Call, R());
1156
1157#if GTEST_HAS_STD_FUNCTION_
1158 ::std::function<R()> AsStdFunction() {
1159 return [this]() -> R {
1160 return this->Call();
1161 };
1162 }
1163#endif // GTEST_HAS_STD_FUNCTION_
1164
1165 private:
1166 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1167};
1168
1169template <typename R, typename A0>
1170class MockFunction<R(A0)> {
1171 public:
1172 MockFunction() {}
1173
1174 MOCK_METHOD1_T(Call, R(A0));
1175
1176#if GTEST_HAS_STD_FUNCTION_
1177 ::std::function<R(A0)> AsStdFunction() {
1178 return [this](A0 a0) -> R {
1179 return this->Call(::std::move(a0));
1180 };
1181 }
1182#endif // GTEST_HAS_STD_FUNCTION_
1183
1184 private:
1185 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1186};
1187
1188template <typename R, typename A0, typename A1>
1189class MockFunction<R(A0, A1)> {
1190 public:
1191 MockFunction() {}
1192
1193 MOCK_METHOD2_T(Call, R(A0, A1));
1194
1195#if GTEST_HAS_STD_FUNCTION_
1196 ::std::function<R(A0, A1)> AsStdFunction() {
1197 return [this](A0 a0, A1 a1) -> R {
1198 return this->Call(::std::move(a0), ::std::move(a1));
1199 };
1200 }
1201#endif // GTEST_HAS_STD_FUNCTION_
1202
1203 private:
1204 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1205};
1206
1207template <typename R, typename A0, typename A1, typename A2>
1208class MockFunction<R(A0, A1, A2)> {
1209 public:
1210 MockFunction() {}
1211
1212 MOCK_METHOD3_T(Call, R(A0, A1, A2));
1213
1214#if GTEST_HAS_STD_FUNCTION_
1215 ::std::function<R(A0, A1, A2)> AsStdFunction() {
1216 return [this](A0 a0, A1 a1, A2 a2) -> R {
1217 return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2));
1218 };
1219 }
1220#endif // GTEST_HAS_STD_FUNCTION_
1221
1222 private:
1223 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1224};
1225
1226template <typename R, typename A0, typename A1, typename A2, typename A3>
1227class MockFunction<R(A0, A1, A2, A3)> {
1228 public:
1229 MockFunction() {}
1230
1231 MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));
1232
1233#if GTEST_HAS_STD_FUNCTION_
1234 ::std::function<R(A0, A1, A2, A3)> AsStdFunction() {
1235 return [this](A0 a0, A1 a1, A2 a2, A3 a3) -> R {
1236 return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
1237 ::std::move(a3));
1238 };
1239 }
1240#endif // GTEST_HAS_STD_FUNCTION_
1241
1242 private:
1243 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1244};
1245
1246template <typename R, typename A0, typename A1, typename A2, typename A3,
1247 typename A4>
1248class MockFunction<R(A0, A1, A2, A3, A4)> {
1249 public:
1250 MockFunction() {}
1251
1252 MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));
1253
1254#if GTEST_HAS_STD_FUNCTION_
1255 ::std::function<R(A0, A1, A2, A3, A4)> AsStdFunction() {
1256 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) -> R {
1257 return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
1258 ::std::move(a3), ::std::move(a4));
1259 };
1260 }
1261#endif // GTEST_HAS_STD_FUNCTION_
1262
1263 private:
1264 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1265};
1266
1267template <typename R, typename A0, typename A1, typename A2, typename A3,
1268 typename A4, typename A5>
1269class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
1270 public:
1271 MockFunction() {}
1272
1273 MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));
1274
1275#if GTEST_HAS_STD_FUNCTION_
1276 ::std::function<R(A0, A1, A2, A3, A4, A5)> AsStdFunction() {
1277 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) -> R {
1278 return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
1279 ::std::move(a3), ::std::move(a4), ::std::move(a5));
1280 };
1281 }
1282#endif // GTEST_HAS_STD_FUNCTION_
1283
1284 private:
1285 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1286};
1287
1288template <typename R, typename A0, typename A1, typename A2, typename A3,
1289 typename A4, typename A5, typename A6>
1290class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
1291 public:
1292 MockFunction() {}
1293
1294 MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));
1295
1296#if GTEST_HAS_STD_FUNCTION_
1297 ::std::function<R(A0, A1, A2, A3, A4, A5, A6)> AsStdFunction() {
1298 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) -> R {
1299 return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
1300 ::std::move(a3), ::std::move(a4), ::std::move(a5), ::std::move(a6));
1301 };
1302 }
1303#endif // GTEST_HAS_STD_FUNCTION_
1304
1305 private:
1306 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1307};
1308
1309template <typename R, typename A0, typename A1, typename A2, typename A3,
1310 typename A4, typename A5, typename A6, typename A7>
1311class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
1312 public:
1313 MockFunction() {}
1314
1315 MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));
1316
1317#if GTEST_HAS_STD_FUNCTION_
1318 ::std::function<R(A0, A1, A2, A3, A4, A5, A6, A7)> AsStdFunction() {
1319 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) -> R {
1320 return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
1321 ::std::move(a3), ::std::move(a4), ::std::move(a5), ::std::move(a6),
1322 ::std::move(a7));
1323 };
1324 }
1325#endif // GTEST_HAS_STD_FUNCTION_
1326
1327 private:
1328 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1329};
1330
1331template <typename R, typename A0, typename A1, typename A2, typename A3,
1332 typename A4, typename A5, typename A6, typename A7, typename A8>
1333class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
1334 public:
1335 MockFunction() {}
1336
1337 MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));
1338
1339#if GTEST_HAS_STD_FUNCTION_
1340 ::std::function<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> AsStdFunction() {
1341 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7,
1342 A8 a8) -> R {
1343 return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
1344 ::std::move(a3), ::std::move(a4), ::std::move(a5), ::std::move(a6),
1345 ::std::move(a7), ::std::move(a8));
1346 };
1347 }
1348#endif // GTEST_HAS_STD_FUNCTION_
1349
1350 private:
1351 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1352};
1353
1354template <typename R, typename A0, typename A1, typename A2, typename A3,
1355 typename A4, typename A5, typename A6, typename A7, typename A8,
1356 typename A9>
1357class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
1358 public:
1359 MockFunction() {}
1360
1361 MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
1362
1363#if GTEST_HAS_STD_FUNCTION_
1364 ::std::function<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> AsStdFunction() {
1365 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7,
1366 A8 a8, A9 a9) -> R {
1367 return this->Call(::std::move(a0), ::std::move(a1), ::std::move(a2),
1368 ::std::move(a3), ::std::move(a4), ::std::move(a5), ::std::move(a6),
1369 ::std::move(a7), ::std::move(a8), ::std::move(a9));
1370 };
1371 }
1372#endif // GTEST_HAS_STD_FUNCTION_
1373
1374 private:
1375 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
1376};
1377
1378} // namespace testing
1379
1380#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
1381