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// Author: wan@google.com (Zhanyong Wan) 35 36// Google Mock - a framework for writing C++ mock classes. 37// 38// This file implements function mockers of various arities. 39 40#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ 41#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ 42 43#include "gmock/gmock-spec-builders.h" 44#include "gmock/internal/gmock-internal-utils.h" 45 46#if GTEST_HAS_STD_FUNCTION_ 47# include <functional> 48#endif 49 50namespace testing { 51namespace internal { 52 53template <typename F> 54class FunctionMockerBase; 55 56// Note: class FunctionMocker really belongs to the ::testing 57// namespace. However if we define it in ::testing, MSVC will 58// complain when classes in ::testing::internal declare it as a 59// friend class template. To workaround this compiler bug, we define 60// FunctionMocker in ::testing::internal and import it into ::testing. 61template <typename F> 62class FunctionMocker; 63 64template <typename R> 65class FunctionMocker<R()> : public 66 internal::FunctionMockerBase<R()> { 67 public: 68 typedef R F(); 69 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; 70 71 MockSpec<F>& With() { 72 return this->current_spec(); 73 } 74 75 R Invoke() { 76 // Even though gcc and MSVC don't enforce it, 'this->' is required 77 // by the C++ standard [14.6.4] here, as the base class type is 78 // dependent on the template argument (and thus shouldn't be 79 // looked into when resolving InvokeWith). 80 return this->InvokeWith(ArgumentTuple()); 81 } 82}; 83 84template <typename R, typename A1> 85class FunctionMocker<R(A1)> : public 86 internal::FunctionMockerBase<R(A1)> { 87 public: 88 typedef R F(A1); 89 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; 90 91 MockSpec<F>& With(const Matcher<A1>& m1) { 92 this->current_spec().SetMatchers(::testing::make_tuple(m1)); 93 return this->current_spec(); 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(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 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2)); 114 return this->current_spec(); 115 } 116 117 R Invoke(A1 a1, A2 a2) { 118 // Even though gcc and MSVC don't enforce it, 'this->' is required 119 // by the C++ standard [14.6.4] here, as the base class type is 120 // dependent on the template argument (and thus shouldn't be 121 // looked into when resolving InvokeWith). 122 return this->InvokeWith(ArgumentTuple(a1, a2)); 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 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3)); 136 return this->current_spec(); 137 } 138 139 R Invoke(A1 a1, A2 a2, A3 a3) { 140 // Even though gcc and MSVC don't enforce it, 'this->' is required 141 // by the C++ standard [14.6.4] here, as the base class type is 142 // dependent on the template argument (and thus shouldn't be 143 // looked into when resolving InvokeWith). 144 return this->InvokeWith(ArgumentTuple(a1, a2, a3)); 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 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4)); 158 return this->current_spec(); 159 } 160 161 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) { 162 // Even though gcc and MSVC don't enforce it, 'this->' is required 163 // by the C++ standard [14.6.4] here, as the base class type is 164 // dependent on the template argument (and thus shouldn't be 165 // looked into when resolving InvokeWith). 166 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4)); 167 } 168}; 169 170template <typename R, typename A1, typename A2, typename A3, typename A4, 171 typename A5> 172class FunctionMocker<R(A1, A2, A3, A4, A5)> : public 173 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)> { 174 public: 175 typedef R F(A1, A2, A3, A4, A5); 176 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; 177 178 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, 179 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5) { 180 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5)); 181 return this->current_spec(); 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(a1, a2, a3, a4, a5)); 190 } 191}; 192 193template <typename R, typename A1, typename A2, typename A3, typename A4, 194 typename A5, typename A6> 195class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public 196 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6)> { 197 public: 198 typedef R F(A1, A2, A3, A4, A5, A6); 199 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; 200 201 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, 202 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, 203 const Matcher<A6>& m6) { 204 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5, 205 m6)); 206 return this->current_spec(); 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(a1, a2, a3, a4, a5, a6)); 215 } 216}; 217 218template <typename R, typename A1, typename A2, typename A3, typename A4, 219 typename A5, typename A6, typename A7> 220class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public 221 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)> { 222 public: 223 typedef R F(A1, A2, A3, A4, A5, A6, A7); 224 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; 225 226 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, 227 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, 228 const Matcher<A6>& m6, const Matcher<A7>& m7) { 229 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5, 230 m6, m7)); 231 return this->current_spec(); 232 } 233 234 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { 235 // Even though gcc and MSVC don't enforce it, 'this->' is required 236 // by the C++ standard [14.6.4] here, as the base class type is 237 // dependent on the template argument (and thus shouldn't be 238 // looked into when resolving InvokeWith). 239 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7)); 240 } 241}; 242 243template <typename R, typename A1, typename A2, typename A3, typename A4, 244 typename A5, typename A6, typename A7, typename A8> 245class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public 246 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)> { 247 public: 248 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8); 249 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; 250 251 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, 252 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, 253 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8) { 254 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5, 255 m6, m7, m8)); 256 return this->current_spec(); 257 } 258 259 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) { 260 // Even though gcc and MSVC don't enforce it, 'this->' is required 261 // by the C++ standard [14.6.4] here, as the base class type is 262 // dependent on the template argument (and thus shouldn't be 263 // looked into when resolving InvokeWith). 264 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8)); 265 } 266}; 267 268template <typename R, typename A1, typename A2, typename A3, typename A4, 269 typename A5, typename A6, typename A7, typename A8, typename A9> 270class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public 271 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> { 272 public: 273 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9); 274 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; 275 276 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, 277 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, 278 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8, 279 const Matcher<A9>& m9) { 280 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5, 281 m6, m7, m8, m9)); 282 return this->current_spec(); 283 } 284 285 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) { 286 // Even though gcc and MSVC don't enforce it, 'this->' is required 287 // by the C++ standard [14.6.4] here, as the base class type is 288 // dependent on the template argument (and thus shouldn't be 289 // looked into when resolving InvokeWith). 290 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9)); 291 } 292}; 293 294template <typename R, typename A1, typename A2, typename A3, typename A4, 295 typename A5, typename A6, typename A7, typename A8, typename A9, 296 typename A10> 297class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public 298 internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> { 299 public: 300 typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); 301 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; 302 303 MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, 304 const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, 305 const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8, 306 const Matcher<A9>& m9, const Matcher<A10>& m10) { 307 this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5, 308 m6, m7, m8, m9, m10)); 309 return this->current_spec(); 310 } 311 312 R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, 313 A10 a10) { 314 // Even though gcc and MSVC don't enforce it, 'this->' is required 315 // by the C++ standard [14.6.4] here, as the base class type is 316 // dependent on the template argument (and thus shouldn't be 317 // looked into when resolving InvokeWith). 318 return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9, 319 a10)); 320 } 321}; 322 323} // namespace internal 324 325// The style guide prohibits "using" statements in a namespace scope 326// inside a header file. However, the FunctionMocker class template 327// is meant to be defined in the ::testing namespace. The following 328// line is just a trick for working around a bug in MSVC 8.0, which 329// cannot handle it if we define FunctionMocker in ::testing. 330using internal::FunctionMocker; 331 332// GMOCK_RESULT_(tn, F) expands to the result type of function type F. 333// We define this as a variadic macro in case F contains unprotected 334// commas (the same reason that we use variadic macros in other places 335// in this file). 336// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 337#define GMOCK_RESULT_(tn, ...) \ 338 tn ::testing::internal::Function<__VA_ARGS__>::Result 339 340// The type of argument N of the given function type. 341// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 342#define GMOCK_ARG_(tn, N, ...) \ 343 tn ::testing::internal::Function<__VA_ARGS__>::Argument##N 344 345// The matcher type for argument N of the given function type. 346// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 347#define GMOCK_MATCHER_(tn, N, ...) \ 348 const ::testing::Matcher<GMOCK_ARG_(tn, N, __VA_ARGS__)>& 349 350// The variable for mocking the given method. 351// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 352#define GMOCK_MOCKER_(arity, constness, Method) \ 353 GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__) 354 355// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 356#define GMOCK_METHOD0_(tn, constness, ct, Method, ...) \ 357 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ 358 ) constness { \ 359 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \ 360 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \ 361 == 0), \ 362 this_method_does_not_take_0_arguments); \ 363 GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \ 364 return GMOCK_MOCKER_(0, constness, Method).Invoke(); \ 365 } \ 366 ::testing::MockSpec<__VA_ARGS__>& \ 367 gmock_##Method() constness { \ 368 GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \ 369 return GMOCK_MOCKER_(0, constness, Method).With(); \ 370 } \ 371 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(0, constness, \ 372 Method) 373 374// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 375#define GMOCK_METHOD1_(tn, constness, ct, Method, ...) \ 376 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ 377 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1) constness { \ 378 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \ 379 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \ 380 == 1), \ 381 this_method_does_not_take_1_argument); \ 382 GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \ 383 return GMOCK_MOCKER_(1, constness, Method).Invoke(gmock_a1); \ 384 } \ 385 ::testing::MockSpec<__VA_ARGS__>& \ 386 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1) constness { \ 387 GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \ 388 return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \ 389 } \ 390 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(1, constness, \ 391 Method) 392 393// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 394#define GMOCK_METHOD2_(tn, constness, ct, Method, ...) \ 395 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ 396 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \ 397 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2) constness { \ 398 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \ 399 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \ 400 == 2), \ 401 this_method_does_not_take_2_arguments); \ 402 GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \ 403 return GMOCK_MOCKER_(2, constness, Method).Invoke(gmock_a1, gmock_a2); \ 404 } \ 405 ::testing::MockSpec<__VA_ARGS__>& \ 406 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ 407 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2) constness { \ 408 GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \ 409 return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \ 410 } \ 411 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(2, constness, \ 412 Method) 413 414// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 415#define GMOCK_METHOD3_(tn, constness, ct, Method, ...) \ 416 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ 417 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \ 418 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \ 419 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3) constness { \ 420 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \ 421 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \ 422 == 3), \ 423 this_method_does_not_take_3_arguments); \ 424 GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \ 425 return GMOCK_MOCKER_(3, constness, Method).Invoke(gmock_a1, gmock_a2, \ 426 gmock_a3); \ 427 } \ 428 ::testing::MockSpec<__VA_ARGS__>& \ 429 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ 430 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ 431 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3) constness { \ 432 GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \ 433 return GMOCK_MOCKER_(3, constness, Method).With(gmock_a1, gmock_a2, \ 434 gmock_a3); \ 435 } \ 436 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(3, constness, \ 437 Method) 438 439// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 440#define GMOCK_METHOD4_(tn, constness, ct, Method, ...) \ 441 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ 442 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \ 443 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \ 444 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ 445 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4) constness { \ 446 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \ 447 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \ 448 == 4), \ 449 this_method_does_not_take_4_arguments); \ 450 GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \ 451 return GMOCK_MOCKER_(4, constness, Method).Invoke(gmock_a1, gmock_a2, \ 452 gmock_a3, gmock_a4); \ 453 } \ 454 ::testing::MockSpec<__VA_ARGS__>& \ 455 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ 456 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ 457 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ 458 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4) constness { \ 459 GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \ 460 return GMOCK_MOCKER_(4, constness, Method).With(gmock_a1, gmock_a2, \ 461 gmock_a3, gmock_a4); \ 462 } \ 463 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(4, constness, \ 464 Method) 465 466// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 467#define GMOCK_METHOD5_(tn, constness, ct, Method, ...) \ 468 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ 469 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \ 470 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \ 471 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ 472 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \ 473 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5) constness { \ 474 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \ 475 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \ 476 == 5), \ 477 this_method_does_not_take_5_arguments); \ 478 GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \ 479 return GMOCK_MOCKER_(5, constness, Method).Invoke(gmock_a1, gmock_a2, \ 480 gmock_a3, gmock_a4, gmock_a5); \ 481 } \ 482 ::testing::MockSpec<__VA_ARGS__>& \ 483 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ 484 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ 485 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ 486 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \ 487 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5) constness { \ 488 GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \ 489 return GMOCK_MOCKER_(5, constness, Method).With(gmock_a1, gmock_a2, \ 490 gmock_a3, gmock_a4, gmock_a5); \ 491 } \ 492 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(5, constness, \ 493 Method) 494 495// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 496#define GMOCK_METHOD6_(tn, constness, ct, Method, ...) \ 497 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ 498 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \ 499 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \ 500 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ 501 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \ 502 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \ 503 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6) constness { \ 504 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \ 505 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \ 506 == 6), \ 507 this_method_does_not_take_6_arguments); \ 508 GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \ 509 return GMOCK_MOCKER_(6, constness, Method).Invoke(gmock_a1, gmock_a2, \ 510 gmock_a3, gmock_a4, gmock_a5, gmock_a6); \ 511 } \ 512 ::testing::MockSpec<__VA_ARGS__>& \ 513 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ 514 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ 515 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ 516 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \ 517 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \ 518 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6) constness { \ 519 GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \ 520 return GMOCK_MOCKER_(6, constness, Method).With(gmock_a1, gmock_a2, \ 521 gmock_a3, gmock_a4, gmock_a5, gmock_a6); \ 522 } \ 523 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(6, constness, \ 524 Method) 525 526// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 527#define GMOCK_METHOD7_(tn, constness, ct, Method, ...) \ 528 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ 529 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \ 530 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \ 531 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ 532 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \ 533 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \ 534 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \ 535 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7) constness { \ 536 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \ 537 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \ 538 == 7), \ 539 this_method_does_not_take_7_arguments); \ 540 GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \ 541 return GMOCK_MOCKER_(7, constness, Method).Invoke(gmock_a1, gmock_a2, \ 542 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \ 543 } \ 544 ::testing::MockSpec<__VA_ARGS__>& \ 545 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ 546 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ 547 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ 548 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \ 549 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \ 550 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \ 551 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7) constness { \ 552 GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \ 553 return GMOCK_MOCKER_(7, constness, Method).With(gmock_a1, gmock_a2, \ 554 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \ 555 } \ 556 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(7, constness, \ 557 Method) 558 559// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 560#define GMOCK_METHOD8_(tn, constness, ct, Method, ...) \ 561 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ 562 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \ 563 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \ 564 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ 565 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \ 566 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \ 567 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \ 568 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \ 569 GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8) constness { \ 570 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \ 571 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \ 572 == 8), \ 573 this_method_does_not_take_8_arguments); \ 574 GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \ 575 return GMOCK_MOCKER_(8, constness, Method).Invoke(gmock_a1, gmock_a2, \ 576 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \ 577 } \ 578 ::testing::MockSpec<__VA_ARGS__>& \ 579 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ 580 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ 581 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ 582 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \ 583 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \ 584 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \ 585 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \ 586 GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8) constness { \ 587 GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \ 588 return GMOCK_MOCKER_(8, constness, Method).With(gmock_a1, gmock_a2, \ 589 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \ 590 } \ 591 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(8, constness, \ 592 Method) 593 594// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 595#define GMOCK_METHOD9_(tn, constness, ct, Method, ...) \ 596 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ 597 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \ 598 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \ 599 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ 600 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \ 601 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \ 602 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \ 603 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \ 604 GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \ 605 GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9) constness { \ 606 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \ 607 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \ 608 == 9), \ 609 this_method_does_not_take_9_arguments); \ 610 GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \ 611 return GMOCK_MOCKER_(9, constness, Method).Invoke(gmock_a1, gmock_a2, \ 612 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \ 613 gmock_a9); \ 614 } \ 615 ::testing::MockSpec<__VA_ARGS__>& \ 616 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ 617 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ 618 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ 619 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \ 620 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \ 621 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \ 622 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \ 623 GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \ 624 GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9) constness { \ 625 GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \ 626 return GMOCK_MOCKER_(9, constness, Method).With(gmock_a1, gmock_a2, \ 627 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \ 628 gmock_a9); \ 629 } \ 630 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(9, constness, \ 631 Method) 632 633// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! 634#define GMOCK_METHOD10_(tn, constness, ct, Method, ...) \ 635 GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ 636 GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \ 637 GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \ 638 GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ 639 GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \ 640 GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \ 641 GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \ 642 GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \ 643 GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \ 644 GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9, \ 645 GMOCK_ARG_(tn, 10, __VA_ARGS__) gmock_a10) constness { \ 646 GTEST_COMPILE_ASSERT_((::testing::tuple_size< \ 647 tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \ 648 == 10), \ 649 this_method_does_not_take_10_arguments); \ 650 GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \ 651 return GMOCK_MOCKER_(10, constness, Method).Invoke(gmock_a1, gmock_a2, \ 652 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \ 653 gmock_a10); \ 654 } \ 655 ::testing::MockSpec<__VA_ARGS__>& \ 656 gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ 657 GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ 658 GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ 659 GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \ 660 GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \ 661 GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \ 662 GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \ 663 GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \ 664 GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9, \ 665 GMOCK_MATCHER_(tn, 10, \ 666 __VA_ARGS__) gmock_a10) constness { \ 667 GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \ 668 return GMOCK_MOCKER_(10, constness, Method).With(gmock_a1, gmock_a2, \ 669 gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \ 670 gmock_a10); \ 671 } \ 672 mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(10, constness, \ 673 Method) 674 675#define MOCK_METHOD0(m, ...) GMOCK_METHOD0_(, , , m, __VA_ARGS__) 676#define MOCK_METHOD1(m, ...) GMOCK_METHOD1_(, , , m, __VA_ARGS__) 677#define MOCK_METHOD2(m, ...) GMOCK_METHOD2_(, , , m, __VA_ARGS__) 678#define MOCK_METHOD3(m, ...) GMOCK_METHOD3_(, , , m, __VA_ARGS__) 679#define MOCK_METHOD4(m, ...) GMOCK_METHOD4_(, , , m, __VA_ARGS__) 680#define MOCK_METHOD5(m, ...) GMOCK_METHOD5_(, , , m, __VA_ARGS__) 681#define MOCK_METHOD6(m, ...) GMOCK_METHOD6_(, , , m, __VA_ARGS__) 682#define MOCK_METHOD7(m, ...) GMOCK_METHOD7_(, , , m, __VA_ARGS__) 683#define MOCK_METHOD8(m, ...) GMOCK_METHOD8_(, , , m, __VA_ARGS__) 684#define MOCK_METHOD9(m, ...) GMOCK_METHOD9_(, , , m, __VA_ARGS__) 685#define MOCK_METHOD10(m, ...) GMOCK_METHOD10_(, , , m, __VA_ARGS__) 686 687#define MOCK_CONST_METHOD0(m, ...) GMOCK_METHOD0_(, const, , m, __VA_ARGS__) 688#define MOCK_CONST_METHOD1(m, ...) GMOCK_METHOD1_(, const, , m, __VA_ARGS__) 689#define MOCK_CONST_METHOD2(m, ...) GMOCK_METHOD2_(, const, , m, __VA_ARGS__) 690#define MOCK_CONST_METHOD3(m, ...) GMOCK_METHOD3_(, const, , m, __VA_ARGS__) 691#define MOCK_CONST_METHOD4(m, ...) GMOCK_METHOD4_(, const, , m, __VA_ARGS__) 692#define MOCK_CONST_METHOD5(m, ...) GMOCK_METHOD5_(, const, , m, __VA_ARGS__) 693#define MOCK_CONST_METHOD6(m, ...) GMOCK_METHOD6_(, const, , m, __VA_ARGS__) 694#define MOCK_CONST_METHOD7(m, ...) GMOCK_METHOD7_(, const, , m, __VA_ARGS__) 695#define MOCK_CONST_METHOD8(m, ...) GMOCK_METHOD8_(, const, , m, __VA_ARGS__) 696#define MOCK_CONST_METHOD9(m, ...) GMOCK_METHOD9_(, const, , m, __VA_ARGS__) 697#define MOCK_CONST_METHOD10(m, ...) GMOCK_METHOD10_(, const, , m, __VA_ARGS__) 698 699#define MOCK_METHOD0_T(m, ...) GMOCK_METHOD0_(typename, , , m, __VA_ARGS__) 700#define MOCK_METHOD1_T(m, ...) GMOCK_METHOD1_(typename, , , m, __VA_ARGS__) 701#define MOCK_METHOD2_T(m, ...) GMOCK_METHOD2_(typename, , , m, __VA_ARGS__) 702#define MOCK_METHOD3_T(m, ...) GMOCK_METHOD3_(typename, , , m, __VA_ARGS__) 703#define MOCK_METHOD4_T(m, ...) GMOCK_METHOD4_(typename, , , m, __VA_ARGS__) 704#define MOCK_METHOD5_T(m, ...) GMOCK_METHOD5_(typename, , , m, __VA_ARGS__) 705#define MOCK_METHOD6_T(m, ...) GMOCK_METHOD6_(typename, , , m, __VA_ARGS__) 706#define MOCK_METHOD7_T(m, ...) GMOCK_METHOD7_(typename, , , m, __VA_ARGS__) 707#define MOCK_METHOD8_T(m, ...) GMOCK_METHOD8_(typename, , , m, __VA_ARGS__) 708#define MOCK_METHOD9_T(m, ...) GMOCK_METHOD9_(typename, , , m, __VA_ARGS__) 709#define MOCK_METHOD10_T(m, ...) GMOCK_METHOD10_(typename, , , m, __VA_ARGS__) 710 711#define MOCK_CONST_METHOD0_T(m, ...) \ 712 GMOCK_METHOD0_(typename, const, , m, __VA_ARGS__) 713#define MOCK_CONST_METHOD1_T(m, ...) \ 714 GMOCK_METHOD1_(typename, const, , m, __VA_ARGS__) 715#define MOCK_CONST_METHOD2_T(m, ...) \ 716 GMOCK_METHOD2_(typename, const, , m, __VA_ARGS__) 717#define MOCK_CONST_METHOD3_T(m, ...) \ 718 GMOCK_METHOD3_(typename, const, , m, __VA_ARGS__) 719#define MOCK_CONST_METHOD4_T(m, ...) \ 720 GMOCK_METHOD4_(typename, const, , m, __VA_ARGS__) 721#define MOCK_CONST_METHOD5_T(m, ...) \ 722 GMOCK_METHOD5_(typename, const, , m, __VA_ARGS__) 723#define MOCK_CONST_METHOD6_T(m, ...) \ 724 GMOCK_METHOD6_(typename, const, , m, __VA_ARGS__) 725#define MOCK_CONST_METHOD7_T(m, ...) \ 726 GMOCK_METHOD7_(typename, const, , m, __VA_ARGS__) 727#define MOCK_CONST_METHOD8_T(m, ...) \ 728 GMOCK_METHOD8_(typename, const, , m, __VA_ARGS__) 729#define MOCK_CONST_METHOD9_T(m, ...) \ 730 GMOCK_METHOD9_(typename, const, , m, __VA_ARGS__) 731#define MOCK_CONST_METHOD10_T(m, ...) \ 732 GMOCK_METHOD10_(typename, const, , m, __VA_ARGS__) 733 734#define MOCK_METHOD0_WITH_CALLTYPE(ct, m, ...) \ 735 GMOCK_METHOD0_(, , ct, m, __VA_ARGS__) 736#define MOCK_METHOD1_WITH_CALLTYPE(ct, m, ...) \ 737 GMOCK_METHOD1_(, , ct, m, __VA_ARGS__) 738#define MOCK_METHOD2_WITH_CALLTYPE(ct, m, ...) \ 739 GMOCK_METHOD2_(, , ct, m, __VA_ARGS__) 740#define MOCK_METHOD3_WITH_CALLTYPE(ct, m, ...) \ 741 GMOCK_METHOD3_(, , ct, m, __VA_ARGS__) 742#define MOCK_METHOD4_WITH_CALLTYPE(ct, m, ...) \ 743 GMOCK_METHOD4_(, , ct, m, __VA_ARGS__) 744#define MOCK_METHOD5_WITH_CALLTYPE(ct, m, ...) \ 745 GMOCK_METHOD5_(, , ct, m, __VA_ARGS__) 746#define MOCK_METHOD6_WITH_CALLTYPE(ct, m, ...) \ 747 GMOCK_METHOD6_(, , ct, m, __VA_ARGS__) 748#define MOCK_METHOD7_WITH_CALLTYPE(ct, m, ...) \ 749 GMOCK_METHOD7_(, , ct, m, __VA_ARGS__) 750#define MOCK_METHOD8_WITH_CALLTYPE(ct, m, ...) \ 751 GMOCK_METHOD8_(, , ct, m, __VA_ARGS__) 752#define MOCK_METHOD9_WITH_CALLTYPE(ct, m, ...) \ 753 GMOCK_METHOD9_(, , ct, m, __VA_ARGS__) 754#define MOCK_METHOD10_WITH_CALLTYPE(ct, m, ...) \ 755 GMOCK_METHOD10_(, , ct, m, __VA_ARGS__) 756 757#define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, ...) \ 758 GMOCK_METHOD0_(, const, ct, m, __VA_ARGS__) 759#define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, ...) \ 760 GMOCK_METHOD1_(, const, ct, m, __VA_ARGS__) 761#define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, ...) \ 762 GMOCK_METHOD2_(, const, ct, m, __VA_ARGS__) 763#define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, ...) \ 764 GMOCK_METHOD3_(, const, ct, m, __VA_ARGS__) 765#define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, ...) \ 766 GMOCK_METHOD4_(, const, ct, m, __VA_ARGS__) 767#define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, ...) \ 768 GMOCK_METHOD5_(, const, ct, m, __VA_ARGS__) 769#define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, ...) \ 770 GMOCK_METHOD6_(, const, ct, m, __VA_ARGS__) 771#define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, ...) \ 772 GMOCK_METHOD7_(, const, ct, m, __VA_ARGS__) 773#define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, ...) \ 774 GMOCK_METHOD8_(, const, ct, m, __VA_ARGS__) 775#define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, ...) \ 776 GMOCK_METHOD9_(, const, ct, m, __VA_ARGS__) 777#define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, ...) \ 778 GMOCK_METHOD10_(, const, ct, m, __VA_ARGS__) 779 780#define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \ 781 GMOCK_METHOD0_(typename, , ct, m, __VA_ARGS__) 782#define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \ 783 GMOCK_METHOD1_(typename, , ct, m, __VA_ARGS__) 784#define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \ 785 GMOCK_METHOD2_(typename, , ct, m, __VA_ARGS__) 786#define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \ 787 GMOCK_METHOD3_(typename, , ct, m, __VA_ARGS__) 788#define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \ 789 GMOCK_METHOD4_(typename, , ct, m, __VA_ARGS__) 790#define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \ 791 GMOCK_METHOD5_(typename, , ct, m, __VA_ARGS__) 792#define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \ 793 GMOCK_METHOD6_(typename, , ct, m, __VA_ARGS__) 794#define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \ 795 GMOCK_METHOD7_(typename, , ct, m, __VA_ARGS__) 796#define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \ 797 GMOCK_METHOD8_(typename, , ct, m, __VA_ARGS__) 798#define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \ 799 GMOCK_METHOD9_(typename, , ct, m, __VA_ARGS__) 800#define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \ 801 GMOCK_METHOD10_(typename, , ct, m, __VA_ARGS__) 802 803#define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \ 804 GMOCK_METHOD0_(typename, const, ct, m, __VA_ARGS__) 805#define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \ 806 GMOCK_METHOD1_(typename, const, ct, m, __VA_ARGS__) 807#define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \ 808 GMOCK_METHOD2_(typename, const, ct, m, __VA_ARGS__) 809#define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \ 810 GMOCK_METHOD3_(typename, const, ct, m, __VA_ARGS__) 811#define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \ 812 GMOCK_METHOD4_(typename, const, ct, m, __VA_ARGS__) 813#define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \ 814 GMOCK_METHOD5_(typename, const, ct, m, __VA_ARGS__) 815#define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \ 816 GMOCK_METHOD6_(typename, const, ct, m, __VA_ARGS__) 817#define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \ 818 GMOCK_METHOD7_(typename, const, ct, m, __VA_ARGS__) 819#define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \ 820 GMOCK_METHOD8_(typename, const, ct, m, __VA_ARGS__) 821#define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \ 822 GMOCK_METHOD9_(typename, const, ct, m, __VA_ARGS__) 823#define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \ 824 GMOCK_METHOD10_(typename, const, ct, m, __VA_ARGS__) 825 826// A MockFunction<F> class has one mock method whose type is F. It is 827// useful when you just want your test code to emit some messages and 828// have Google Mock verify the right messages are sent (and perhaps at 829// the right times). For example, if you are exercising code: 830// 831// Foo(1); 832// Foo(2); 833// Foo(3); 834// 835// and want to verify that Foo(1) and Foo(3) both invoke 836// mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write: 837// 838// TEST(FooTest, InvokesBarCorrectly) { 839// MyMock mock; 840// MockFunction<void(string check_point_name)> check; 841// { 842// InSequence s; 843// 844// EXPECT_CALL(mock, Bar("a")); 845// EXPECT_CALL(check, Call("1")); 846// EXPECT_CALL(check, Call("2")); 847// EXPECT_CALL(mock, Bar("a")); 848// } 849// Foo(1); 850// check.Call("1"); 851// Foo(2); 852// check.Call("2"); 853// Foo(3); 854// } 855// 856// The expectation spec says that the first Bar("a") must happen 857// before check point "1", the second Bar("a") must happen after check 858// point "2", and nothing should happen between the two check 859// points. The explicit check points make it easy to tell which 860// Bar("a") is called by which call to Foo(). 861// 862// MockFunction<F> can also be used to exercise code that accepts 863// std::function<F> callbacks. To do so, use AsStdFunction() method 864// to create std::function proxy forwarding to original object's Call. 865// Example: 866// 867// TEST(FooTest, RunsCallbackWithBarArgument) { 868// MockFunction<int(string)> callback; 869// EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1)); 870// Foo(callback.AsStdFunction()); 871// } 872template <typename F> 873class MockFunction; 874 875template <typename R> 876class MockFunction<R()> { 877 public: 878 MockFunction() {} 879 880 MOCK_METHOD0_T(Call, R()); 881 882#if GTEST_HAS_STD_FUNCTION_ 883 std::function<R()> AsStdFunction() { 884 return [this]() -> R { 885 return this->Call(); 886 }; 887 } 888#endif // GTEST_HAS_STD_FUNCTION_ 889 890 private: 891 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); 892}; 893 894template <typename R, typename A0> 895class MockFunction<R(A0)> { 896 public: 897 MockFunction() {} 898 899 MOCK_METHOD1_T(Call, R(A0)); 900 901#if GTEST_HAS_STD_FUNCTION_ 902 std::function<R(A0)> AsStdFunction() { 903 return [this](A0 a0) -> R { 904 return this->Call(a0); 905 }; 906 } 907#endif // GTEST_HAS_STD_FUNCTION_ 908 909 private: 910 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); 911}; 912 913template <typename R, typename A0, typename A1> 914class MockFunction<R(A0, A1)> { 915 public: 916 MockFunction() {} 917 918 MOCK_METHOD2_T(Call, R(A0, A1)); 919 920#if GTEST_HAS_STD_FUNCTION_ 921 std::function<R(A0, A1)> AsStdFunction() { 922 return [this](A0 a0, A1 a1) -> R { 923 return this->Call(a0, a1); 924 }; 925 } 926#endif // GTEST_HAS_STD_FUNCTION_ 927 928 private: 929 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); 930}; 931 932template <typename R, typename A0, typename A1, typename A2> 933class MockFunction<R(A0, A1, A2)> { 934 public: 935 MockFunction() {} 936 937 MOCK_METHOD3_T(Call, R(A0, A1, A2)); 938 939#if GTEST_HAS_STD_FUNCTION_ 940 std::function<R(A0, A1, A2)> AsStdFunction() { 941 return [this](A0 a0, A1 a1, A2 a2) -> R { 942 return this->Call(a0, a1, a2); 943 }; 944 } 945#endif // GTEST_HAS_STD_FUNCTION_ 946 947 private: 948 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); 949}; 950 951template <typename R, typename A0, typename A1, typename A2, typename A3> 952class MockFunction<R(A0, A1, A2, A3)> { 953 public: 954 MockFunction() {} 955 956 MOCK_METHOD4_T(Call, R(A0, A1, A2, A3)); 957 958#if GTEST_HAS_STD_FUNCTION_ 959 std::function<R(A0, A1, A2, A3)> AsStdFunction() { 960 return [this](A0 a0, A1 a1, A2 a2, A3 a3) -> R { 961 return this->Call(a0, a1, a2, a3); 962 }; 963 } 964#endif // GTEST_HAS_STD_FUNCTION_ 965 966 private: 967 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); 968}; 969 970template <typename R, typename A0, typename A1, typename A2, typename A3, 971 typename A4> 972class MockFunction<R(A0, A1, A2, A3, A4)> { 973 public: 974 MockFunction() {} 975 976 MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4)); 977 978#if GTEST_HAS_STD_FUNCTION_ 979 std::function<R(A0, A1, A2, A3, A4)> AsStdFunction() { 980 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) -> R { 981 return this->Call(a0, a1, a2, a3, a4); 982 }; 983 } 984#endif // GTEST_HAS_STD_FUNCTION_ 985 986 private: 987 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); 988}; 989 990template <typename R, typename A0, typename A1, typename A2, typename A3, 991 typename A4, typename A5> 992class MockFunction<R(A0, A1, A2, A3, A4, A5)> { 993 public: 994 MockFunction() {} 995 996 MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5)); 997 998#if GTEST_HAS_STD_FUNCTION_ 999 std::function<R(A0, A1, A2, A3, A4, A5)> AsStdFunction() { 1000 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) -> R { 1001 return this->Call(a0, a1, a2, a3, a4, a5); 1002 }; 1003 } 1004#endif // GTEST_HAS_STD_FUNCTION_ 1005 1006 private: 1007 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); 1008}; 1009 1010template <typename R, typename A0, typename A1, typename A2, typename A3, 1011 typename A4, typename A5, typename A6> 1012class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> { 1013 public: 1014 MockFunction() {} 1015 1016 MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6)); 1017 1018#if GTEST_HAS_STD_FUNCTION_ 1019 std::function<R(A0, A1, A2, A3, A4, A5, A6)> AsStdFunction() { 1020 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) -> R { 1021 return this->Call(a0, a1, a2, a3, a4, a5, a6); 1022 }; 1023 } 1024#endif // GTEST_HAS_STD_FUNCTION_ 1025 1026 private: 1027 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); 1028}; 1029 1030template <typename R, typename A0, typename A1, typename A2, typename A3, 1031 typename A4, typename A5, typename A6, typename A7> 1032class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> { 1033 public: 1034 MockFunction() {} 1035 1036 MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7)); 1037 1038#if GTEST_HAS_STD_FUNCTION_ 1039 std::function<R(A0, A1, A2, A3, A4, A5, A6, A7)> AsStdFunction() { 1040 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) -> R { 1041 return this->Call(a0, a1, a2, a3, a4, a5, a6, a7); 1042 }; 1043 } 1044#endif // GTEST_HAS_STD_FUNCTION_ 1045 1046 private: 1047 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); 1048}; 1049 1050template <typename R, typename A0, typename A1, typename A2, typename A3, 1051 typename A4, typename A5, typename A6, typename A7, typename A8> 1052class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> { 1053 public: 1054 MockFunction() {} 1055 1056 MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8)); 1057 1058#if GTEST_HAS_STD_FUNCTION_ 1059 std::function<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> AsStdFunction() { 1060 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, 1061 A8 a8) -> R { 1062 return this->Call(a0, a1, a2, a3, a4, a5, a6, a7, a8); 1063 }; 1064 } 1065#endif // GTEST_HAS_STD_FUNCTION_ 1066 1067 private: 1068 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); 1069}; 1070 1071template <typename R, typename A0, typename A1, typename A2, typename A3, 1072 typename A4, typename A5, typename A6, typename A7, typename A8, 1073 typename A9> 1074class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> { 1075 public: 1076 MockFunction() {} 1077 1078 MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)); 1079 1080#if GTEST_HAS_STD_FUNCTION_ 1081 std::function<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> AsStdFunction() { 1082 return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, 1083 A8 a8, A9 a9) -> R { 1084 return this->Call(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); 1085 }; 1086 } 1087#endif // GTEST_HAS_STD_FUNCTION_ 1088 1089 private: 1090 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); 1091}; 1092 1093} // namespace testing 1094 1095#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ 1096