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