blob: 7b334e4233c9de7f4d7d864fbb3abdbb08c8839e [file] [log] [blame]
shiqiane35fdd92008-12-10 05:08:54 +00001// This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
2
3// Copyright 2007, Google Inc.
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
9//
10// * Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12// * Redistributions in binary form must reproduce the above
13// copyright notice, this list of conditions and the following disclaimer
14// in the documentation and/or other materials provided with the
15// distribution.
16// * Neither the name of Google Inc. nor the names of its
17// contributors may be used to endorse or promote products derived from
18// this software without specific prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31//
32// Author: wan@google.com (Zhanyong Wan)
33
34// Google Mock - a framework for writing C++ mock classes.
35//
36// This file implements function mockers of various arities.
37
38#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
39#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
40
zhanyong.wan53e08c42010-09-14 05:38:21 +000041#include "gmock/gmock-spec-builders.h"
42#include "gmock/internal/gmock-internal-utils.h"
shiqiane35fdd92008-12-10 05:08:54 +000043
44namespace testing {
shiqiane35fdd92008-12-10 05:08:54 +000045namespace internal {
46
47template <typename F>
48class FunctionMockerBase;
49
50// Note: class FunctionMocker really belongs to the ::testing
51// namespace. However if we define it in ::testing, MSVC will
52// complain when classes in ::testing::internal declare it as a
53// friend class template. To workaround this compiler bug, we define
54// FunctionMocker in ::testing::internal and import it into ::testing.
55template <typename F>
56class FunctionMocker;
57
58template <typename R>
59class FunctionMocker<R()> : public
60 internal::FunctionMockerBase<R()> {
61 public:
62 typedef R F();
63 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
64
65 MockSpec<F>& With() {
66 return this->current_spec();
67 }
68
69 R Invoke() {
zhanyong.wan21a58462009-11-12 19:18:08 +000070 // Even though gcc and MSVC don't enforce it, 'this->' is required
71 // by the C++ standard [14.6.4] here, as the base class type is
72 // dependent on the template argument (and thus shouldn't be
73 // looked into when resolving InvokeWith).
74 return this->InvokeWith(ArgumentTuple());
shiqiane35fdd92008-12-10 05:08:54 +000075 }
76};
77
78template <typename R, typename A1>
79class FunctionMocker<R(A1)> : public
80 internal::FunctionMockerBase<R(A1)> {
81 public:
82 typedef R F(A1);
83 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
84
85 MockSpec<F>& With(const Matcher<A1>& m1) {
86 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1));
87 return this->current_spec();
88 }
89
90 R Invoke(A1 a1) {
zhanyong.wan21a58462009-11-12 19:18:08 +000091 // Even though gcc and MSVC don't enforce it, 'this->' is required
92 // by the C++ standard [14.6.4] here, as the base class type is
93 // dependent on the template argument (and thus shouldn't be
94 // looked into when resolving InvokeWith).
95 return this->InvokeWith(ArgumentTuple(a1));
shiqiane35fdd92008-12-10 05:08:54 +000096 }
97};
98
99template <typename R, typename A1, typename A2>
100class FunctionMocker<R(A1, A2)> : public
101 internal::FunctionMockerBase<R(A1, A2)> {
102 public:
103 typedef R F(A1, A2);
104 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
105
106 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2) {
107 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2));
108 return this->current_spec();
109 }
110
111 R Invoke(A1 a1, A2 a2) {
zhanyong.wan21a58462009-11-12 19:18:08 +0000112 // Even though gcc and MSVC don't enforce it, 'this->' is required
113 // by the C++ standard [14.6.4] here, as the base class type is
114 // dependent on the template argument (and thus shouldn't be
115 // looked into when resolving InvokeWith).
116 return this->InvokeWith(ArgumentTuple(a1, a2));
shiqiane35fdd92008-12-10 05:08:54 +0000117 }
118};
119
120template <typename R, typename A1, typename A2, typename A3>
121class FunctionMocker<R(A1, A2, A3)> : public
122 internal::FunctionMockerBase<R(A1, A2, A3)> {
123 public:
124 typedef R F(A1, A2, A3);
125 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
126
127 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
128 const Matcher<A3>& m3) {
129 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3));
130 return this->current_spec();
131 }
132
133 R Invoke(A1 a1, A2 a2, A3 a3) {
zhanyong.wan21a58462009-11-12 19:18:08 +0000134 // Even though gcc and MSVC don't enforce it, 'this->' is required
135 // by the C++ standard [14.6.4] here, as the base class type is
136 // dependent on the template argument (and thus shouldn't be
137 // looked into when resolving InvokeWith).
138 return this->InvokeWith(ArgumentTuple(a1, a2, a3));
shiqiane35fdd92008-12-10 05:08:54 +0000139 }
140};
141
142template <typename R, typename A1, typename A2, typename A3, typename A4>
143class FunctionMocker<R(A1, A2, A3, A4)> : public
144 internal::FunctionMockerBase<R(A1, A2, A3, A4)> {
145 public:
146 typedef R F(A1, A2, A3, A4);
147 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
148
149 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
150 const Matcher<A3>& m3, const Matcher<A4>& m4) {
151 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4));
152 return this->current_spec();
153 }
154
155 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) {
zhanyong.wan21a58462009-11-12 19:18:08 +0000156 // Even though gcc and MSVC don't enforce it, 'this->' is required
157 // by the C++ standard [14.6.4] here, as the base class type is
158 // dependent on the template argument (and thus shouldn't be
159 // looked into when resolving InvokeWith).
160 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4));
shiqiane35fdd92008-12-10 05:08:54 +0000161 }
162};
163
164template <typename R, typename A1, typename A2, typename A3, typename A4,
165 typename A5>
166class FunctionMocker<R(A1, A2, A3, A4, A5)> : public
167 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)> {
168 public:
169 typedef R F(A1, A2, A3, A4, A5);
170 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
171
172 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
173 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5) {
174 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
175 m5));
176 return this->current_spec();
177 }
178
179 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
zhanyong.wan21a58462009-11-12 19:18:08 +0000180 // Even though gcc and MSVC don't enforce it, 'this->' is required
181 // by the C++ standard [14.6.4] here, as the base class type is
182 // dependent on the template argument (and thus shouldn't be
183 // looked into when resolving InvokeWith).
184 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5));
shiqiane35fdd92008-12-10 05:08:54 +0000185 }
186};
187
188template <typename R, typename A1, typename A2, typename A3, typename A4,
189 typename A5, typename A6>
190class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public
191 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6)> {
192 public:
193 typedef R F(A1, A2, A3, A4, A5, A6);
194 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
195
196 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
197 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
198 const Matcher<A6>& m6) {
199 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
200 m6));
201 return this->current_spec();
202 }
203
204 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
zhanyong.wan21a58462009-11-12 19:18:08 +0000205 // Even though gcc and MSVC don't enforce it, 'this->' is required
206 // by the C++ standard [14.6.4] here, as the base class type is
207 // dependent on the template argument (and thus shouldn't be
208 // looked into when resolving InvokeWith).
209 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6));
shiqiane35fdd92008-12-10 05:08:54 +0000210 }
211};
212
213template <typename R, typename A1, typename A2, typename A3, typename A4,
214 typename A5, typename A6, typename A7>
215class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public
216 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)> {
217 public:
218 typedef R F(A1, A2, A3, A4, A5, A6, A7);
219 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
220
221 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
222 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
223 const Matcher<A6>& m6, const Matcher<A7>& m7) {
224 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
225 m6, m7));
226 return this->current_spec();
227 }
228
229 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
zhanyong.wan21a58462009-11-12 19:18:08 +0000230 // Even though gcc and MSVC don't enforce it, 'this->' is required
231 // by the C++ standard [14.6.4] here, as the base class type is
232 // dependent on the template argument (and thus shouldn't be
233 // looked into when resolving InvokeWith).
234 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7));
shiqiane35fdd92008-12-10 05:08:54 +0000235 }
236};
237
238template <typename R, typename A1, typename A2, typename A3, typename A4,
239 typename A5, typename A6, typename A7, typename A8>
240class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public
241 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
242 public:
243 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8);
244 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
245
246 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
247 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
248 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8) {
249 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
250 m6, m7, m8));
251 return this->current_spec();
252 }
253
254 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) {
zhanyong.wan21a58462009-11-12 19:18:08 +0000255 // Even though gcc and MSVC don't enforce it, 'this->' is required
256 // by the C++ standard [14.6.4] here, as the base class type is
257 // dependent on the template argument (and thus shouldn't be
258 // looked into when resolving InvokeWith).
259 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8));
shiqiane35fdd92008-12-10 05:08:54 +0000260 }
261};
262
263template <typename R, typename A1, typename A2, typename A3, typename A4,
264 typename A5, typename A6, typename A7, typename A8, typename A9>
265class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public
266 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
267 public:
268 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9);
269 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
270
271 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
272 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
273 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
274 const Matcher<A9>& m9) {
275 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
276 m6, m7, m8, m9));
277 return this->current_spec();
278 }
279
280 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) {
zhanyong.wan21a58462009-11-12 19:18:08 +0000281 // Even though gcc and MSVC don't enforce it, 'this->' is required
282 // by the C++ standard [14.6.4] here, as the base class type is
283 // dependent on the template argument (and thus shouldn't be
284 // looked into when resolving InvokeWith).
285 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9));
shiqiane35fdd92008-12-10 05:08:54 +0000286 }
287};
288
289template <typename R, typename A1, typename A2, typename A3, typename A4,
290 typename A5, typename A6, typename A7, typename A8, typename A9,
291 typename A10>
292class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
293 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> {
294 public:
295 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
296 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
297
298 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
299 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
300 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
301 const Matcher<A9>& m9, const Matcher<A10>& m10) {
302 this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
303 m6, m7, m8, m9, m10));
304 return this->current_spec();
305 }
306
307 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
308 A10 a10) {
zhanyong.wan21a58462009-11-12 19:18:08 +0000309 // Even though gcc and MSVC don't enforce it, 'this->' is required
310 // by the C++ standard [14.6.4] here, as the base class type is
311 // dependent on the template argument (and thus shouldn't be
312 // looked into when resolving InvokeWith).
313 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9,
314 a10));
shiqiane35fdd92008-12-10 05:08:54 +0000315 }
316};
317
318} // namespace internal
319
320// The style guide prohibits "using" statements in a namespace scope
321// inside a header file. However, the FunctionMocker class template
322// is meant to be defined in the ::testing namespace. The following
323// line is just a trick for working around a bug in MSVC 8.0, which
324// cannot handle it if we define FunctionMocker in ::testing.
325using internal::FunctionMocker;
326
327// The result type of function type F.
328// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000329#define GMOCK_RESULT_(tn, F) tn ::testing::internal::Function<F>::Result
shiqiane35fdd92008-12-10 05:08:54 +0000330
331// The type of argument N of function type F.
332// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000333#define GMOCK_ARG_(tn, F, N) tn ::testing::internal::Function<F>::Argument##N
shiqiane35fdd92008-12-10 05:08:54 +0000334
335// The matcher type for argument N of function type F.
336// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000337#define GMOCK_MATCHER_(tn, F, N) const ::testing::Matcher<GMOCK_ARG_(tn, F, N)>&
shiqiane35fdd92008-12-10 05:08:54 +0000338
339// The variable for mocking the given method.
340// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wan68be1112009-03-25 03:56:48 +0000341#define GMOCK_MOCKER_(arity, constness, Method) \
zhanyong.wanccedc1c2010-08-09 22:46:12 +0000342 GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
shiqiane35fdd92008-12-10 05:08:54 +0000343
344// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000345#define GMOCK_METHOD0_(tn, constness, ct, Method, F) \
346 GMOCK_RESULT_(tn, F) ct Method() constness { \
zhanyong.wan02f71062010-05-10 17:14:29 +0000347 GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
shiqiane35fdd92008-12-10 05:08:54 +0000348 tn ::testing::internal::Function<F>::ArgumentTuple>::value == 0, \
349 this_method_does_not_take_0_arguments); \
zhanyong.wan68be1112009-03-25 03:56:48 +0000350 GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \
351 return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
shiqiane35fdd92008-12-10 05:08:54 +0000352 } \
353 ::testing::MockSpec<F>& \
354 gmock_##Method() constness { \
zhanyong.wan68be1112009-03-25 03:56:48 +0000355 return GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this).With(); \
shiqiane35fdd92008-12-10 05:08:54 +0000356 } \
zhanyong.wan68be1112009-03-25 03:56:48 +0000357 mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(0, constness, Method)
shiqiane35fdd92008-12-10 05:08:54 +0000358
359// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000360#define GMOCK_METHOD1_(tn, constness, ct, Method, F) \
361 GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1) constness { \
zhanyong.wan02f71062010-05-10 17:14:29 +0000362 GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
shiqiane35fdd92008-12-10 05:08:54 +0000363 tn ::testing::internal::Function<F>::ArgumentTuple>::value == 1, \
364 this_method_does_not_take_1_argument); \
zhanyong.wan68be1112009-03-25 03:56:48 +0000365 GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \
366 return GMOCK_MOCKER_(1, constness, Method).Invoke(gmock_a1); \
shiqiane35fdd92008-12-10 05:08:54 +0000367 } \
368 ::testing::MockSpec<F>& \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000369 gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1) constness { \
zhanyong.wan68be1112009-03-25 03:56:48 +0000370 return GMOCK_MOCKER_(1, constness, \
371 Method).RegisterOwner(this).With(gmock_a1); \
shiqiane35fdd92008-12-10 05:08:54 +0000372 } \
zhanyong.wan68be1112009-03-25 03:56:48 +0000373 mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(1, constness, Method)
shiqiane35fdd92008-12-10 05:08:54 +0000374
375// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000376#define GMOCK_METHOD2_(tn, constness, ct, Method, F) \
377 GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
378 GMOCK_ARG_(tn, F, 2) gmock_a2) constness { \
zhanyong.wan02f71062010-05-10 17:14:29 +0000379 GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
shiqiane35fdd92008-12-10 05:08:54 +0000380 tn ::testing::internal::Function<F>::ArgumentTuple>::value == 2, \
381 this_method_does_not_take_2_arguments); \
zhanyong.wan68be1112009-03-25 03:56:48 +0000382 GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \
383 return GMOCK_MOCKER_(2, constness, Method).Invoke(gmock_a1, gmock_a2); \
shiqiane35fdd92008-12-10 05:08:54 +0000384 } \
385 ::testing::MockSpec<F>& \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000386 gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
387 GMOCK_MATCHER_(tn, F, 2) gmock_a2) constness { \
zhanyong.wan68be1112009-03-25 03:56:48 +0000388 return GMOCK_MOCKER_(2, constness, \
389 Method).RegisterOwner(this).With(gmock_a1, gmock_a2); \
shiqiane35fdd92008-12-10 05:08:54 +0000390 } \
zhanyong.wan68be1112009-03-25 03:56:48 +0000391 mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(2, constness, Method)
shiqiane35fdd92008-12-10 05:08:54 +0000392
393// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000394#define GMOCK_METHOD3_(tn, constness, ct, Method, F) \
395 GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
396 GMOCK_ARG_(tn, F, 2) gmock_a2, \
397 GMOCK_ARG_(tn, F, 3) gmock_a3) constness { \
zhanyong.wan02f71062010-05-10 17:14:29 +0000398 GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
shiqiane35fdd92008-12-10 05:08:54 +0000399 tn ::testing::internal::Function<F>::ArgumentTuple>::value == 3, \
400 this_method_does_not_take_3_arguments); \
zhanyong.wan68be1112009-03-25 03:56:48 +0000401 GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \
402 return GMOCK_MOCKER_(3, constness, Method).Invoke(gmock_a1, gmock_a2, \
403 gmock_a3); \
shiqiane35fdd92008-12-10 05:08:54 +0000404 } \
405 ::testing::MockSpec<F>& \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000406 gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
407 GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
408 GMOCK_MATCHER_(tn, F, 3) gmock_a3) constness { \
zhanyong.wan68be1112009-03-25 03:56:48 +0000409 return GMOCK_MOCKER_(3, constness, \
410 Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3); \
shiqiane35fdd92008-12-10 05:08:54 +0000411 } \
zhanyong.wan68be1112009-03-25 03:56:48 +0000412 mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(3, constness, Method)
shiqiane35fdd92008-12-10 05:08:54 +0000413
414// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000415#define GMOCK_METHOD4_(tn, constness, ct, Method, F) \
416 GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
417 GMOCK_ARG_(tn, F, 2) gmock_a2, \
418 GMOCK_ARG_(tn, F, 3) gmock_a3, \
419 GMOCK_ARG_(tn, F, 4) gmock_a4) constness { \
zhanyong.wan02f71062010-05-10 17:14:29 +0000420 GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
shiqiane35fdd92008-12-10 05:08:54 +0000421 tn ::testing::internal::Function<F>::ArgumentTuple>::value == 4, \
422 this_method_does_not_take_4_arguments); \
zhanyong.wan68be1112009-03-25 03:56:48 +0000423 GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \
424 return GMOCK_MOCKER_(4, constness, Method).Invoke(gmock_a1, gmock_a2, \
425 gmock_a3, gmock_a4); \
shiqiane35fdd92008-12-10 05:08:54 +0000426 } \
427 ::testing::MockSpec<F>& \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000428 gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
429 GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
430 GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
431 GMOCK_MATCHER_(tn, F, 4) gmock_a4) constness { \
zhanyong.wan68be1112009-03-25 03:56:48 +0000432 return GMOCK_MOCKER_(4, constness, \
433 Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
434 gmock_a4); \
shiqiane35fdd92008-12-10 05:08:54 +0000435 } \
zhanyong.wan68be1112009-03-25 03:56:48 +0000436 mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(4, constness, Method)
shiqiane35fdd92008-12-10 05:08:54 +0000437
438// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000439#define GMOCK_METHOD5_(tn, constness, ct, Method, F) \
440 GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
441 GMOCK_ARG_(tn, F, 2) gmock_a2, \
442 GMOCK_ARG_(tn, F, 3) gmock_a3, \
443 GMOCK_ARG_(tn, F, 4) gmock_a4, \
444 GMOCK_ARG_(tn, F, 5) gmock_a5) constness { \
zhanyong.wan02f71062010-05-10 17:14:29 +0000445 GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
shiqiane35fdd92008-12-10 05:08:54 +0000446 tn ::testing::internal::Function<F>::ArgumentTuple>::value == 5, \
447 this_method_does_not_take_5_arguments); \
zhanyong.wan68be1112009-03-25 03:56:48 +0000448 GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \
449 return GMOCK_MOCKER_(5, constness, Method).Invoke(gmock_a1, gmock_a2, \
450 gmock_a3, gmock_a4, gmock_a5); \
shiqiane35fdd92008-12-10 05:08:54 +0000451 } \
452 ::testing::MockSpec<F>& \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000453 gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
454 GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
455 GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
456 GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
457 GMOCK_MATCHER_(tn, F, 5) gmock_a5) constness { \
zhanyong.wan68be1112009-03-25 03:56:48 +0000458 return GMOCK_MOCKER_(5, constness, \
459 Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
460 gmock_a4, gmock_a5); \
shiqiane35fdd92008-12-10 05:08:54 +0000461 } \
zhanyong.wan68be1112009-03-25 03:56:48 +0000462 mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(5, constness, Method)
shiqiane35fdd92008-12-10 05:08:54 +0000463
464// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000465#define GMOCK_METHOD6_(tn, constness, ct, Method, F) \
466 GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
467 GMOCK_ARG_(tn, F, 2) gmock_a2, \
468 GMOCK_ARG_(tn, F, 3) gmock_a3, \
469 GMOCK_ARG_(tn, F, 4) gmock_a4, \
470 GMOCK_ARG_(tn, F, 5) gmock_a5, \
471 GMOCK_ARG_(tn, F, 6) gmock_a6) constness { \
zhanyong.wan02f71062010-05-10 17:14:29 +0000472 GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
shiqiane35fdd92008-12-10 05:08:54 +0000473 tn ::testing::internal::Function<F>::ArgumentTuple>::value == 6, \
474 this_method_does_not_take_6_arguments); \
zhanyong.wan68be1112009-03-25 03:56:48 +0000475 GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \
476 return GMOCK_MOCKER_(6, constness, Method).Invoke(gmock_a1, gmock_a2, \
477 gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
shiqiane35fdd92008-12-10 05:08:54 +0000478 } \
479 ::testing::MockSpec<F>& \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000480 gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
481 GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
482 GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
483 GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
484 GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
485 GMOCK_MATCHER_(tn, F, 6) gmock_a6) constness { \
zhanyong.wan68be1112009-03-25 03:56:48 +0000486 return GMOCK_MOCKER_(6, constness, \
487 Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
488 gmock_a4, gmock_a5, gmock_a6); \
shiqiane35fdd92008-12-10 05:08:54 +0000489 } \
zhanyong.wan68be1112009-03-25 03:56:48 +0000490 mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(6, constness, Method)
shiqiane35fdd92008-12-10 05:08:54 +0000491
492// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000493#define GMOCK_METHOD7_(tn, constness, ct, Method, F) \
494 GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
495 GMOCK_ARG_(tn, F, 2) gmock_a2, \
496 GMOCK_ARG_(tn, F, 3) gmock_a3, \
497 GMOCK_ARG_(tn, F, 4) gmock_a4, \
498 GMOCK_ARG_(tn, F, 5) gmock_a5, \
499 GMOCK_ARG_(tn, F, 6) gmock_a6, \
500 GMOCK_ARG_(tn, F, 7) gmock_a7) constness { \
zhanyong.wan02f71062010-05-10 17:14:29 +0000501 GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
shiqiane35fdd92008-12-10 05:08:54 +0000502 tn ::testing::internal::Function<F>::ArgumentTuple>::value == 7, \
503 this_method_does_not_take_7_arguments); \
zhanyong.wan68be1112009-03-25 03:56:48 +0000504 GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \
505 return GMOCK_MOCKER_(7, constness, Method).Invoke(gmock_a1, gmock_a2, \
506 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
shiqiane35fdd92008-12-10 05:08:54 +0000507 } \
508 ::testing::MockSpec<F>& \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000509 gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
510 GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
511 GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
512 GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
513 GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
514 GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
515 GMOCK_MATCHER_(tn, F, 7) gmock_a7) constness { \
zhanyong.wan68be1112009-03-25 03:56:48 +0000516 return GMOCK_MOCKER_(7, constness, \
517 Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
518 gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
shiqiane35fdd92008-12-10 05:08:54 +0000519 } \
zhanyong.wan68be1112009-03-25 03:56:48 +0000520 mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(7, constness, Method)
shiqiane35fdd92008-12-10 05:08:54 +0000521
522// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000523#define GMOCK_METHOD8_(tn, constness, ct, Method, F) \
524 GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
525 GMOCK_ARG_(tn, F, 2) gmock_a2, \
526 GMOCK_ARG_(tn, F, 3) gmock_a3, \
527 GMOCK_ARG_(tn, F, 4) gmock_a4, \
528 GMOCK_ARG_(tn, F, 5) gmock_a5, \
529 GMOCK_ARG_(tn, F, 6) gmock_a6, \
530 GMOCK_ARG_(tn, F, 7) gmock_a7, \
531 GMOCK_ARG_(tn, F, 8) gmock_a8) constness { \
zhanyong.wan02f71062010-05-10 17:14:29 +0000532 GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
shiqiane35fdd92008-12-10 05:08:54 +0000533 tn ::testing::internal::Function<F>::ArgumentTuple>::value == 8, \
534 this_method_does_not_take_8_arguments); \
zhanyong.wan68be1112009-03-25 03:56:48 +0000535 GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \
536 return GMOCK_MOCKER_(8, constness, Method).Invoke(gmock_a1, gmock_a2, \
537 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
shiqiane35fdd92008-12-10 05:08:54 +0000538 } \
539 ::testing::MockSpec<F>& \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000540 gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
541 GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
542 GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
543 GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
544 GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
545 GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
546 GMOCK_MATCHER_(tn, F, 7) gmock_a7, \
547 GMOCK_MATCHER_(tn, F, 8) gmock_a8) constness { \
zhanyong.wan68be1112009-03-25 03:56:48 +0000548 return GMOCK_MOCKER_(8, constness, \
549 Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
550 gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
shiqiane35fdd92008-12-10 05:08:54 +0000551 } \
zhanyong.wan68be1112009-03-25 03:56:48 +0000552 mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(8, constness, Method)
shiqiane35fdd92008-12-10 05:08:54 +0000553
554// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000555#define GMOCK_METHOD9_(tn, constness, ct, Method, F) \
556 GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
557 GMOCK_ARG_(tn, F, 2) gmock_a2, \
558 GMOCK_ARG_(tn, F, 3) gmock_a3, \
559 GMOCK_ARG_(tn, F, 4) gmock_a4, \
560 GMOCK_ARG_(tn, F, 5) gmock_a5, \
561 GMOCK_ARG_(tn, F, 6) gmock_a6, \
562 GMOCK_ARG_(tn, F, 7) gmock_a7, \
563 GMOCK_ARG_(tn, F, 8) gmock_a8, \
564 GMOCK_ARG_(tn, F, 9) gmock_a9) constness { \
zhanyong.wan02f71062010-05-10 17:14:29 +0000565 GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
shiqiane35fdd92008-12-10 05:08:54 +0000566 tn ::testing::internal::Function<F>::ArgumentTuple>::value == 9, \
567 this_method_does_not_take_9_arguments); \
zhanyong.wan68be1112009-03-25 03:56:48 +0000568 GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \
569 return GMOCK_MOCKER_(9, constness, Method).Invoke(gmock_a1, gmock_a2, \
570 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
571 gmock_a9); \
shiqiane35fdd92008-12-10 05:08:54 +0000572 } \
573 ::testing::MockSpec<F>& \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000574 gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
575 GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
576 GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
577 GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
578 GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
579 GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
580 GMOCK_MATCHER_(tn, F, 7) gmock_a7, \
581 GMOCK_MATCHER_(tn, F, 8) gmock_a8, \
582 GMOCK_MATCHER_(tn, F, 9) gmock_a9) constness { \
zhanyong.wan68be1112009-03-25 03:56:48 +0000583 return GMOCK_MOCKER_(9, constness, \
584 Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
585 gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9); \
shiqiane35fdd92008-12-10 05:08:54 +0000586 } \
zhanyong.wan68be1112009-03-25 03:56:48 +0000587 mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(9, constness, Method)
shiqiane35fdd92008-12-10 05:08:54 +0000588
589// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000590#define GMOCK_METHOD10_(tn, constness, ct, Method, F) \
591 GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
592 GMOCK_ARG_(tn, F, 2) gmock_a2, \
593 GMOCK_ARG_(tn, F, 3) gmock_a3, \
594 GMOCK_ARG_(tn, F, 4) gmock_a4, \
595 GMOCK_ARG_(tn, F, 5) gmock_a5, \
596 GMOCK_ARG_(tn, F, 6) gmock_a6, \
597 GMOCK_ARG_(tn, F, 7) gmock_a7, \
598 GMOCK_ARG_(tn, F, 8) gmock_a8, \
599 GMOCK_ARG_(tn, F, 9) gmock_a9, \
600 GMOCK_ARG_(tn, F, 10) gmock_a10) constness { \
zhanyong.wan02f71062010-05-10 17:14:29 +0000601 GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
shiqiane35fdd92008-12-10 05:08:54 +0000602 tn ::testing::internal::Function<F>::ArgumentTuple>::value == 10, \
603 this_method_does_not_take_10_arguments); \
zhanyong.wan68be1112009-03-25 03:56:48 +0000604 GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \
605 return GMOCK_MOCKER_(10, constness, Method).Invoke(gmock_a1, gmock_a2, \
606 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
shiqiane35fdd92008-12-10 05:08:54 +0000607 gmock_a10); \
608 } \
609 ::testing::MockSpec<F>& \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000610 gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
611 GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
612 GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
613 GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
614 GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
615 GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
616 GMOCK_MATCHER_(tn, F, 7) gmock_a7, \
617 GMOCK_MATCHER_(tn, F, 8) gmock_a8, \
618 GMOCK_MATCHER_(tn, F, 9) gmock_a9, \
619 GMOCK_MATCHER_(tn, F, 10) gmock_a10) constness { \
zhanyong.wan68be1112009-03-25 03:56:48 +0000620 return GMOCK_MOCKER_(10, constness, \
621 Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
622 gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
shiqiane35fdd92008-12-10 05:08:54 +0000623 gmock_a10); \
624 } \
zhanyong.wan68be1112009-03-25 03:56:48 +0000625 mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(10, constness, Method)
shiqiane35fdd92008-12-10 05:08:54 +0000626
zhanyong.wane0d051e2009-02-19 00:33:37 +0000627#define MOCK_METHOD0(m, F) GMOCK_METHOD0_(, , , m, F)
628#define MOCK_METHOD1(m, F) GMOCK_METHOD1_(, , , m, F)
629#define MOCK_METHOD2(m, F) GMOCK_METHOD2_(, , , m, F)
630#define MOCK_METHOD3(m, F) GMOCK_METHOD3_(, , , m, F)
631#define MOCK_METHOD4(m, F) GMOCK_METHOD4_(, , , m, F)
632#define MOCK_METHOD5(m, F) GMOCK_METHOD5_(, , , m, F)
633#define MOCK_METHOD6(m, F) GMOCK_METHOD6_(, , , m, F)
634#define MOCK_METHOD7(m, F) GMOCK_METHOD7_(, , , m, F)
635#define MOCK_METHOD8(m, F) GMOCK_METHOD8_(, , , m, F)
636#define MOCK_METHOD9(m, F) GMOCK_METHOD9_(, , , m, F)
637#define MOCK_METHOD10(m, F) GMOCK_METHOD10_(, , , m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000638
zhanyong.wane0d051e2009-02-19 00:33:37 +0000639#define MOCK_CONST_METHOD0(m, F) GMOCK_METHOD0_(, const, , m, F)
640#define MOCK_CONST_METHOD1(m, F) GMOCK_METHOD1_(, const, , m, F)
641#define MOCK_CONST_METHOD2(m, F) GMOCK_METHOD2_(, const, , m, F)
642#define MOCK_CONST_METHOD3(m, F) GMOCK_METHOD3_(, const, , m, F)
643#define MOCK_CONST_METHOD4(m, F) GMOCK_METHOD4_(, const, , m, F)
644#define MOCK_CONST_METHOD5(m, F) GMOCK_METHOD5_(, const, , m, F)
645#define MOCK_CONST_METHOD6(m, F) GMOCK_METHOD6_(, const, , m, F)
646#define MOCK_CONST_METHOD7(m, F) GMOCK_METHOD7_(, const, , m, F)
647#define MOCK_CONST_METHOD8(m, F) GMOCK_METHOD8_(, const, , m, F)
648#define MOCK_CONST_METHOD9(m, F) GMOCK_METHOD9_(, const, , m, F)
649#define MOCK_CONST_METHOD10(m, F) GMOCK_METHOD10_(, const, , m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000650
zhanyong.wane0d051e2009-02-19 00:33:37 +0000651#define MOCK_METHOD0_T(m, F) GMOCK_METHOD0_(typename, , , m, F)
652#define MOCK_METHOD1_T(m, F) GMOCK_METHOD1_(typename, , , m, F)
653#define MOCK_METHOD2_T(m, F) GMOCK_METHOD2_(typename, , , m, F)
654#define MOCK_METHOD3_T(m, F) GMOCK_METHOD3_(typename, , , m, F)
655#define MOCK_METHOD4_T(m, F) GMOCK_METHOD4_(typename, , , m, F)
656#define MOCK_METHOD5_T(m, F) GMOCK_METHOD5_(typename, , , m, F)
657#define MOCK_METHOD6_T(m, F) GMOCK_METHOD6_(typename, , , m, F)
658#define MOCK_METHOD7_T(m, F) GMOCK_METHOD7_(typename, , , m, F)
659#define MOCK_METHOD8_T(m, F) GMOCK_METHOD8_(typename, , , m, F)
660#define MOCK_METHOD9_T(m, F) GMOCK_METHOD9_(typename, , , m, F)
661#define MOCK_METHOD10_T(m, F) GMOCK_METHOD10_(typename, , , m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000662
zhanyong.wane0d051e2009-02-19 00:33:37 +0000663#define MOCK_CONST_METHOD0_T(m, F) GMOCK_METHOD0_(typename, const, , m, F)
664#define MOCK_CONST_METHOD1_T(m, F) GMOCK_METHOD1_(typename, const, , m, F)
665#define MOCK_CONST_METHOD2_T(m, F) GMOCK_METHOD2_(typename, const, , m, F)
666#define MOCK_CONST_METHOD3_T(m, F) GMOCK_METHOD3_(typename, const, , m, F)
667#define MOCK_CONST_METHOD4_T(m, F) GMOCK_METHOD4_(typename, const, , m, F)
668#define MOCK_CONST_METHOD5_T(m, F) GMOCK_METHOD5_(typename, const, , m, F)
669#define MOCK_CONST_METHOD6_T(m, F) GMOCK_METHOD6_(typename, const, , m, F)
670#define MOCK_CONST_METHOD7_T(m, F) GMOCK_METHOD7_(typename, const, , m, F)
671#define MOCK_CONST_METHOD8_T(m, F) GMOCK_METHOD8_(typename, const, , m, F)
672#define MOCK_CONST_METHOD9_T(m, F) GMOCK_METHOD9_(typename, const, , m, F)
673#define MOCK_CONST_METHOD10_T(m, F) GMOCK_METHOD10_(typename, const, , m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000674
zhanyong.wane0d051e2009-02-19 00:33:37 +0000675#define MOCK_METHOD0_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD0_(, , ct, m, F)
676#define MOCK_METHOD1_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD1_(, , ct, m, F)
677#define MOCK_METHOD2_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD2_(, , ct, m, F)
678#define MOCK_METHOD3_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD3_(, , ct, m, F)
679#define MOCK_METHOD4_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD4_(, , ct, m, F)
680#define MOCK_METHOD5_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD5_(, , ct, m, F)
681#define MOCK_METHOD6_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD6_(, , ct, m, F)
682#define MOCK_METHOD7_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD7_(, , ct, m, F)
683#define MOCK_METHOD8_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD8_(, , ct, m, F)
684#define MOCK_METHOD9_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD9_(, , ct, m, F)
685#define MOCK_METHOD10_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD10_(, , ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000686
687#define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000688 GMOCK_METHOD0_(, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000689#define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000690 GMOCK_METHOD1_(, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000691#define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000692 GMOCK_METHOD2_(, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000693#define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000694 GMOCK_METHOD3_(, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000695#define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000696 GMOCK_METHOD4_(, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000697#define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000698 GMOCK_METHOD5_(, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000699#define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000700 GMOCK_METHOD6_(, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000701#define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000702 GMOCK_METHOD7_(, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000703#define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000704 GMOCK_METHOD8_(, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000705#define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000706 GMOCK_METHOD9_(, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000707#define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000708 GMOCK_METHOD10_(, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000709
710#define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000711 GMOCK_METHOD0_(typename, , ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000712#define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000713 GMOCK_METHOD1_(typename, , ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000714#define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000715 GMOCK_METHOD2_(typename, , ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000716#define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000717 GMOCK_METHOD3_(typename, , ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000718#define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000719 GMOCK_METHOD4_(typename, , ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000720#define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000721 GMOCK_METHOD5_(typename, , ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000722#define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000723 GMOCK_METHOD6_(typename, , ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000724#define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000725 GMOCK_METHOD7_(typename, , ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000726#define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000727 GMOCK_METHOD8_(typename, , ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000728#define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000729 GMOCK_METHOD9_(typename, , ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000730#define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000731 GMOCK_METHOD10_(typename, , ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000732
733#define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000734 GMOCK_METHOD0_(typename, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000735#define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000736 GMOCK_METHOD1_(typename, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000737#define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000738 GMOCK_METHOD2_(typename, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000739#define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000740 GMOCK_METHOD3_(typename, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000741#define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000742 GMOCK_METHOD4_(typename, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000743#define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000744 GMOCK_METHOD5_(typename, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000745#define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000746 GMOCK_METHOD6_(typename, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000747#define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000748 GMOCK_METHOD7_(typename, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000749#define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000750 GMOCK_METHOD8_(typename, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000751#define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000752 GMOCK_METHOD9_(typename, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000753#define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, F) \
zhanyong.wane0d051e2009-02-19 00:33:37 +0000754 GMOCK_METHOD10_(typename, const, ct, m, F)
shiqiane35fdd92008-12-10 05:08:54 +0000755
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000756// A MockFunction<F> class has one mock method whose type is F. It is
757// useful when you just want your test code to emit some messages and
758// have Google Mock verify the right messages are sent (and perhaps at
759// the right times). For example, if you are exercising code:
760//
761// Foo(1);
762// Foo(2);
763// Foo(3);
764//
765// and want to verify that Foo(1) and Foo(3) both invoke
766// mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
767//
768// TEST(FooTest, InvokesBarCorrectly) {
769// MyMock mock;
770// MockFunction<void(string check_point_name)> check;
771// {
772// InSequence s;
773//
774// EXPECT_CALL(mock, Bar("a"));
775// EXPECT_CALL(check, Call("1"));
776// EXPECT_CALL(check, Call("2"));
777// EXPECT_CALL(mock, Bar("a"));
778// }
779// Foo(1);
780// check.Call("1");
781// Foo(2);
782// check.Call("2");
783// Foo(3);
784// }
785//
786// The expectation spec says that the first Bar("a") must happen
787// before check point "1", the second Bar("a") must happen after check
788// point "2", and nothing should happen between the two check
789// points. The explicit check points make it easy to tell which
790// Bar("a") is called by which call to Foo().
791template <typename F>
792class MockFunction;
793
794template <typename R>
795class MockFunction<R()> {
796 public:
zhanyong.wan32de5f52009-12-23 00:13:23 +0000797 MockFunction() {}
798
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000799 MOCK_METHOD0_T(Call, R());
zhanyong.wan32de5f52009-12-23 00:13:23 +0000800
801 private:
802 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000803};
804
805template <typename R, typename A0>
806class MockFunction<R(A0)> {
807 public:
zhanyong.wan32de5f52009-12-23 00:13:23 +0000808 MockFunction() {}
809
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000810 MOCK_METHOD1_T(Call, R(A0));
zhanyong.wan32de5f52009-12-23 00:13:23 +0000811
812 private:
813 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000814};
815
816template <typename R, typename A0, typename A1>
817class MockFunction<R(A0, A1)> {
818 public:
zhanyong.wan32de5f52009-12-23 00:13:23 +0000819 MockFunction() {}
820
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000821 MOCK_METHOD2_T(Call, R(A0, A1));
zhanyong.wan32de5f52009-12-23 00:13:23 +0000822
823 private:
824 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000825};
826
827template <typename R, typename A0, typename A1, typename A2>
828class MockFunction<R(A0, A1, A2)> {
829 public:
zhanyong.wan32de5f52009-12-23 00:13:23 +0000830 MockFunction() {}
831
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000832 MOCK_METHOD3_T(Call, R(A0, A1, A2));
zhanyong.wan32de5f52009-12-23 00:13:23 +0000833
834 private:
835 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000836};
837
838template <typename R, typename A0, typename A1, typename A2, typename A3>
839class MockFunction<R(A0, A1, A2, A3)> {
840 public:
zhanyong.wan32de5f52009-12-23 00:13:23 +0000841 MockFunction() {}
842
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000843 MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));
zhanyong.wan32de5f52009-12-23 00:13:23 +0000844
845 private:
846 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000847};
848
849template <typename R, typename A0, typename A1, typename A2, typename A3,
850 typename A4>
851class MockFunction<R(A0, A1, A2, A3, A4)> {
852 public:
zhanyong.wan32de5f52009-12-23 00:13:23 +0000853 MockFunction() {}
854
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000855 MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));
zhanyong.wan32de5f52009-12-23 00:13:23 +0000856
857 private:
858 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000859};
860
861template <typename R, typename A0, typename A1, typename A2, typename A3,
862 typename A4, typename A5>
863class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
864 public:
zhanyong.wan32de5f52009-12-23 00:13:23 +0000865 MockFunction() {}
866
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000867 MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));
zhanyong.wan32de5f52009-12-23 00:13:23 +0000868
869 private:
870 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000871};
872
873template <typename R, typename A0, typename A1, typename A2, typename A3,
874 typename A4, typename A5, typename A6>
875class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
876 public:
zhanyong.wan32de5f52009-12-23 00:13:23 +0000877 MockFunction() {}
878
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000879 MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));
zhanyong.wan32de5f52009-12-23 00:13:23 +0000880
881 private:
882 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000883};
884
885template <typename R, typename A0, typename A1, typename A2, typename A3,
886 typename A4, typename A5, typename A6, typename A7>
887class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
888 public:
zhanyong.wan32de5f52009-12-23 00:13:23 +0000889 MockFunction() {}
890
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000891 MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));
zhanyong.wan32de5f52009-12-23 00:13:23 +0000892
893 private:
894 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000895};
896
897template <typename R, typename A0, typename A1, typename A2, typename A3,
898 typename A4, typename A5, typename A6, typename A7, typename A8>
899class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
900 public:
zhanyong.wan32de5f52009-12-23 00:13:23 +0000901 MockFunction() {}
902
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000903 MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));
zhanyong.wan32de5f52009-12-23 00:13:23 +0000904
905 private:
906 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000907};
908
909template <typename R, typename A0, typename A1, typename A2, typename A3,
910 typename A4, typename A5, typename A6, typename A7, typename A8,
911 typename A9>
912class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
913 public:
zhanyong.wan32de5f52009-12-23 00:13:23 +0000914 MockFunction() {}
915
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000916 MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
zhanyong.wan32de5f52009-12-23 00:13:23 +0000917
918 private:
919 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
zhanyong.wanf3aa4d22009-09-25 22:34:47 +0000920};
921
shiqiane35fdd92008-12-10 05:08:54 +0000922} // namespace testing
923
924#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_