merging
This commit is contained in:
		@@ -68,7 +68,7 @@ $for i [[
 | 
				
			|||||||
$range j 1..i
 | 
					$range j 1..i
 | 
				
			||||||
$var typename_As = [[$for j [[, typename A$j]]]]
 | 
					$var typename_As = [[$for j [[, typename A$j]]]]
 | 
				
			||||||
$var As = [[$for j, [[A$j]]]]
 | 
					$var As = [[$for j, [[A$j]]]]
 | 
				
			||||||
$var as = [[$for j, [[a$j]]]]
 | 
					$var as = [[$for j, [[internal::forward<A$j>(a$j)]]]]
 | 
				
			||||||
$var Aas = [[$for j, [[A$j a$j]]]]
 | 
					$var Aas = [[$for j, [[A$j a$j]]]]
 | 
				
			||||||
$var ms = [[$for j, [[m$j]]]]
 | 
					$var ms = [[$for j, [[m$j]]]]
 | 
				
			||||||
$var matchers = [[$for j, [[const Matcher<A$j>& m$j]]]]
 | 
					$var matchers = [[$for j, [[const Matcher<A$j>& m$j]]]]
 | 
				
			||||||
@@ -79,13 +79,8 @@ class FunctionMocker<R($As)> : public
 | 
				
			|||||||
  typedef R F($As);
 | 
					  typedef R F($As);
 | 
				
			||||||
  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
 | 
					  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  MockSpec<F>& With($matchers) {
 | 
					  MockSpec<F> With($matchers) {
 | 
				
			||||||
 | 
					    return MockSpec<F>(this, ::testing::make_tuple($ms));
 | 
				
			||||||
$if i >= 1 [[
 | 
					 | 
				
			||||||
    this->current_spec().SetMatchers(::testing::make_tuple($ms));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
]]
 | 
					 | 
				
			||||||
    return this->current_spec();
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  R Invoke($Aas) {
 | 
					  R Invoke($Aas) {
 | 
				
			||||||
@@ -134,11 +129,12 @@ using internal::FunctionMocker;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
$for i [[
 | 
					$for i [[
 | 
				
			||||||
$range j 1..i
 | 
					$range j 1..i
 | 
				
			||||||
$var arg_as = [[$for j, \
 | 
					$var arg_as = [[$for j, [[GMOCK_ARG_(tn, $j, __VA_ARGS__) gmock_a$j]]]]
 | 
				
			||||||
      [[GMOCK_ARG_(tn, $j, __VA_ARGS__) gmock_a$j]]]]
 | 
					$var as = [[$for j, \
 | 
				
			||||||
$var as = [[$for j, [[gmock_a$j]]]]
 | 
					  [[::testing::internal::forward<GMOCK_ARG_(tn, $j, __VA_ARGS__)>(gmock_a$j)]]]]
 | 
				
			||||||
$var matcher_as = [[$for j, \
 | 
					$var matcher_arg_as = [[$for j, \
 | 
				
			||||||
                     [[GMOCK_MATCHER_(tn, $j, __VA_ARGS__) gmock_a$j]]]]
 | 
					                     [[GMOCK_MATCHER_(tn, $j, __VA_ARGS__) gmock_a$j]]]]
 | 
				
			||||||
 | 
					$var matcher_as = [[$for j, [[gmock_a$j]]]]
 | 
				
			||||||
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
 | 
					// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
 | 
				
			||||||
#define GMOCK_METHOD$i[[]]_(tn, constness, ct, Method, ...) \
 | 
					#define GMOCK_METHOD$i[[]]_(tn, constness, ct, Method, ...) \
 | 
				
			||||||
  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
 | 
					  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
 | 
				
			||||||
@@ -149,10 +145,10 @@ $var matcher_as = [[$for j, \
 | 
				
			|||||||
    GMOCK_MOCKER_($i, constness, Method).SetOwnerAndName(this, #Method); \
 | 
					    GMOCK_MOCKER_($i, constness, Method).SetOwnerAndName(this, #Method); \
 | 
				
			||||||
    return GMOCK_MOCKER_($i, constness, Method).Invoke($as); \
 | 
					    return GMOCK_MOCKER_($i, constness, Method).Invoke($as); \
 | 
				
			||||||
  } \
 | 
					  } \
 | 
				
			||||||
  ::testing::MockSpec<__VA_ARGS__>& \
 | 
					  ::testing::MockSpec<__VA_ARGS__> \
 | 
				
			||||||
      gmock_##Method($matcher_as) constness { \
 | 
					      gmock_##Method($matcher_arg_as) constness { \
 | 
				
			||||||
    GMOCK_MOCKER_($i, constness, Method).RegisterOwner(this); \
 | 
					    GMOCK_MOCKER_($i, constness, Method).RegisterOwner(this); \
 | 
				
			||||||
    return GMOCK_MOCKER_($i, constness, Method).With($as); \
 | 
					    return GMOCK_MOCKER_($i, constness, Method).With($matcher_as); \
 | 
				
			||||||
  } \
 | 
					  } \
 | 
				
			||||||
  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_($i, constness, Method)
 | 
					  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_($i, constness, Method)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -263,7 +259,7 @@ class MockFunction;
 | 
				
			|||||||
$for i [[
 | 
					$for i [[
 | 
				
			||||||
$range j 0..i-1
 | 
					$range j 0..i-1
 | 
				
			||||||
$var ArgTypes = [[$for j, [[A$j]]]]
 | 
					$var ArgTypes = [[$for j, [[A$j]]]]
 | 
				
			||||||
$var ArgNames = [[$for j, [[a$j]]]]
 | 
					$var ArgValues = [[$for j, [[::std::move(a$j)]]]]
 | 
				
			||||||
$var ArgDecls = [[$for j, [[A$j a$j]]]]
 | 
					$var ArgDecls = [[$for j, [[A$j a$j]]]]
 | 
				
			||||||
template <typename R$for j [[, typename A$j]]>
 | 
					template <typename R$for j [[, typename A$j]]>
 | 
				
			||||||
class MockFunction<R($ArgTypes)> {
 | 
					class MockFunction<R($ArgTypes)> {
 | 
				
			||||||
@@ -273,9 +269,9 @@ class MockFunction<R($ArgTypes)> {
 | 
				
			|||||||
  MOCK_METHOD$i[[]]_T(Call, R($ArgTypes));
 | 
					  MOCK_METHOD$i[[]]_T(Call, R($ArgTypes));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if GTEST_HAS_STD_FUNCTION_
 | 
					#if GTEST_HAS_STD_FUNCTION_
 | 
				
			||||||
  std::function<R($ArgTypes)> AsStdFunction() {
 | 
					  ::std::function<R($ArgTypes)> AsStdFunction() {
 | 
				
			||||||
    return [this]($ArgDecls) -> R {
 | 
					    return [this]($ArgDecls) -> R {
 | 
				
			||||||
      return this->Call($ArgNames);
 | 
					      return this->Call($ArgValues);
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
#endif  // GTEST_HAS_STD_FUNCTION_
 | 
					#endif  // GTEST_HAS_STD_FUNCTION_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -620,5 +620,28 @@ TEST(MockFunctionTest, AsStdFunctionReturnsReference) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
#endif  // GTEST_HAS_STD_FUNCTION_
 | 
					#endif  // GTEST_HAS_STD_FUNCTION_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 gmock_generated_function_mockers_test
 | 
				
			||||||
}  // namespace testing
 | 
					}  // namespace testing
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user