aboutsummaryrefslogtreecommitdiffstats
path: root/googlemock
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2020-02-05 17:38:58 -0500
committerAndy Getz <durandal@google.com>2020-02-07 13:35:27 -0500
commitfbf67a70d07543f40832d0cd7a58f304bc6ab1d1 (patch)
tree17c398d421017528782ad3a69a6af090ba001305 /googlemock
parent11d9834e98c158712cf257c8497eaf3ec536f755 (diff)
downloadgoogletest-fbf67a70d07543f40832d0cd7a58f304bc6ab1d1.tar.gz
googletest-fbf67a70d07543f40832d0cd7a58f304bc6ab1d1.tar.bz2
googletest-fbf67a70d07543f40832d0cd7a58f304bc6ab1d1.zip
Googletest export
Get rid of gmock-generated-function-mockers.h and gmock-generated-function-mockers.h.pump. Stop using pump for GMOCK_METHOD* macroses generation. PiperOrigin-RevId: 293454519
Diffstat (limited to 'googlemock')
-rw-r--r--googlemock/CMakeLists.txt1
-rw-r--r--googlemock/include/gmock/gmock-function-mocker.h57
-rw-r--r--googlemock/include/gmock/gmock-generated-function-mockers.h601
-rw-r--r--googlemock/include/gmock/gmock-generated-function-mockers.h.pump176
-rw-r--r--googlemock/include/gmock/gmock.h1
-rw-r--r--googlemock/test/gmock-function-mocker_test.cc353
-rw-r--r--googlemock/test/gmock-generated-function-mockers_test.cc659
-rw-r--r--googlemock/test/gmock_all_test.cc1
8 files changed, 299 insertions, 1550 deletions
diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt
index d32b70b5..8ab59d7f 100644
--- a/googlemock/CMakeLists.txt
+++ b/googlemock/CMakeLists.txt
@@ -166,7 +166,6 @@ $env:Path = \"$project_bin;$env:Path\"
cxx_test(gmock_ex_test gmock_main)
cxx_test(gmock-function-mocker_test gmock_main)
cxx_test(gmock-generated-actions_test gmock_main)
- cxx_test(gmock-generated-function-mockers_test gmock_main)
cxx_test(gmock-generated-matchers_test gmock_main)
cxx_test(gmock-internal-utils_test gmock_main)
cxx_test(gmock-matchers_test gmock_main)
diff --git a/googlemock/include/gmock/gmock-function-mocker.h b/googlemock/include/gmock/gmock-function-mocker.h
index 1af0d935..317d6c2b 100644
--- a/googlemock/include/gmock/gmock-function-mocker.h
+++ b/googlemock/include/gmock/gmock-function-mocker.h
@@ -37,16 +37,35 @@
#define THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT
#include <type_traits> // IWYU pragma: keep
-#include <utility> // IWYU pragma: keep
+#include <utility> // IWYU pragma: keep
-#include "gmock/gmock-generated-function-mockers.h" // NOLINT
+#include "gmock/gmock-spec-builders.h"
+#include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-pp.h"
namespace testing {
namespace internal {
template <typename T>
using identity_t = T;
+
+template <typename MockType>
+const MockType* AdjustConstness_const(const MockType* mock) {
+ return mock;
+}
+
+template <typename MockType>
+MockType* AdjustConstness_(const MockType* mock) {
+ return const_cast<MockType*>(mock);
+}
+
} // namespace internal
+
+// The style guide prohibits "using" statements in a namespace scope
+// inside a header file. However, the FunctionMocker class template
+// is meant to be defined in the ::testing namespace. The following
+// line is just a trick for working around a bug in MSVC 8.0, which
+// cannot handle it if we define FunctionMocker in ::testing.
+using internal::FunctionMocker;
} // namespace testing
#define MOCK_METHOD(...) \
@@ -244,20 +263,19 @@ using identity_t = T;
GMOCK_PP_IDENTITY) \
(_elem)
-#define GMOCK_INTERNAL_PARAMETER(_i, _Signature, _) \
- GMOCK_PP_COMMA_IF(_i) \
- GMOCK_INTERNAL_ARG_O(GMOCK_PP_INC(_i), GMOCK_PP_REMOVE_PARENS(_Signature)) \
+#define GMOCK_INTERNAL_PARAMETER(_i, _Signature, _) \
+ GMOCK_PP_COMMA_IF(_i) \
+ GMOCK_INTERNAL_ARG_O(_i, GMOCK_PP_REMOVE_PARENS(_Signature)) \
gmock_a##_i
#define GMOCK_INTERNAL_FORWARD_ARG(_i, _Signature, _) \
GMOCK_PP_COMMA_IF(_i) \
::std::forward<GMOCK_INTERNAL_ARG_O( \
- GMOCK_PP_INC(_i), GMOCK_PP_REMOVE_PARENS(_Signature))>(gmock_a##_i)
+ _i, GMOCK_PP_REMOVE_PARENS(_Signature))>(gmock_a##_i)
-#define GMOCK_INTERNAL_MATCHER_PARAMETER(_i, _Signature, _) \
- GMOCK_PP_COMMA_IF(_i) \
- GMOCK_INTERNAL_MATCHER_O(GMOCK_PP_INC(_i), \
- GMOCK_PP_REMOVE_PARENS(_Signature)) \
+#define GMOCK_INTERNAL_MATCHER_PARAMETER(_i, _Signature, _) \
+ GMOCK_PP_COMMA_IF(_i) \
+ GMOCK_INTERNAL_MATCHER_O(_i, GMOCK_PP_REMOVE_PARENS(_Signature)) \
gmock_a##_i
#define GMOCK_INTERNAL_MATCHER_ARGUMENT(_i, _1, _2) \
@@ -266,12 +284,14 @@ using identity_t = T;
#define GMOCK_INTERNAL_A_MATCHER_ARGUMENT(_i, _Signature, _) \
GMOCK_PP_COMMA_IF(_i) \
- ::testing::A<GMOCK_INTERNAL_ARG_O(GMOCK_PP_INC(_i), \
- GMOCK_PP_REMOVE_PARENS(_Signature))>()
+ ::testing::A<GMOCK_INTERNAL_ARG_O(_i, GMOCK_PP_REMOVE_PARENS(_Signature))>()
-#define GMOCK_INTERNAL_ARG_O(_i, ...) GMOCK_ARG_(_i, __VA_ARGS__)
+#define GMOCK_INTERNAL_ARG_O(_i, ...) \
+ typename ::testing::internal::Function<__VA_ARGS__>::template Arg<_i>::type
-#define GMOCK_INTERNAL_MATCHER_O(_i, ...) GMOCK_MATCHER_(_i, __VA_ARGS__)
+#define GMOCK_INTERNAL_MATCHER_O(_i, ...) \
+ const ::testing::Matcher<typename ::testing::internal::Function< \
+ __VA_ARGS__>::template Arg<_i>::type>&
#define MOCK_METHOD0(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 0, __VA_ARGS__)
#define MOCK_METHOD1(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 1, __VA_ARGS__)
@@ -426,6 +446,13 @@ using identity_t = T;
MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, __VA_ARGS__)
#define GMOCK_INTERNAL_MOCK_METHODN(constness, ct, Method, args_num, ...) \
- GMOCK_METHOD##args_num##_(constness, ct, Method, __VA_ARGS__)
+ GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE( \
+ args_num, ::testing::internal::identity_t<__VA_ARGS__>); \
+ GMOCK_INTERNAL_MOCK_METHOD_IMPL( \
+ args_num, Method, GMOCK_PP_NARG0(constness), 0, 0, , ct, \
+ (::testing::internal::identity_t<__VA_ARGS__>))
+
+#define GMOCK_MOCKER_(arity, constness, Method) \
+ GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
#endif // THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_
diff --git a/googlemock/include/gmock/gmock-generated-function-mockers.h b/googlemock/include/gmock/gmock-generated-function-mockers.h
deleted file mode 100644
index e0bd6cd7..00000000
--- a/googlemock/include/gmock/gmock-generated-function-mockers.h
+++ /dev/null
@@ -1,601 +0,0 @@
-// This file was GENERATED by command:
-// pump.py gmock-generated-function-mockers.h.pump
-// DO NOT EDIT BY HAND!!!
-
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file implements function mockers of various arities.
-
-// GOOGLETEST_CM0002 DO NOT DELETE
-
-#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
-#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
-
-#include <functional>
-#include <utility>
-
-#include "gmock/gmock-spec-builders.h"
-#include "gmock/internal/gmock-internal-utils.h"
-
-namespace testing {
-namespace internal {
-// Removes the given pointer; this is a helper for the expectation setter method
-// for parameterless matchers.
-//
-// We want to make sure that the user cannot set a parameterless expectation on
-// overloaded methods, including methods which are overloaded on const. Example:
-//
-// class MockClass {
-// MOCK_METHOD0(GetName, string&());
-// MOCK_CONST_METHOD0(GetName, const string&());
-// };
-//
-// TEST() {
-// // This should be an error, as it's not clear which overload is expected.
-// EXPECT_CALL(mock, GetName).WillOnce(ReturnRef(value));
-// }
-//
-// Here are the generated expectation-setter methods:
-//
-// class MockClass {
-// // Overload 1
-// MockSpec<string&()> gmock_GetName() { ... }
-// // Overload 2. Declared const so that the compiler will generate an
-// // error when trying to resolve between this and overload 4 in
-// // 'gmock_GetName(WithoutMatchers(), nullptr)'.
-// MockSpec<string&()> gmock_GetName(
-// const WithoutMatchers&, const Function<string&()>*) const {
-// // Removes const from this, calls overload 1
-// return AdjustConstness_(this)->gmock_GetName();
-// }
-//
-// // Overload 3
-// const string& gmock_GetName() const { ... }
-// // Overload 4
-// MockSpec<const string&()> gmock_GetName(
-// const WithoutMatchers&, const Function<const string&()>*) const {
-// // Does not remove const, calls overload 3
-// return AdjustConstness_const(this)->gmock_GetName();
-// }
-// }
-//
-template <typename MockType>
-const MockType* AdjustConstness_const(const MockType* mock) {
- return mock;
-}
-
-// Removes const from and returns the given pointer; this is a helper for the
-// expectation setter method for parameterless matchers.
-template <typename MockType>
-MockType* AdjustConstness_(const MockType* mock) {
- return const_cast<MockType*>(mock);
-}
-
-} // namespace internal
-
-// The style guide prohibits "using" statements in a namespace scope
-// inside a header file. However, the FunctionMocker class template
-// is meant to be defined in the ::testing namespace. The following
-// line is just a trick for working around a bug in MSVC 8.0, which
-// cannot handle it if we define FunctionMocker in ::testing.
-using internal::FunctionMocker;
-
-// GMOCK_RESULT_(tn, F) expands to the result type of function type F.
-// We define this as a variadic macro in case F contains unprotected
-// commas (the same reason that we use variadic macros in other places
-// in this file).
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_RESULT_(...) \
- typename ::testing::internal::Function<__VA_ARGS__>::Result
-
-// The type of argument N of the given function type.
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_ARG_(N, ...) \
- typename ::testing::internal::Function<__VA_ARGS__>::template Arg<N-1>::type
-
-// The matcher type for argument N of the given function type.
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_MATCHER_(N, ...) \
- const ::testing::Matcher<GMOCK_ARG_(N, __VA_ARGS__)>&
-
-// The variable for mocking the given method.
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_MOCKER_(arity, constness, Method) \
- GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD0_(constness, ct, Method, ...) \
- static_assert(0 == \
- ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \
- "MOCK_METHOD<N> must match argument count.");\
- GMOCK_RESULT_(__VA_ARGS__) ct Method( \
- ) constness { \
- GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \
- return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
- } \
- ::testing::MockSpec<__VA_ARGS__> \
- gmock_##Method() constness { \
- GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \
- return GMOCK_MOCKER_(0, constness, Method).With(); \
- } \
- ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
- const ::testing::internal::WithoutMatchers&, \
- constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
- return ::testing::internal::AdjustConstness_##constness(this)-> \
- gmock_##Method(); \
- } \
- mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(0, constness, \
- Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD1_(constness, ct, Method, ...) \
- static_assert(1 == \
- ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \
- "MOCK_METHOD<N> must match argument count.");\
- GMOCK_RESULT_(__VA_ARGS__) ct Method( \
- GMOCK_ARG_(1, __VA_ARGS__) gmock_a1) constness { \
- GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \
- return GMOCK_MOCKER_(1, constness, \
- Method).Invoke(::std::forward<GMOCK_ARG_(1, __VA_ARGS__)>(gmock_a1)); \
- \
- } \
- ::testing::MockSpec<__VA_ARGS__> \
- gmock_##Method(GMOCK_MATCHER_(1, __VA_ARGS__) gmock_a1) constness { \
- GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \
- return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \
- } \
- ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
- const ::testing::internal::WithoutMatchers&, \
- constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
- return ::testing::internal::AdjustConstness_##constness(this)-> \
- gmock_##Method(::testing::A<GMOCK_ARG_(1, __VA_ARGS__)>()); \
- } \
- mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(1, constness, \
- Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD2_(constness, ct, Method, ...) \
- static_assert(2 == \
- ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \
- "MOCK_METHOD<N> must match argument count.");\
- GMOCK_RESULT_(__VA_ARGS__) ct Method( \
- GMOCK_ARG_(1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(2, \
- __VA_ARGS__) gmock_a2) constness { \
- GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \
- return GMOCK_MOCKER_(2, constness, \
- Method).Invoke(::std::forward<GMOCK_ARG_(1, __VA_ARGS__)>(gmock_a1), \
- \
- ::std::forward<GMOCK_ARG_(2, __VA_ARGS__)>(gmock_a2)); \
- } \
- ::testing::MockSpec<__VA_ARGS__> \
- gmock_##Method(GMOCK_MATCHER_(1, __VA_ARGS__) gmock_a1, \
- GMOCK_MATCHER_(2, __VA_ARGS__) gmock_a2) constness { \
- GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \
- return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \
- } \
- ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
- const ::testing::internal::WithoutMatchers&, \
- constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
- return ::testing::internal::AdjustConstness_##constness(this)-> \
- gmock_##Method(::testing::A<GMOCK_ARG_(1, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(2, __VA_ARGS__)>()); \
- } \
- mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(2, constness, \
- Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD3_(constness, ct, Method, ...) \
- static_assert(3 == \
- ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \
- "MOCK_METHOD<N> must match argument count.");\
- GMOCK_RESULT_(__VA_ARGS__) ct Method( \
- GMOCK_ARG_(1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(2, \
- __VA_ARGS__) gmock_a2, GMOCK_ARG_(3, \
- __VA_ARGS__) gmock_a3) constness { \
- GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \
- return GMOCK_MOCKER_(3, constness, \
- Method).Invoke(::std::forward<GMOCK_ARG_(1, __VA_ARGS__)>(gmock_a1), \
- \
- ::std::forward<GMOCK_ARG_(2, __VA_ARGS__)>(gmock_a2), \
- ::std::forward<GMOCK_ARG_(3, __VA_ARGS__)>(gmock_a3)); \
- } \
- ::testing::MockSpec<__VA_ARGS__> \
- gmock_##Method(GMOCK_MATCHER_(1, __VA_ARGS__) gmock_a1, \
- GMOCK_MATCHER_(2, __VA_ARGS__) gmock_a2, \
- GMOCK_MATCHER_(3, __VA_ARGS__) gmock_a3) constness { \
- GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \
- return GMOCK_MOCKER_(3, constness, Method).With(gmock_a1, gmock_a2, \
- gmock_a3); \
- } \
- ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
- const ::testing::internal::WithoutMatchers&, \
- constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
- return ::testing::internal::AdjustConstness_##constness(this)-> \
- gmock_##Method(::testing::A<GMOCK_ARG_(1, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(2, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(3, __VA_ARGS__)>()); \
- } \
- mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(3, constness, \
- Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD4_(constness, ct, Method, ...) \
- static_assert(4 == \
- ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \
- "MOCK_METHOD<N> must match argument count.");\
- GMOCK_RESULT_(__VA_ARGS__) ct Method( \
- GMOCK_ARG_(1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(2, \
- __VA_ARGS__) gmock_a2, GMOCK_ARG_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_ARG_(4, __VA_ARGS__) gmock_a4) constness { \
- GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \
- return GMOCK_MOCKER_(4, constness, \
- Method).Invoke(::std::forward<GMOCK_ARG_(1, __VA_ARGS__)>(gmock_a1), \
- \
- ::std::forward<GMOCK_ARG_(2, __VA_ARGS__)>(gmock_a2), \
- ::std::forward<GMOCK_ARG_(3, __VA_ARGS__)>(gmock_a3), \
- ::std::forward<GMOCK_ARG_(4, __VA_ARGS__)>(gmock_a4)); \
- } \
- ::testing::MockSpec<__VA_ARGS__> \
- gmock_##Method(GMOCK_MATCHER_(1, __VA_ARGS__) gmock_a1, \
- GMOCK_MATCHER_(2, __VA_ARGS__) gmock_a2, \
- GMOCK_MATCHER_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_MATCHER_(4, __VA_ARGS__) gmock_a4) constness { \
- GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \
- return GMOCK_MOCKER_(4, constness, Method).With(gmock_a1, gmock_a2, \
- gmock_a3, gmock_a4); \
- } \
- ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
- const ::testing::internal::WithoutMatchers&, \
- constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
- return ::testing::internal::AdjustConstness_##constness(this)-> \
- gmock_##Method(::testing::A<GMOCK_ARG_(1, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(2, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(3, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(4, __VA_ARGS__)>()); \
- } \
- mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(4, constness, \
- Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD5_(constness, ct, Method, ...) \
- static_assert(5 == \
- ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \
- "MOCK_METHOD<N> must match argument count.");\
- GMOCK_RESULT_(__VA_ARGS__) ct Method( \
- GMOCK_ARG_(1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(2, \
- __VA_ARGS__) gmock_a2, GMOCK_ARG_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_ARG_(4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(5, \
- __VA_ARGS__) gmock_a5) constness { \
- GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \
- return GMOCK_MOCKER_(5, constness, \
- Method).Invoke(::std::forward<GMOCK_ARG_(1, __VA_ARGS__)>(gmock_a1), \
- \
- ::std::forward<GMOCK_ARG_(2, __VA_ARGS__)>(gmock_a2), \
- ::std::forward<GMOCK_ARG_(3, __VA_ARGS__)>(gmock_a3), \
- ::std::forward<GMOCK_ARG_(4, __VA_ARGS__)>(gmock_a4), \
- ::std::forward<GMOCK_ARG_(5, __VA_ARGS__)>(gmock_a5)); \
- } \
- ::testing::MockSpec<__VA_ARGS__> \
- gmock_##Method(GMOCK_MATCHER_(1, __VA_ARGS__) gmock_a1, \
- GMOCK_MATCHER_(2, __VA_ARGS__) gmock_a2, \
- GMOCK_MATCHER_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_MATCHER_(4, __VA_ARGS__) gmock_a4, \
- GMOCK_MATCHER_(5, __VA_ARGS__) gmock_a5) constness { \
- GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \
- return GMOCK_MOCKER_(5, constness, Method).With(gmock_a1, gmock_a2, \
- gmock_a3, gmock_a4, gmock_a5); \
- } \
- ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
- const ::testing::internal::WithoutMatchers&, \
- constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
- return ::testing::internal::AdjustConstness_##constness(this)-> \
- gmock_##Method(::testing::A<GMOCK_ARG_(1, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(2, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(3, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(4, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(5, __VA_ARGS__)>()); \
- } \
- mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(5, constness, \
- Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD6_(constness, ct, Method, ...) \
- static_assert(6 == \
- ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \
- "MOCK_METHOD<N> must match argument count.");\
- GMOCK_RESULT_(__VA_ARGS__) ct Method( \
- GMOCK_ARG_(1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(2, \
- __VA_ARGS__) gmock_a2, GMOCK_ARG_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_ARG_(4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(5, \
- __VA_ARGS__) gmock_a5, GMOCK_ARG_(6, \
- __VA_ARGS__) gmock_a6) constness { \
- GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \
- return GMOCK_MOCKER_(6, constness, \
- Method).Invoke(::std::forward<GMOCK_ARG_(1, __VA_ARGS__)>(gmock_a1), \
- \
- ::std::forward<GMOCK_ARG_(2, __VA_ARGS__)>(gmock_a2), \
- ::std::forward<GMOCK_ARG_(3, __VA_ARGS__)>(gmock_a3), \
- ::std::forward<GMOCK_ARG_(4, __VA_ARGS__)>(gmock_a4), \
- ::std::forward<GMOCK_ARG_(5, __VA_ARGS__)>(gmock_a5), \
- ::std::forward<GMOCK_ARG_(6, __VA_ARGS__)>(gmock_a6)); \
- } \
- ::testing::MockSpec<__VA_ARGS__> \
- gmock_##Method(GMOCK_MATCHER_(1, __VA_ARGS__) gmock_a1, \
- GMOCK_MATCHER_(2, __VA_ARGS__) gmock_a2, \
- GMOCK_MATCHER_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_MATCHER_(4, __VA_ARGS__) gmock_a4, \
- GMOCK_MATCHER_(5, __VA_ARGS__) gmock_a5, \
- GMOCK_MATCHER_(6, __VA_ARGS__) gmock_a6) constness { \
- GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \
- return GMOCK_MOCKER_(6, constness, Method).With(gmock_a1, gmock_a2, \
- gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
- } \
- ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
- const ::testing::internal::WithoutMatchers&, \
- constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
- return ::testing::internal::AdjustConstness_##constness(this)-> \
- gmock_##Method(::testing::A<GMOCK_ARG_(1, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(2, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(3, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(4, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(5, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(6, __VA_ARGS__)>()); \
- } \
- mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(6, constness, \
- Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD7_(constness, ct, Method, ...) \
- static_assert(7 == \
- ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \
- "MOCK_METHOD<N> must match argument count.");\
- GMOCK_RESULT_(__VA_ARGS__) ct Method( \
- GMOCK_ARG_(1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(2, \
- __VA_ARGS__) gmock_a2, GMOCK_ARG_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_ARG_(4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(5, \
- __VA_ARGS__) gmock_a5, GMOCK_ARG_(6, __VA_ARGS__) gmock_a6, \
- GMOCK_ARG_(7, __VA_ARGS__) gmock_a7) constness { \
- GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \
- return GMOCK_MOCKER_(7, constness, \
- Method).Invoke(::std::forward<GMOCK_ARG_(1, __VA_ARGS__)>(gmock_a1), \
- \
- ::std::forward<GMOCK_ARG_(2, __VA_ARGS__)>(gmock_a2), \
- ::std::forward<GMOCK_ARG_(3, __VA_ARGS__)>(gmock_a3), \
- ::std::forward<GMOCK_ARG_(4, __VA_ARGS__)>(gmock_a4), \
- ::std::forward<GMOCK_ARG_(5, __VA_ARGS__)>(gmock_a5), \
- ::std::forward<GMOCK_ARG_(6, __VA_ARGS__)>(gmock_a6), \
- ::std::forward<GMOCK_ARG_(7, __VA_ARGS__)>(gmock_a7)); \
- } \
- ::testing::MockSpec<__VA_ARGS__> \
- gmock_##Method(GMOCK_MATCHER_(1, __VA_ARGS__) gmock_a1, \
- GMOCK_MATCHER_(2, __VA_ARGS__) gmock_a2, \
- GMOCK_MATCHER_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_MATCHER_(4, __VA_ARGS__) gmock_a4, \
- GMOCK_MATCHER_(5, __VA_ARGS__) gmock_a5, \
- GMOCK_MATCHER_(6, __VA_ARGS__) gmock_a6, \
- GMOCK_MATCHER_(7, __VA_ARGS__) gmock_a7) constness { \
- GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \
- return GMOCK_MOCKER_(7, constness, Method).With(gmock_a1, gmock_a2, \
- gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
- } \
- ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
- const ::testing::internal::WithoutMatchers&, \
- constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
- return ::testing::internal::AdjustConstness_##constness(this)-> \
- gmock_##Method(::testing::A<GMOCK_ARG_(1, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(2, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(3, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(4, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(5, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(6, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(7, __VA_ARGS__)>()); \
- } \
- mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(7, constness, \
- Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD8_(constness, ct, Method, ...) \
- static_assert(8 == \
- ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \
- "MOCK_METHOD<N> must match argument count.");\
- GMOCK_RESULT_(__VA_ARGS__) ct Method( \
- GMOCK_ARG_(1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(2, \
- __VA_ARGS__) gmock_a2, GMOCK_ARG_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_ARG_(4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(5, \
- __VA_ARGS__) gmock_a5, GMOCK_ARG_(6, __VA_ARGS__) gmock_a6, \
- GMOCK_ARG_(7, __VA_ARGS__) gmock_a7, GMOCK_ARG_(8, \
- __VA_ARGS__) gmock_a8) constness { \
- GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \
- return GMOCK_MOCKER_(8, constness, \
- Method).Invoke(::std::forward<GMOCK_ARG_(1, __VA_ARGS__)>(gmock_a1), \
- \
- ::std::forward<GMOCK_ARG_(2, __VA_ARGS__)>(gmock_a2), \
- ::std::forward<GMOCK_ARG_(3, __VA_ARGS__)>(gmock_a3), \
- ::std::forward<GMOCK_ARG_(4, __VA_ARGS__)>(gmock_a4), \
- ::std::forward<GMOCK_ARG_(5, __VA_ARGS__)>(gmock_a5), \
- ::std::forward<GMOCK_ARG_(6, __VA_ARGS__)>(gmock_a6), \
- ::std::forward<GMOCK_ARG_(7, __VA_ARGS__)>(gmock_a7), \
- ::std::forward<GMOCK_ARG_(8, __VA_ARGS__)>(gmock_a8)); \
- } \
- ::testing::MockSpec<__VA_ARGS__> \
- gmock_##Method(GMOCK_MATCHER_(1, __VA_ARGS__) gmock_a1, \
- GMOCK_MATCHER_(2, __VA_ARGS__) gmock_a2, \
- GMOCK_MATCHER_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_MATCHER_(4, __VA_ARGS__) gmock_a4, \
- GMOCK_MATCHER_(5, __VA_ARGS__) gmock_a5, \
- GMOCK_MATCHER_(6, __VA_ARGS__) gmock_a6, \
- GMOCK_MATCHER_(7, __VA_ARGS__) gmock_a7, \
- GMOCK_MATCHER_(8, __VA_ARGS__) gmock_a8) constness { \
- GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \
- return GMOCK_MOCKER_(8, constness, Method).With(gmock_a1, gmock_a2, \
- gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
- } \
- ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
- const ::testing::internal::WithoutMatchers&, \
- constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
- return ::testing::internal::AdjustConstness_##constness(this)-> \
- gmock_##Method(::testing::A<GMOCK_ARG_(1, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(2, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(3, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(4, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(5, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(6, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(7, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(8, __VA_ARGS__)>()); \
- } \
- mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(8, constness, \
- Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD9_(constness, ct, Method, ...) \
- static_assert(9 == \
- ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \
- "MOCK_METHOD<N> must match argument count.");\
- GMOCK_RESULT_(__VA_ARGS__) ct Method( \
- GMOCK_ARG_(1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(2, \
- __VA_ARGS__) gmock_a2, GMOCK_ARG_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_ARG_(4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(5, \
- __VA_ARGS__) gmock_a5, GMOCK_ARG_(6, __VA_ARGS__) gmock_a6, \
- GMOCK_ARG_(7, __VA_ARGS__) gmock_a7, GMOCK_ARG_(8, \
- __VA_ARGS__) gmock_a8, GMOCK_ARG_(9, \
- __VA_ARGS__) gmock_a9) constness { \
- GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \
- return GMOCK_MOCKER_(9, constness, \
- Method).Invoke(::std::forward<GMOCK_ARG_(1, __VA_ARGS__)>(gmock_a1), \
- \
- ::std::forward<GMOCK_ARG_(2, __VA_ARGS__)>(gmock_a2), \
- ::std::forward<GMOCK_ARG_(3, __VA_ARGS__)>(gmock_a3), \
- ::std::forward<GMOCK_ARG_(4, __VA_ARGS__)>(gmock_a4), \
- ::std::forward<GMOCK_ARG_(5, __VA_ARGS__)>(gmock_a5), \
- ::std::forward<GMOCK_ARG_(6, __VA_ARGS__)>(gmock_a6), \
- ::std::forward<GMOCK_ARG_(7, __VA_ARGS__)>(gmock_a7), \
- ::std::forward<GMOCK_ARG_(8, __VA_ARGS__)>(gmock_a8), \
- ::std::forward<GMOCK_ARG_(9, __VA_ARGS__)>(gmock_a9)); \
- } \
- ::testing::MockSpec<__VA_ARGS__> \
- gmock_##Method(GMOCK_MATCHER_(1, __VA_ARGS__) gmock_a1, \
- GMOCK_MATCHER_(2, __VA_ARGS__) gmock_a2, \
- GMOCK_MATCHER_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_MATCHER_(4, __VA_ARGS__) gmock_a4, \
- GMOCK_MATCHER_(5, __VA_ARGS__) gmock_a5, \
- GMOCK_MATCHER_(6, __VA_ARGS__) gmock_a6, \
- GMOCK_MATCHER_(7, __VA_ARGS__) gmock_a7, \
- GMOCK_MATCHER_(8, __VA_ARGS__) gmock_a8, \
- GMOCK_MATCHER_(9, __VA_ARGS__) gmock_a9) constness { \
- GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \
- return GMOCK_MOCKER_(9, constness, Method).With(gmock_a1, gmock_a2, \
- gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
- gmock_a9); \
- } \
- ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
- const ::testing::internal::WithoutMatchers&, \
- constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
- return ::testing::internal::AdjustConstness_##constness(this)-> \
- gmock_##Method(::testing::A<GMOCK_ARG_(1, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(2, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(3, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(4, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(5, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(6, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(7, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(8, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(9, __VA_ARGS__)>()); \
- } \
- mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(9, constness, \
- Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD10_(constness, ct, Method, ...) \
- static_assert(10 == \
- ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \
- "MOCK_METHOD<N> must match argument count.");\
- GMOCK_RESULT_(__VA_ARGS__) ct Method( \
- GMOCK_ARG_(1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(2, \
- __VA_ARGS__) gmock_a2, GMOCK_ARG_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_ARG_(4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(5, \
- __VA_ARGS__) gmock_a5, GMOCK_ARG_(6, __VA_ARGS__) gmock_a6, \
- GMOCK_ARG_(7, __VA_ARGS__) gmock_a7, GMOCK_ARG_(8, \
- __VA_ARGS__) gmock_a8, GMOCK_ARG_(9, __VA_ARGS__) gmock_a9, \
- GMOCK_ARG_(10, __VA_ARGS__) gmock_a10) constness { \
- GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \
- return GMOCK_MOCKER_(10, constness, \
- Method).Invoke(::std::forward<GMOCK_ARG_(1, __VA_ARGS__)>(gmock_a1), \
- \
- ::std::forward<GMOCK_ARG_(2, __VA_ARGS__)>(gmock_a2), \
- ::std::forward<GMOCK_ARG_(3, __VA_ARGS__)>(gmock_a3), \
- ::std::forward<GMOCK_ARG_(4, __VA_ARGS__)>(gmock_a4), \
- ::std::forward<GMOCK_ARG_(5, __VA_ARGS__)>(gmock_a5), \
- ::std::forward<GMOCK_ARG_(6, __VA_ARGS__)>(gmock_a6), \
- ::std::forward<GMOCK_ARG_(7, __VA_ARGS__)>(gmock_a7), \
- ::std::forward<GMOCK_ARG_(8, __VA_ARGS__)>(gmock_a8), \
- ::std::forward<GMOCK_ARG_(9, __VA_ARGS__)>(gmock_a9), \
- ::std::forward<GMOCK_ARG_(10, __VA_ARGS__)>(gmock_a10)); \
- } \
- ::testing::MockSpec<__VA_ARGS__> \
- gmock_##Method(GMOCK_MATCHER_(1, __VA_ARGS__) gmock_a1, \
- GMOCK_MATCHER_(2, __VA_ARGS__) gmock_a2, \
- GMOCK_MATCHER_(3, __VA_ARGS__) gmock_a3, \
- GMOCK_MATCHER_(4, __VA_ARGS__) gmock_a4, \
- GMOCK_MATCHER_(5, __VA_ARGS__) gmock_a5, \
- GMOCK_MATCHER_(6, __VA_ARGS__) gmock_a6, \
- GMOCK_MATCHER_(7, __VA_ARGS__) gmock_a7, \
- GMOCK_MATCHER_(8, __VA_ARGS__) gmock_a8, \
- GMOCK_MATCHER_(9, __VA_ARGS__) gmock_a9, \
- GMOCK_MATCHER_(10, __VA_ARGS__) gmock_a10) constness { \
- GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \
- return GMOCK_MOCKER_(10, constness, Method).With(gmock_a1, gmock_a2, \
- gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
- gmock_a10); \
- } \
- ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
- const ::testing::internal::WithoutMatchers&, \
- constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
- return ::testing::internal::AdjustConstness_##constness(this)-> \
- gmock_##Method(::testing::A<GMOCK_ARG_(1, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(2, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(3, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(4, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(5, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(6, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(7, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(8, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(9, __VA_ARGS__)>(), \
- ::testing::A<GMOCK_ARG_(10, __VA_ARGS__)>()); \
- } \
- mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(10, constness, \
- Method)
-
-
-} // namespace testing
-
-#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
diff --git a/googlemock/include/gmock/gmock-generated-function-mockers.h.pump b/googlemock/include/gmock/gmock-generated-function-mockers.h.pump
deleted file mode 100644
index d240a89f..00000000
--- a/googlemock/include/gmock/gmock-generated-function-mockers.h.pump
+++ /dev/null
@@ -1,176 +0,0 @@
-$$ -*- mode: c++; -*-
-$$ This is a Pump source file. Please use Pump to convert
-$$ it to gmock-generated-function-mockers.h.
-$$
-$var n = 10 $$ The maximum arity we support.
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file implements function mockers of various arities.
-
-// GOOGLETEST_CM0002 DO NOT DELETE
-
-#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
-#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
-
-#include <functional>
-#include <utility>
-
-#include "gmock/gmock-spec-builders.h"
-#include "gmock/internal/gmock-internal-utils.h"
-
-namespace testing {
-namespace internal {
-
-$range i 0..n
-// Removes the given pointer; this is a helper for the expectation setter method
-// for parameterless matchers.
-//
-// We want to make sure that the user cannot set a parameterless expectation on
-// overloaded methods, including methods which are overloaded on const. Example:
-//
-// class MockClass {
-// MOCK_METHOD0(GetName, string&());
-// MOCK_CONST_METHOD0(GetName, const string&());
-// };
-//
-// TEST() {
-// // This should be an error, as it's not clear which overload is expected.
-// EXPECT_CALL(mock, GetName).WillOnce(ReturnRef(value));
-// }
-//
-// Here are the generated expectation-setter methods:
-//
-// class MockClass {
-// // Overload 1
-// MockSpec<string&()> gmock_GetName() { ... }
-// // Overload 2. Declared const so that the compiler will generate an
-// // error when trying to resolve between this and overload 4 in
-// // 'gmock_GetName(WithoutMatchers(), nullptr)'.
-// MockSpec<string&()> gmock_GetName(
-// const WithoutMatchers&, const Function<string&()>*) const {
-// // Removes const from this, calls overload 1
-// return AdjustConstness_(this)->gmock_GetName();
-// }
-//
-// // Overload 3
-// const string& gmock_GetName() const { ... }
-// // Overload 4
-// MockSpec<const string&()> gmock_GetName(
-// const WithoutMatchers&, const Function<const string&()>*) const {
-// // Does not remove const, calls overload 3
-// return AdjustConstness_const(this)->gmock_GetName();
-// }
-// }
-//
-template <typename MockType>
-const MockType* AdjustConstness_const(const MockType* mock) {
- return mock;
-}
-
-// Removes const from and returns the given pointer; this is a helper for the
-// expectation setter method for parameterless matchers.
-template <typename MockType>
-MockType* AdjustConstness_(const MockType* mock) {
- return const_cast<MockType*>(mock);
-}
-
-} // namespace internal
-
-// The style guide prohibits "using" statements in a namespace scope
-// inside a header file. However, the FunctionMocker class template
-// is meant to be defined in the ::testing namespace. The following
-// line is just a trick for working around a bug in MSVC 8.0, which
-// cannot handle it if we define FunctionMocker in ::testing.
-using internal::FunctionMocker;
-
-// GMOCK_RESULT_(tn, F) expands to the result type of function type F.
-// We define this as a variadic macro in case F contains unprotected
-// commas (the same reason that we use variadic macros in other places
-// in this file).
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_RESULT_(...) \
- typename ::testing::internal::Function<__VA_ARGS__>::Result
-
-// The type of argument N of the given function type.
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_ARG_(N, ...) \
- typename ::testing::internal::Function<__VA_ARGS__>::template Arg<N-1>::type
-
-// The matcher type for argument N of the given function type.
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_MATCHER_(N, ...) \
- const ::testing::Matcher<GMOCK_ARG_(N, __VA_ARGS__)>&
-
-// The variable for mocking the given method.
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_MOCKER_(arity, constness, Method) \
- GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
-
-
-$for i [[
-$range j 1..i
-$var arg_as = [[$for j, [[GMOCK_ARG_($j, __VA_ARGS__) gmock_a$j]]]]
-$var as = [[$for j, \
- [[::std::forward<GMOCK_ARG_($j, __VA_ARGS__)>(gmock_a$j)]]]]
-$var matcher_arg_as = [[$for j, \
- [[GMOCK_MATCHER_($j, __VA_ARGS__) gmock_a$j]]]]
-$var matcher_as = [[$for j, [[gmock_a$j]]]]
-$var anything_matchers = [[$for j, \
- [[::testing::A<GMOCK_ARG_($j, __VA_ARGS__)>()]]]]
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD$i[[]]_(constness, ct, Method, ...) \
- static_assert($i == ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, "MOCK_METHOD<N> must match argument count.");\
- GMOCK_RESULT_(__VA_ARGS__) ct Method( \
- $arg_as) constness { \
- GMOCK_MOCKER_($i, constness, Method).SetOwnerAndName(this, #Method); \
- return GMOCK_MOCKER_($i, constness, Method).Invoke($as); \
- } \
- ::testing::MockSpec<__VA_ARGS__> \
- gmock_##Method($matcher_arg_as) constness { \
- GMOCK_MOCKER_($i, constness, Method).RegisterOwner(this); \
- return GMOCK_MOCKER_($i, constness, Method).With($matcher_as); \
- } \
- ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
- const ::testing::internal::WithoutMatchers&, \
- constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
- return ::testing::internal::AdjustConstness_##constness(this)-> \
- gmock_##Method($anything_matchers); \
- } \
- mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_($i, constness, Method)
-
-
-]]
-
-} // namespace testing
-
-#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
diff --git a/googlemock/include/gmock/gmock.h b/googlemock/include/gmock/gmock.h
index 99c3d787..969f3ca7 100644
--- a/googlemock/include/gmock/gmock.h
+++ b/googlemock/include/gmock/gmock.h
@@ -60,7 +60,6 @@
#include "gmock/gmock-cardinalities.h"
#include "gmock/gmock-function-mocker.h"
#include "gmock/gmock-generated-actions.h"
-#include "gmock/gmock-generated-function-mockers.h"
#include "gmock/gmock-generated-matchers.h"
#include "gmock/gmock-matchers.h"
#include "gmock/gmock-more-actions.h"
diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc
index 90d6b5f1..019e3cb9 100644
--- a/googlemock/test/gmock-function-mocker_test.cc
+++ b/googlemock/test/gmock-function-mocker_test.cc
@@ -31,7 +31,7 @@
// Google Mock - a framework for writing C++ mock classes.
//
// This file tests the function mocker classes.
-#include "gmock/gmock-generated-function-mockers.h"
+#include "gmock/gmock-function-mocker.h"
#if GTEST_OS_WINDOWS
// MSDN says the header file to be included for STDMETHOD is BaseTyps.h but
@@ -183,182 +183,238 @@ class MockFoo : public FooInterface {
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
};
+
+class LegacyMockFoo : public FooInterface {
+ public:
+ LegacyMockFoo() {}
+
+ // Makes sure that a mock function parameter can be named.
+ MOCK_METHOD1(VoidReturning, void(int n)); // NOLINT
+
+ MOCK_METHOD0(Nullary, int()); // NOLINT
+
+ // Makes sure that a mock function parameter can be unnamed.
+ MOCK_METHOD1(Unary, bool(int)); // NOLINT
+ MOCK_METHOD2(Binary, long(short, int)); // NOLINT
+ MOCK_METHOD10(Decimal, int(bool, char, short, int, long, float, // NOLINT
+ double, unsigned, char*, const std::string& str));
+
+ MOCK_METHOD1(TakesNonConstReference, bool(int&)); // NOLINT
+ MOCK_METHOD1(TakesConstReference, std::string(const int&));
+ MOCK_METHOD1(TakesConst, bool(const int)); // NOLINT
+
+ // Tests that the function return type can contain unprotected comma.
+ MOCK_METHOD0(ReturnTypeWithComma, std::map<int, std::string>());
+ MOCK_CONST_METHOD1(ReturnTypeWithComma,
+ std::map<int, std::string>(int)); // NOLINT
+
+ MOCK_METHOD0(OverloadedOnArgumentNumber, int()); // NOLINT
+ MOCK_METHOD1(OverloadedOnArgumentNumber, int(int)); // NOLINT
+
+ MOCK_METHOD1(OverloadedOnArgumentType, int(int)); // NOLINT
+ MOCK_METHOD1(OverloadedOnArgumentType, char(char)); // NOLINT
+
+ MOCK_METHOD0(OverloadedOnConstness, int()); // NOLINT
+ MOCK_CONST_METHOD0(OverloadedOnConstness, char()); // NOLINT
+
+ MOCK_METHOD1(TypeWithHole, int(int (*)())); // NOLINT
+ MOCK_METHOD1(TypeWithComma,
+ int(const std::map<int, std::string>&)); // NOLINT
+ MOCK_METHOD1(TypeWithTemplatedCopyCtor,
+ int(const TemplatedCopyable<int>&)); // NOLINT
+
+ MOCK_METHOD1(ReturnsFunctionPointer1, int (*(int))(bool));
+ MOCK_METHOD1(ReturnsFunctionPointer2, fn_ptr(int));
+
+#if GTEST_OS_WINDOWS
+ MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTNullary, int());
+ MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTUnary, bool(int)); // NOLINT
+ MOCK_METHOD10_WITH_CALLTYPE(STDMETHODCALLTYPE, CTDecimal,
+ int(bool b, char c, short d, int e, // NOLINT
+ long f, float g, double h, // NOLINT
+ unsigned i, char* j, const std::string& k));
+ MOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTConst,
+ char(int)); // NOLINT
+
+ // Tests that the function return type can contain unprotected comma.
+ MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTReturnTypeWithComma,
+ std::map<int, std::string>());
+#endif // GTEST_OS_WINDOWS
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockFoo);
+};
+
#ifdef _MSC_VER
# pragma warning(pop)
#endif
-class MockMethodFunctionMockerTest : public testing::Test {
+template <class T>
+class FunctionMockerTest : public testing::Test {
protected:
- MockMethodFunctionMockerTest() : foo_(&mock_foo_) {}
+ FunctionMockerTest() : foo_(&mock_foo_) {}
FooInterface* const foo_;
- MockFoo mock_foo_;
+ T mock_foo_;
};
+using FunctionMockerTestTypes = ::testing::Types<MockFoo, LegacyMockFoo>;
+TYPED_TEST_SUITE(FunctionMockerTest, FunctionMockerTestTypes);
// Tests mocking a void-returning function.
-TEST_F(MockMethodFunctionMockerTest, MocksVoidFunction) {
- EXPECT_CALL(mock_foo_, VoidReturning(Lt(100)));
- foo_->VoidReturning(0);
+TYPED_TEST(FunctionMockerTest, MocksVoidFunction) {
+ EXPECT_CALL(this->mock_foo_, VoidReturning(Lt(100)));
+ this->foo_->VoidReturning(0);
}
// Tests mocking a nullary function.
-TEST_F(MockMethodFunctionMockerTest, MocksNullaryFunction) {
- EXPECT_CALL(mock_foo_, Nullary())
+TYPED_TEST(FunctionMockerTest, MocksNullaryFunction) {
+ EXPECT_CALL(this->mock_foo_, Nullary())
.WillOnce(DoDefault())
.WillOnce(Return(1));
- EXPECT_EQ(0, foo_->Nullary());
- EXPECT_EQ(1, foo_->Nullary());
+ EXPECT_EQ(0, this->foo_->Nullary());
+ EXPECT_EQ(1, this->foo_->Nullary());
}
// Tests mocking a unary function.
-TEST_F(MockMethodFunctionMockerTest, MocksUnaryFunction) {
- EXPECT_CALL(mock_foo_, Unary(Eq(2)))
- .Times(2)
- .WillOnce(Return(true));
+TYPED_TEST(FunctionMockerTest, MocksUnaryFunction) {
+ EXPECT_CALL(this->mock_foo_, Unary(Eq(2))).Times(2).WillOnce(Return(true));
- EXPECT_TRUE(foo_->Unary(2));
- EXPECT_FALSE(foo_->Unary(2));
+ EXPECT_TRUE(this->foo_->Unary(2));
+ EXPECT_FALSE(this->foo_->Unary(2));
}
// Tests mocking a binary function.
-TEST_F(MockMethodFunctionMockerTest, MocksBinaryFunction) {
- EXPECT_CALL(mock_foo_, Binary(2, _))
- .WillOnce(Return(3));
+TYPED_TEST(FunctionMockerTest, MocksBinaryFunction) {
+ EXPECT_CALL(this->mock_foo_, Binary(2, _)).WillOnce(Return(3));
- EXPECT_EQ(3, foo_->Binary(2, 1));
+ EXPECT_EQ(3, this->foo_->Binary(2, 1));
}
// Tests mocking a decimal function.
-TEST_F(MockMethodFunctionMockerTest, MocksDecimalFunction) {
- EXPECT_CALL(mock_foo_, Decimal(true, 'a', 0, 0, 1L, A<float>(),
- Lt(100), 5U, NULL, "hi"))
+TYPED_TEST(FunctionMockerTest, MocksDecimalFunction) {
+ EXPECT_CALL(this->mock_foo_,
+ Decimal(true, 'a', 0, 0, 1L, A<float>(), Lt(100), 5U, NULL, "hi"))
.WillOnce(Return(5));
- EXPECT_EQ(5, foo_->Decimal(true, 'a', 0, 0, 1, 0, 0, 5, nullptr, "hi"));
+ EXPECT_EQ(5, this->foo_->Decimal(true, 'a', 0, 0, 1, 0, 0, 5, nullptr, "hi"));
}
// Tests mocking a function that takes a non-const reference.
-TEST_F(MockMethodFunctionMockerTest,
- MocksFunctionWithNonConstReferenceArgument) {
+TYPED_TEST(FunctionMockerTest, MocksFunctionWithNonConstReferenceArgument) {
int a = 0;
- EXPECT_CALL(mock_foo_, TakesNonConstReference(Ref(a)))
+ EXPECT_CALL(this->mock_foo_, TakesNonConstReference(Ref(a)))
.WillOnce(Return(true));
- EXPECT_TRUE(foo_->TakesNonConstReference(a));
+ EXPECT_TRUE(this->foo_->TakesNonConstReference(a));
}
// Tests mocking a function that takes a const reference.
-TEST_F(MockMethodFunctionMockerTest, MocksFunctionWithConstReferenceArgument) {
+TYPED_TEST(FunctionMockerTest, MocksFunctionWithConstReferenceArgument) {
int a = 0;
- EXPECT_CALL(mock_foo_, TakesConstReference(Ref(a)))
+ EXPECT_CALL(this->mock_foo_, TakesConstReference(Ref(a)))
.WillOnce(Return("Hello"));
- EXPECT_EQ("Hello", foo_->TakesConstReference(a));
+ EXPECT_EQ("Hello", this->foo_->TakesConstReference(a));
}
// Tests mocking a function that takes a const variable.
-TEST_F(MockMethodFunctionMockerTest, MocksFunctionWithConstArgument) {
- EXPECT_CALL(mock_foo_, TakesConst(Lt(10)))
- .WillOnce(DoDefault());
+TYPED_TEST(FunctionMockerTest, MocksFunctionWithConstArgument) {
+ EXPECT_CALL(this->mock_foo_, TakesConst(Lt(10))).WillOnce(DoDefault());
- EXPECT_FALSE(foo_->TakesConst(5));
+ EXPECT_FALSE(this->foo_->TakesConst(5));
}
// Tests mocking functions overloaded on the number of arguments.
-TEST_F(MockMethodFunctionMockerTest, MocksFunctionsOverloadedOnArgumentNumber) {
- EXPECT_CALL(mock_foo_, OverloadedOnArgumentNumber())
+TYPED_TEST(FunctionMockerTest, MocksFunctionsOverloadedOnArgumentNumber) {
+ EXPECT_CALL(this->mock_foo_, OverloadedOnArgumentNumber())
.WillOnce(Return(1));
- EXPECT_CALL(mock_foo_, OverloadedOnArgumentNumber(_))
+ EXPECT_CALL(this->mock_foo_, OverloadedOnArgumentNumber(_))
.WillOnce(Return(2));
- EXPECT_EQ(2, foo_->OverloadedOnArgumentNumber(1));
- EXPECT_EQ(1, foo_->OverloadedOnArgumentNumber());
+ EXPECT_EQ(2, this->foo_->OverloadedOnArgumentNumber(1));
+ EXPECT_EQ(1, this->foo_->OverloadedOnArgumentNumber());
}
// Tests mocking functions overloaded on the types of argument.
-TEST_F(MockMethodFunctionMockerTest, MocksFunctionsOverloadedOnArgumentType) {
- EXPECT_CALL(mock_foo_, OverloadedOnArgumentType(An<int>()))
+TYPED_TEST(FunctionMockerTest, MocksFunctionsOverloadedOnArgumentType) {
+ EXPECT_CALL(this->mock_foo_, OverloadedOnArgumentType(An<int>()))
.WillOnce(Return(1));
- EXPECT_CALL(mock_foo_, OverloadedOnArgumentType(TypedEq<char>('a')))
+ EXPECT_CALL(this->mock_foo_, OverloadedOnArgumentType(TypedEq<char>('a')))
.WillOnce(Return('b'));
- EXPECT_EQ(1, foo_->OverloadedOnArgumentType(0));
- EXPECT_EQ('b', foo_->OverloadedOnArgumentType('a'));
+ EXPECT_EQ(1, this->foo_->OverloadedOnArgumentType(0));
+ EXPECT_EQ('b', this->foo_->OverloadedOnArgumentType('a'));
}
// Tests mocking functions overloaded on the const-ness of this object.
-TEST_F(MockMethodFunctionMockerTest,
- MocksFunctionsOverloadedOnConstnessOfThis) {
- EXPECT_CALL(mock_foo_, OverloadedOnConstness());
- EXPECT_CALL(Const(mock_foo_), OverloadedOnConstness())
+TYPED_TEST(FunctionMockerTest, MocksFunctionsOverloadedOnConstnessOfThis) {
+ EXPECT_CALL(this->mock_foo_, OverloadedOnConstness());
+ EXPECT_CALL(Const(this->mock_foo_), OverloadedOnConstness())
.WillOnce(Return('a'));
- EXPECT_EQ(0, foo_->OverloadedOnConstness());
- EXPECT_EQ('a', Const(*foo_).OverloadedOnConstness());
+ EXPECT_EQ(0, this->foo_->OverloadedOnConstness());
+ EXPECT_EQ('a', Const(*this->foo_).OverloadedOnConstness());
}
-TEST_F(MockMethodFunctionMockerTest, MocksReturnTypeWithComma) {
+TYPED_TEST(FunctionMockerTest, MocksReturnTypeWithComma) {
const std::map<int, std::string> a_map;
- EXPECT_CALL(mock_foo_, ReturnTypeWithComma())
- .WillOnce(Return(a_map));
- EXPECT_CALL(mock_foo_, ReturnTypeWithComma(42))
- .WillOnce(Return(a_map));
+ EXPECT_CALL(this->mock_foo_, ReturnTypeWithComma()).WillOnce(Return(a_map));
+ EXPECT_CALL(this->mock_foo_, ReturnTypeWithComma(42)).WillOnce(Return(a_map));
- EXPECT_EQ(a_map, mock_foo_.ReturnTypeWithComma());
- EXPECT_EQ(a_map, mock_foo_.ReturnTypeWithComma(42));
+ EXPECT_EQ(a_map, this->mock_foo_.ReturnTypeWithComma());
+ EXPECT_EQ(a_map, this->mock_foo_.ReturnTypeWithComma(42));
}
-TEST_F(MockMethodFunctionMockerTest, MocksTypeWithTemplatedCopyCtor) {
- EXPECT_CALL(mock_foo_, TypeWithTemplatedCopyCtor(_)).WillOnce(Return(true));
- EXPECT_TRUE(foo_->TypeWithTemplatedCopyCtor(TemplatedCopyable<int>()));
+TYPED_TEST(FunctionMockerTest, MocksTypeWithTemplatedCopyCtor) {
+ EXPECT_CALL(this->mock_foo_, TypeWithTemplatedCopyCtor(_))
+ .WillOnce(Return(true));
+ EXPECT_TRUE(this->foo_->TypeWithTemplatedCopyCtor(TemplatedCopyable<int>()));
}
#if GTEST_OS_WINDOWS
// Tests mocking a nullary function with calltype.
-TEST_F(MockMethodFunctionMockerTest, MocksNullaryFunctionWithCallType) {
- EXPECT_CALL(mock_foo_, CTNullary())
+TYPED_TEST(FunctionMockerTest, MocksNullaryFunctionWithCallType) {
+ EXPECT_CALL(this->mock_foo_, CTNullary())
.WillOnce(Return(-1))
.WillOnce(Return(0));
- EXPECT_EQ(-1, foo_->CTNullary());
- EXPECT_EQ(0, foo_->CTNullary());
+ EXPECT_EQ(-1, this->foo_->CTNullary());
+ EXPECT_EQ(0, this->foo_->CTNullary());
}
// Tests mocking a unary function with calltype.
-TEST_F(MockMethodFunctionMockerTest, MocksUnaryFunctionWithCallType) {
- EXPECT_CALL(mock_foo_, CTUnary(Eq(2)))
+TYPED_TEST(FunctionMockerTest, MocksUnaryFunctionWithCallType) {
+ EXPECT_CALL(this->mock_foo_, CTUnary(Eq(2)))
.Times(2)
.WillOnce(Return(true))
.WillOnce(Return(false));
- EXPECT_TRUE(foo_->CTUnary(2));
- EXPECT_FALSE(foo_->CTUnary(2));
+ EXPECT_TRUE(this->foo_->CTUnary(2));
+ EXPECT_FALSE(this->foo_->CTUnary(2));
}
// Tests mocking a decimal function with calltype.
-TEST_F(MockMethodFunctionMockerTest, MocksDecimalFunctionWithCallType) {
- EXPECT_CALL(mock_foo_, CTDecimal(true, 'a', 0, 0, 1L, A<float>(),
- Lt(100), 5U, NULL, "hi"))
+TYPED_TEST(FunctionMockerTest, MocksDecimalFunctionWithCallType) {
+ EXPECT_CALL(this->mock_foo_, CTDecimal(true, 'a', 0, 0, 1L, A<float>(),
+ Lt(100), 5U, NULL, "hi"))
.WillOnce(Return(10));
- EXPECT_EQ(10, foo_->CTDecimal(true, 'a', 0, 0, 1, 0, 0, 5, NULL, "hi"));
+ EXPECT_EQ(10, this->foo_->CTDecimal(true, 'a', 0, 0, 1, 0, 0, 5, NULL, "hi"));
}
// Tests mocking functions overloaded on the const-ness of this object.
-TEST_F(MockMethodFunctionMockerTest, MocksFunctionsConstFunctionWithCallType) {
- EXPECT_CALL(Const(mock_foo_), CTConst(_))
- .WillOnce(Return('a'));
+TYPED_TEST(FunctionMockerTest, MocksFunctionsConstFunctionWithCallType) {
+ EXPECT_CALL(Const(this->mock_foo_), CTConst(_)).WillOnce(Return('a'));
- EXPECT_EQ('a', Const(*foo_).CTConst(0));
+ EXPECT_EQ('a', Const(*this->foo_).CTConst(0));
}
-TEST_F(MockMethodFunctionMockerTest, MocksReturnTypeWithCommaAndCallType) {
+TYPED_TEST(FunctionMockerTest, MocksReturnTypeWithCommaAndCallType) {
const std::map<int, std::string> a_map;
- EXPECT_CALL(mock_foo_, CTReturnTypeWithComma())
- .WillOnce(Return(a_map));
+ EXPECT_CALL(this->mock_foo_, CTReturnTypeWithComma()).WillOnce(Return(a_map));
- EXPECT_EQ(a_map, mock_foo_.CTReturnTypeWithComma());
+ EXPECT_EQ(a_map, this->mock_foo_.CTReturnTypeWithComma());
}
#endif // GTEST_OS_WINDOWS
@@ -373,20 +429,33 @@ class MockB {
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockB);
};
+class LegacyMockB {
+ public:
+ LegacyMockB() {}
+
+ MOCK_METHOD0(DoB, void());
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockB);
+};
+
+template <typename T>
+class ExpectCallTest : public ::testing::Test {};
+using ExpectCallTestTypes = ::testing::Types<MockB, LegacyMockB>;
+TYPED_TEST_SUITE(ExpectCallTest, ExpectCallTestTypes);
+
// Tests that functions with no EXPECT_CALL() rules can be called any
// number of times.
-TEST(MockMethodExpectCallTest, UnmentionedFunctionCanBeCalledAnyNumberOfTimes) {
- {
- MockB b;
- }
+TYPED_TEST(ExpectCallTest, UnmentionedFunctionCanBeCalledAnyNumberOfTimes) {
+ { TypeParam b; }
{
- MockB b;
+ TypeParam b;
b.DoB();
}
{
- MockB b;
+ TypeParam b;
b.DoB();
b.DoB();
}
@@ -425,9 +494,33 @@ class MockStack : public StackInterface<T> {
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStack);
};
+template <typename T>
+class LegacyMockStack : public StackInterface<T> {
+ public:
+ LegacyMockStack() {}
+
+ MOCK_METHOD1_T(Push, void(const T& elem));
+ MOCK_METHOD0_T(Pop, void());
+ MOCK_CONST_METHOD0_T(GetSize, int()); // NOLINT
+ MOCK_CONST_METHOD0_T(GetTop, const T&());
+
+ // Tests that the function return type can contain unprotected comma.
+ MOCK_METHOD0_T(ReturnTypeWithComma, std::map<int, int>());
+ MOCK_CONST_METHOD1_T(ReturnTypeWithComma, std::map<int, int>(int)); // NOLINT
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockStack);
+};
+
+template <typename T>
+class TemplateMockTest : public ::testing::Test {};
+using TemplateMockTestTypes =
+ ::testing::Types<MockStack<int>, LegacyMockStack<int>>;
+TYPED_TEST_SUITE(TemplateMockTest, TemplateMockTestTypes);
+
// Tests that template mock works.
-TEST(MockMethodTemplateMockTest, Works) {
- MockStack<int> mock;
+TYPED_TEST(TemplateMockTest, Works) {
+ TypeParam mock;
EXPECT_CALL(mock, GetSize())
.WillOnce(Return(0))
@@ -448,8 +541,8 @@ TEST(MockMethodTemplateMockTest, Works) {
EXPECT_EQ(0, mock.GetSize());
}
-TEST(MockMethodTemplateMockTest, MethodWithCommaInReturnTypeWorks) {
- MockStack<int> mock;
+TYPED_TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) {
+ TypeParam mock;
const std::map<int, int> a_map;
EXPECT_CALL(mock, ReturnTypeWithComma())
@@ -493,9 +586,31 @@ class MockStackWithCallType : public StackInterfaceWithCallType<T> {
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStackWithCallType);
};
+template <typename T>
+class LegacyMockStackWithCallType : public StackInterfaceWithCallType<T> {
+ public:
+ LegacyMockStackWithCallType() {}
+
+ MOCK_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Push, void(const T& elem));
+ MOCK_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Pop, void());
+ MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetSize, int());
+ MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetTop, const T&());
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockStackWithCallType);
+};
+
+template <typename T>
+class TemplateMockTestWithCallType : public ::testing::Test {};
+using TemplateMockTestWithCallTypeTypes =
+ ::testing::Types<MockStackWithCallType<int>,
+ LegacyMockStackWithCallType<int>>;
+TYPED_TEST_SUITE(TemplateMockTestWithCallType,
+ TemplateMockTestWithCallTypeTypes);
+
// Tests that template mock with calltype works.
-TEST(MockMethodTemplateMockTestWithCallType, Works) {
- MockStackWithCallType<int> mock;
+TYPED_TEST(TemplateMockTestWithCallType, Works) {
+ TypeParam mock;
EXPECT_CALL(mock, GetSize())
.WillOnce(Return(0))
@@ -522,6 +637,11 @@ TEST(MockMethodTemplateMockTestWithCallType, Works) {
MOCK_METHOD(int, Overloaded, (int), (const)); \
MOCK_METHOD(bool, Overloaded, (bool f, int n))
+#define LEGACY_MY_MOCK_METHODS1_ \
+ MOCK_METHOD0(Overloaded, void()); \
+ MOCK_CONST_METHOD1(Overloaded, int(int n)); \
+ MOCK_METHOD2(Overloaded, bool(bool f, int n))
+
class MockOverloadedOnArgNumber {
public:
MockOverloadedOnArgNumber() {}
@@ -532,8 +652,25 @@ class MockOverloadedOnArgNumber {
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnArgNumber);
};
-TEST(MockMethodOverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {
- MockOverloadedOnArgNumber mock;
+class LegacyMockOverloadedOnArgNumber {
+ public:
+ LegacyMockOverloadedOnArgNumber() {}
+
+ LEGACY_MY_MOCK_METHODS1_;
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockOverloadedOnArgNumber);
+};
+
+template <typename T>
+class OverloadedMockMethodTest : public ::testing::Test {};
+using OverloadedMockMethodTestTypes =
+ ::testing::Types<MockOverloadedOnArgNumber,
+ LegacyMockOverloadedOnArgNumber>;
+TYPED_TEST_SUITE(OverloadedMockMethodTest, OverloadedMockMethodTestTypes);
+
+TYPED_TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {
+ TypeParam mock;
EXPECT_CALL(mock, Overloaded());
EXPECT_CALL(mock, Overloaded(1)).WillOnce(Return(2));
EXPECT_CALL(mock, Overloaded(true, 1)).WillOnce(Return(true));
@@ -658,11 +795,35 @@ struct MockMethodSizes4 {
MOCK_METHOD(void, func, (int, int, int, int));
};
+struct LegacyMockMethodSizes0 {
+ MOCK_METHOD0(func, void());
+};
+struct LegacyMockMethodSizes1 {
+ MOCK_METHOD1(func, void(int));
+};
+struct LegacyMockMethodSizes2 {
+ MOCK_METHOD2(func, void(int, int));
+};
+struct LegacyMockMethodSizes3 {
+ MOCK_METHOD3(func, void(int, int, int));
+};
+struct LegacyMockMethodSizes4 {
+ MOCK_METHOD4(func, void(int, int, int, int));
+};
+
+
TEST(MockMethodMockFunctionTest, MockMethodSizeOverhead) {
EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes1));
EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes2));
EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes3));
EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes4));
+
+ EXPECT_EQ(sizeof(LegacyMockMethodSizes0), sizeof(LegacyMockMethodSizes1));
+ EXPECT_EQ(sizeof(LegacyMockMethodSizes0), sizeof(LegacyMockMethodSizes2));
+ EXPECT_EQ(sizeof(LegacyMockMethodSizes0), sizeof(LegacyMockMethodSizes3));
+ EXPECT_EQ(sizeof(LegacyMockMethodSizes0), sizeof(LegacyMockMethodSizes4));
+
+ EXPECT_EQ(sizeof(LegacyMockMethodSizes0), sizeof(MockMethodSizes0));
}
void hasTwoParams(int, int);
diff --git a/googlemock/test/gmock-generated-function-mockers_test.cc b/googlemock/test/gmock-generated-function-mockers_test.cc
deleted file mode 100644
index dff3a9f0..00000000
--- a/googlemock/test/gmock-generated-function-mockers_test.cc
+++ /dev/null
@@ -1,659 +0,0 @@
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file tests the function mocker classes.
-
-#include "gmock/gmock-generated-function-mockers.h"
-
-#if GTEST_OS_WINDOWS
-// MSDN says the header file to be included for STDMETHOD is BaseTyps.h but
-// we are getting compiler errors if we use basetyps.h, hence including
-// objbase.h for definition of STDMETHOD.
-# include <objbase.h>
-#endif // GTEST_OS_WINDOWS
-
-#include <map>
-#include <string>
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
-
-namespace testing {
-namespace gmock_generated_function_mockers_test {
-
-using testing::_;
-using testing::A;
-using testing::An;
-using testing::AnyNumber;
-using testing::Const;
-using testing::DoDefault;
-using testing::Eq;
-using testing::Lt;
-using testing::MockFunction;
-using testing::Ref;
-using testing::Return;
-using testing::ReturnRef;
-using testing::TypedEq;
-
-template<typename T>
-class TemplatedCopyable {
- public:
- TemplatedCopyable() {}
-
- template <typename U>
- TemplatedCopyable(const U& other) {} // NOLINT
-};
-
-class FooInterface {
- public:
- virtual ~FooInterface() {}
-
- virtual void VoidReturning(int x) = 0;
-
- virtual int Nullary() = 0;
- virtual bool Unary(int x) = 0;
- virtual long Binary(short x, int y) = 0; // NOLINT
- virtual int Decimal(bool b, char c, short d, int e, long f, // NOLINT
- float g, double h, unsigned i, char* j,
- const std::string& k) = 0;
-
- virtual bool TakesNonConstReference(int& n) = 0; // NOLINT
- virtual std::string TakesConstReference(const int& n) = 0;
- virtual bool TakesConst(const int x) = 0;
-
- virtual int OverloadedOnArgumentNumber() = 0;
- virtual int OverloadedOnArgumentNumber(int n) = 0;
-
- virtual int OverloadedOnArgumentType(int n) = 0;
- virtual char OverloadedOnArgumentType(char c) = 0;
-
- virtual int OverloadedOnConstness() = 0;
- virtual char OverloadedOnConstness() const = 0;
-
- virtual int TypeWithHole(int (*func)()) = 0;
- virtual int TypeWithComma(const std::map<int, std::string>& a_map) = 0;
- virtual int TypeWithTemplatedCopyCtor(
- const TemplatedCopyable<int>& a_vector) = 0;
-
-#if GTEST_OS_WINDOWS
- STDMETHOD_(int, CTNullary)() = 0;
- STDMETHOD_(bool, CTUnary)(int x) = 0;
- STDMETHOD_(int, CTDecimal)
- (bool b, char c, short d, int e, long f, // NOLINT
- float g, double h, unsigned i, char* j, const std::string& k) = 0;
- STDMETHOD_(char, CTConst)(int x) const = 0;
-#endif // GTEST_OS_WINDOWS
-};
-
-// Const qualifiers on arguments were once (incorrectly) considered
-// significant in determining whether two virtual functions had the same
-// signature. This was fixed in Visual Studio 2008. However, the compiler
-// still emits a warning that alerts about this change in behavior.
-#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable : 4373)
-#endif
-class MockFoo : public FooInterface {
- public:
- MockFoo() {}
-
- // Makes sure that a mock function parameter can be named.
- MOCK_METHOD1(VoidReturning, void(int n)); // NOLINT
-
- MOCK_METHOD0(Nullary, int()); // NOLINT
-
- // Makes sure that a mock function parameter can be unnamed.
- MOCK_METHOD1(Unary, bool(int)); // NOLINT
- MOCK_METHOD2(Binary, long(short, int)); // NOLINT
- MOCK_METHOD10(Decimal, int(bool, char, short, int, long, float, // NOLINT
- double, unsigned, char*, const std::string& str));
-
- MOCK_METHOD1(TakesNonConstReference, bool(int&)); // NOLINT
- MOCK_METHOD1(TakesConstReference, std::string(const int&));
- MOCK_METHOD1(TakesConst, bool(const int)); // NOLINT
-
- // Tests that the function return type can contain unprotected comma.
- MOCK_METHOD0(ReturnTypeWithComma, std::map<int, std::string>());
- MOCK_CONST_METHOD1(ReturnTypeWithComma,
- std::map<int, std::string>(int)); // NOLINT
-
- MOCK_METHOD0(OverloadedOnArgumentNumber, int()); // NOLINT
- MOCK_METHOD1(OverloadedOnArgumentNumber, int(int)); // NOLINT
-
- MOCK_METHOD1(OverloadedOnArgumentType, int(int)); // NOLINT
- MOCK_METHOD1(OverloadedOnArgumentType, char(char)); // NOLINT
-
- MOCK_METHOD0(OverloadedOnConstness, int()); // NOLINT
- MOCK_CONST_METHOD0(OverloadedOnConstness, char()); // NOLINT
-
- MOCK_METHOD1(TypeWithHole, int(int (*)())); // NOLINT
- MOCK_METHOD1(TypeWithComma,
- int(const std::map<int, std::string>&)); // NOLINT
- MOCK_METHOD1(TypeWithTemplatedCopyCtor,
- int(const TemplatedCopyable<int>&)); // NOLINT
-
-#if GTEST_OS_WINDOWS
- MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTNullary, int());
- MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTUnary, bool(int));
- MOCK_METHOD10_WITH_CALLTYPE(STDMETHODCALLTYPE, CTDecimal,
- int(bool b, char c, short d, int e, long f,
- float g, double h, unsigned i, char* j,
- const std::string& k));
- MOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTConst, char(int));
-
- // Tests that the function return type can contain unprotected comma.
- MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTReturnTypeWithComma,
- std::map<int, std::string>());
-#endif // GTEST_OS_WINDOWS
-
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
-};
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
-
-class FunctionMockerTest : public testing::Test {
- protected:
- FunctionMockerTest() : foo_(&mock_foo_) {}
-
- FooInterface* const foo_;
- MockFoo mock_foo_;
-};
-
-// Tests mocking a void-returning function.
-TEST_F(FunctionMockerTest, MocksVoidFunction) {
- EXPECT_CALL(mock_foo_, VoidReturning(Lt(100)));
- foo_->VoidReturning(0);
-}
-
-// Tests mocking a nullary function.
-TEST_F(FunctionMockerTest, MocksNullaryFunction) {
- EXPECT_CALL(mock_foo_, Nullary())
- .WillOnce(DoDefault())
- .WillOnce(Return(1));
-
- EXPECT_EQ(0, foo_->Nullary());
- EXPECT_EQ(1, foo_->Nullary());
-}
-
-// Tests mocking a unary function.
-TEST_F(FunctionMockerTest, MocksUnaryFunction) {
- EXPECT_CALL(mock_foo_, Unary(Eq(2)))
- .Times(2)
- .WillOnce(Return(true));
-
- EXPECT_TRUE(foo_->Unary(2));
- EXPECT_FALSE(foo_->Unary(2));
-}
-
-// Tests mocking a binary function.
-TEST_F(FunctionMockerTest, MocksBinaryFunction) {
- EXPECT_CALL(mock_foo_, Binary(2, _))
- .WillOnce(Return(3));
-
- EXPECT_EQ(3, foo_->Binary(2, 1));
-}
-
-// Tests mocking a decimal function.
-TEST_F(FunctionMockerTest, MocksDecimalFunction) {
- EXPECT_CALL(mock_foo_, Decimal(true, 'a', 0, 0, 1L, A<float>(), Lt(100), 5U,
- nullptr, "hi"))
- .WillOnce(Return(5));
-
- EXPECT_EQ(5, foo_->Decimal(true, 'a', 0, 0, 1, 0, 0, 5, nullptr, "hi"));
-}
-
-// Tests mocking a function that takes a non-const reference.
-TEST_F(FunctionMockerTest, MocksFunctionWithNonConstReferenceArgument) {
- int a = 0;
- EXPECT_CALL(mock_foo_, TakesNonConstReference(Ref(a)))
- .WillOnce(Return(true));
-
- EXPECT_TRUE(foo_->TakesNonConstReference(a));
-}
-
-// Tests mocking a function that takes a const reference.
-TEST_F(FunctionMockerTest, MocksFunctionWithConstReferenceArgument) {
- int a = 0;
- EXPECT_CALL(mock_foo_, TakesConstReference(Ref(a)))
- .WillOnce(Return("Hello"));
-
- EXPECT_EQ("Hello", foo_->TakesConstReference(a));
-}
-
-// Tests mocking a function that takes a const variable.
-TEST_F(FunctionMockerTest, MocksFunctionWithConstArgument) {
- EXPECT_CALL(mock_foo_, TakesConst(Lt(10)))
- .WillOnce(DoDefault());
-
- EXPECT_FALSE(foo_->TakesConst(5));
-}
-
-// Tests mocking functions overloaded on the number of arguments.
-TEST_F(FunctionMockerTest, MocksFunctionsOverloadedOnArgumentNumber) {
- EXPECT_CALL(mock_foo_, OverloadedOnArgumentNumber())
- .WillOnce(Return(1));
- EXPECT_CALL(mock_foo_, OverloadedOnArgumentNumber(_))
- .WillOnce(Return(2));
-
- EXPECT_EQ(2, foo_->OverloadedOnArgumentNumber(1));
- EXPECT_EQ(1, foo_->OverloadedOnArgumentNumber());
-}
-
-// Tests mocking functions overloaded on the types of argument.
-TEST_F(FunctionMockerTest, MocksFunctionsOverloadedOnArgumentType) {
- EXPECT_CALL(mock_foo_, OverloadedOnArgumentType(An<int>()))
- .WillOnce(Return(1));
- EXPECT_CALL(mock_foo_, OverloadedOnArgumentType(TypedEq<char>('a')))
- .WillOnce(Return('b'));
-
- EXPECT_EQ(1, foo_->OverloadedOnArgumentType(0));
- EXPECT_EQ('b', foo_->OverloadedOnArgumentType('a'));
-}
-
-// Tests mocking functions overloaded on the const-ness of this object.
-TEST_F(FunctionMockerTest, MocksFunctionsOverloadedOnConstnessOfThis) {
- EXPECT_CALL(mock_foo_, OverloadedOnConstness());
- EXPECT_CALL(Const(mock_foo_), OverloadedOnConstness())
- .WillOnce(Return('a'));
-
- EXPECT_EQ(0, foo_->OverloadedOnConstness());
- EXPECT_EQ('a', Const(*foo_).OverloadedOnConstness());
-}
-
-TEST_F(FunctionMockerTest, MocksReturnTypeWithComma) {
- const std::map<int, std::string> a_map;
- EXPECT_CALL(mock_foo_, ReturnTypeWithComma())
- .WillOnce(Return(a_map));
- EXPECT_CALL(mock_foo_, ReturnTypeWithComma(42))
- .WillOnce(Return(a_map));
-
- EXPECT_EQ(a_map, mock_foo_.ReturnTypeWithComma());
- EXPECT_EQ(a_map, mock_foo_.ReturnTypeWithComma(42));
-}
-
-TEST_F(FunctionMockerTest, MocksTypeWithTemplatedCopyCtor) {
- EXPECT_CALL(mock_foo_, TypeWithTemplatedCopyCtor(_)).WillOnce(Return(true));
- EXPECT_TRUE(foo_->TypeWithTemplatedCopyCtor(TemplatedCopyable<int>()));
-}
-
-#if GTEST_OS_WINDOWS
-// Tests mocking a nullary function with calltype.
-TEST_F(FunctionMockerTest, MocksNullaryFunctionWithCallType) {
- EXPECT_CALL(mock_foo_, CTNullary())
- .WillOnce(Return(-1))
- .WillOnce(Return(0));
-
- EXPECT_EQ(-1, foo_->CTNullary());
- EXPECT_EQ(0, foo_->CTNullary());
-}
-
-// Tests mocking a unary function with calltype.
-TEST_F(FunctionMockerTest, MocksUnaryFunctionWithCallType) {
- EXPECT_CALL(mock_foo_, CTUnary(Eq(2)))
- .Times(2)
- .WillOnce(Return(true))
- .WillOnce(Return(false));
-
- EXPECT_TRUE(foo_->CTUnary(2));
- EXPECT_FALSE(foo_->CTUnary(2));
-}
-
-// Tests mocking a decimal function with calltype.
-TEST_F(FunctionMockerTest, MocksDecimalFunctionWithCallType) {
- EXPECT_CALL(mock_foo_, CTDecimal(true, 'a', 0, 0, 1L, A<float>(), Lt(100), 5U,
- nullptr, "hi"))
- .WillOnce(Return(10));
-
- EXPECT_EQ(10, foo_->CTDecimal(true, 'a', 0, 0, 1, 0, 0, 5, nullptr, "hi"));
-}
-
-// Tests mocking functions overloaded on the const-ness of this object.
-TEST_F(FunctionMockerTest, MocksFunctionsConstFunctionWithCallType) {
- EXPECT_CALL(Const(mock_foo_), CTConst(_))
- .WillOnce(Return('a'));
-
- EXPECT_EQ('a', Const(*foo_).CTConst(0));
-}
-
-TEST_F(FunctionMockerTest, MocksReturnTypeWithCommaAndCallType) {
- const std::map<int, std::string> a_map;
- EXPECT_CALL(mock_foo_, CTReturnTypeWithComma())
- .WillOnce(Return(a_map));
-
- EXPECT_EQ(a_map, mock_foo_.CTReturnTypeWithComma());
-}
-
-#endif // GTEST_OS_WINDOWS
-
-class MockB {
- public:
- MockB() {}
-
- MOCK_METHOD0(DoB, void());
-
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(MockB);
-};
-
-// Tests that functions with no EXPECT_CALL() ruls can be called any
-// number of times.
-TEST(ExpectCallTest, UnmentionedFunctionCanBeCalledAnyNumberOfTimes) {
- {
- MockB b;
- }
-
- {
- MockB b;
- b.DoB();
- }
-
- {
- MockB b;
- b.DoB();
- b.DoB();
- }
-}
-
-// Tests mocking template interfaces.
-
-template <typename T>
-class StackInterface {
- public:
- virtual ~StackInterface() {}
-
- // Template parameter appears in function parameter.
- virtual void Push(const T& value) = 0;
- virtual void Pop() = 0;
- virtual int GetSize() const = 0;
- // Template parameter appears in function return type.
- virtual const T& GetTop() const = 0;
-};
-
-template <typename T>
-class MockStack : public StackInterface<T> {
- public:
- MockStack() {}
-
- MOCK_METHOD1_T(Push, void(const T& elem));
- MOCK_METHOD0_T(Pop, void());
- MOCK_CONST_METHOD0_T(GetSize, int()); // NOLINT
- MOCK_CONST_METHOD0_T(GetTop, const T&());
-
- // Tests that the function return type can contain unprotected comma.
- MOCK_METHOD0_T(ReturnTypeWithComma, std::map<int, int>());
- MOCK_CONST_METHOD1_T(ReturnTypeWithComma, std::map<int, int>(int)); // NOLINT
-
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStack);
-};
-
-// Tests that template mock works.
-TEST(TemplateMockTest, Works) {
- MockStack<int> mock;
-
- EXPECT_CALL(mock, GetSize())
- .WillOnce(Return(0))
- .WillOnce(Return(1))
- .WillOnce(Return(0));
- EXPECT_CALL(mock, Push(_));
- int n = 5;
- EXPECT_CALL(mock, GetTop())
- .WillOnce(ReturnRef(n));
- EXPECT_CALL(mock, Pop())
- .Times(AnyNumber());
-
- EXPECT_EQ(0, mock.GetSize());
- mock.Push(5);
- EXPECT_EQ(1, mock.GetSize());
- EXPECT_EQ(5, mock.GetTop());
- mock.Pop();
- EXPECT_EQ(0, mock.GetSize());
-}
-
-TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) {
- MockStack<int> mock;
-
- const std::map<int, int> a_map;
- EXPECT_CALL(mock, ReturnTypeWithComma())
- .WillOnce(Return(a_map));
- EXPECT_CALL(mock, ReturnTypeWithComma(1))
- .WillOnce(Return(a_map));
-
- EXPECT_EQ(a_map, mock.ReturnTypeWithComma());
- EXPECT_EQ(a_map, mock.ReturnTypeWithComma(1));
-}
-
-#if GTEST_OS_WINDOWS
-// Tests mocking template interfaces with calltype.
-
-template <typename T>
-class StackInterfaceWithCallType {
- public:
- virtual ~StackInterfaceWithCallType() {}
-
- // Template parameter appears in function parameter.
- STDMETHOD_(void, Push)(const T& value) = 0;
- STDMETHOD_(void, Pop)() = 0;
- STDMETHOD_(int, GetSize)() const = 0;
- // Template parameter appears in function return type.
- STDMETHOD_(const T&, GetTop)() const = 0;
-};
-
-template <typename T>
-class MockStackWithCallType : public StackInterfaceWithCallType<T> {
- public:
- MockStackWithCallType() {}
-
- MOCK_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Push, void(const T& elem));
- MOCK_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Pop, void());
- MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetSize, int());
- MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetTop, const T&());
-
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStackWithCallType);
-};
-
-// Tests that template mock with calltype works.
-TEST(TemplateMockTestWithCallType, Works) {
- MockStackWithCallType<int> mock;
-
- EXPECT_CALL(mock, GetSize())
- .WillOnce(Return(0))
- .WillOnce(Return(1))
- .WillOnce(Return(0));
- EXPECT_CALL(mock, Push(_));
- int n = 5;
- EXPECT_CALL(mock, GetTop())
- .WillOnce(ReturnRef(n));
- EXPECT_CALL(mock, Pop())
- .Times(AnyNumber());
-
- EXPECT_EQ(0, mock.GetSize());
- mock.Push(5);
- EXPECT_EQ(1, mock.GetSize());
- EXPECT_EQ(5, mock.GetTop());
- mock.Pop();
- EXPECT_EQ(0, mock.GetSize());
-}
-#endif // GTEST_OS_WINDOWS
-
-#define MY_MOCK_METHODS1_ \
- MOCK_METHOD0(Overloaded, void()); \
- MOCK_CONST_METHOD1(Overloaded, int(int n)); \
- MOCK_METHOD2(Overloaded, bool(bool f, int n))
-
-class MockOverloadedOnArgNumber {
- public:
- MockOverloadedOnArgNumber() {}
-
- MY_MOCK_METHODS1_;
-
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnArgNumber);
-};
-
-TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {
- MockOverloadedOnArgNumber mock;
- EXPECT_CALL(mock, Overloaded());
- EXPECT_CALL(mock, Overloaded(1)).WillOnce(Return(2));
- EXPECT_CALL(mock, Overloaded(true, 1)).WillOnce(Return(true));
-
- mock.Overloaded();
- EXPECT_EQ(2, mock.Overloaded(1));
- EXPECT_TRUE(mock.Overloaded(true, 1));
-}
-
-#define MY_MOCK_METHODS2_ \
- MOCK_CONST_METHOD1(Overloaded, int(int n)); \
- MOCK_METHOD1(Overloaded, int(int n))
-
-class MockOverloadedOnConstness {
- public:
- MockOverloadedOnConstness() {}
-
- MY_MOCK_METHODS2_;
-
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnConstness);
-};
-
-TEST(OverloadedMockMethodTest, CanOverloadOnConstnessInMacroBody) {
- MockOverloadedOnConstness mock;
- const MockOverloadedOnConstness* const_mock = &mock;
- EXPECT_CALL(mock, Overloaded(1)).WillOnce(Return(2));
- EXPECT_CALL(*const_mock, Overloaded(1)).WillOnce(Return(3));
-
- EXPECT_EQ(2, mock.Overloaded(1));
- EXPECT_EQ(3, const_mock->Overloaded(1));
-}
-
-TEST(MockFunctionTest, WorksForVoidNullary) {
- MockFunction<void()> foo;
- EXPECT_CALL(foo, Call());
- foo.Call();
-}
-
-TEST(MockFunctionTest, WorksForNonVoidNullary) {
- MockFunction<int()> foo;
- EXPECT_CALL(foo, Call())
- .WillOnce(Return(1))
- .WillOnce(Return(2));
- EXPECT_EQ(1, foo.Call());
- EXPECT_EQ(2, foo.Call());
-}
-
-TEST(MockFunctionTest, WorksForVoidUnary) {
- MockFunction<void(int)> foo;
- EXPECT_CALL(foo, Call(1));
- foo.Call(1);
-}
-
-TEST(MockFunctionTest, WorksForNonVoidBinary) {
- MockFunction<int(bool, int)> foo;
- EXPECT_CALL(foo, Call(false, 42))
- .WillOnce(Return(1))
- .WillOnce(Return(2));
- EXPECT_CALL(foo, Call(true, Ge(100)))
- .WillOnce(Return(3));
- EXPECT_EQ(1, foo.Call(false, 42));
- EXPECT_EQ(2, foo.Call(false, 42));
- EXPECT_EQ(3, foo.Call(true, 120));
-}
-
-TEST(MockFunctionTest, WorksFor10Arguments) {
- MockFunction<int(bool a0, char a1, int a2, int a3, int a4,
- int a5, int a6, char a7, int a8, bool a9)> foo;
- EXPECT_CALL(foo, Call(_, 'a', _, _, _, _, _, _, _, _))
- .WillOnce(Return(1))
- .WillOnce(Return(2));
- EXPECT_EQ(1, foo.Call(false, 'a', 0, 0, 0, 0, 0, 'b', 0, true));
- EXPECT_EQ(2, foo.Call(true, 'a', 0, 0, 0, 0, 0, 'b', 1, false));
-}
-
-TEST(MockFunctionTest, AsStdFunction) {
- MockFunction<int(int)> foo;
- auto call = [](const std::function<int(int)> &f, int i) {
- return f(i);
- };
- EXPECT_CALL(foo, Call(1)).WillOnce(Return(-1));
- EXPECT_CALL(foo, Call(2)).WillOnce(Return(-2));
- EXPECT_EQ(-1, call(foo.AsStdFunction(), 1));
- EXPECT_EQ(-2, call(foo.AsStdFunction(), 2));
-}
-
-TEST(MockFunctionTest, AsStdFunctionReturnsReference) {
- MockFunction<int&()> foo;
- int value = 1;
- EXPECT_CALL(foo, Call()).WillOnce(ReturnRef(value));
- int& ref = foo.AsStdFunction()();
- EXPECT_EQ(1, ref);
- value = 2;
- EXPECT_EQ(2, ref);
-}
-
-TEST(MockFunctionTest, AsStdFunctionWithReferenceParameter) {
- MockFunction<int(int &)> foo;
- auto call = [](const std::function<int(int& )> &f, int &i) {
- return f(i);
- };
- int i = 42;
- EXPECT_CALL(foo, Call(i)).WillOnce(Return(-1));
- EXPECT_EQ(-1, call(foo.AsStdFunction(), i));
-}
-
-
-struct MockMethodSizes0 {
- MOCK_METHOD0(func, void());
-};
-struct MockMethodSizes1 {
- MOCK_METHOD1(func, void(int));
-};
-struct MockMethodSizes2 {
- MOCK_METHOD2(func, void(int, int));
-};
-struct MockMethodSizes3 {
- MOCK_METHOD3(func, void(int, int, int));
-};
-struct MockMethodSizes4 {
- MOCK_METHOD4(func, void(int, int, int, int));
-};
-
-TEST(MockFunctionTest, MockMethodSizeOverhead) {
- EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes1));
- EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes2));
- EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes3));
- EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes4));
-}
-
-} // namespace gmock_generated_function_mockers_test
-} // namespace testing
diff --git a/googlemock/test/gmock_all_test.cc b/googlemock/test/gmock_all_test.cc
index b2b2027d..c53d0965 100644
--- a/googlemock/test/gmock_all_test.cc
+++ b/googlemock/test/gmock_all_test.cc
@@ -38,7 +38,6 @@
#include "test/gmock-actions_test.cc"
#include "test/gmock-cardinalities_test.cc"
#include "test/gmock-generated-actions_test.cc"
-#include "test/gmock-generated-function-mockers_test.cc"
#include "test/gmock-generated-matchers_test.cc"
#include "test/gmock-internal-utils_test.cc"
#include "test/gmock-matchers_test.cc"