diff options
Diffstat (limited to 'googlemock/test/gmock-generated-function-mockers_test.cc')
-rw-r--r-- | googlemock/test/gmock-generated-function-mockers_test.cc | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/googlemock/test/gmock-generated-function-mockers_test.cc b/googlemock/test/gmock-generated-function-mockers_test.cc index 79130bc..dff3a9f 100644 --- a/googlemock/test/gmock-generated-function-mockers_test.cc +++ b/googlemock/test/gmock-generated-function-mockers_test.cc @@ -63,6 +63,15 @@ 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() {} @@ -91,6 +100,8 @@ class FooInterface { 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; @@ -146,6 +157,8 @@ class MockFoo : public FooInterface { 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()); @@ -288,6 +301,11 @@ TEST_F(FunctionMockerTest, MocksReturnTypeWithComma) { 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) { @@ -517,7 +535,7 @@ TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) { #define MY_MOCK_METHODS2_ \ MOCK_CONST_METHOD1(Overloaded, int(int n)); \ - MOCK_METHOD1(Overloaded, int(int n)); + MOCK_METHOD1(Overloaded, int(int n)) class MockOverloadedOnConstness { public: @@ -582,7 +600,6 @@ TEST(MockFunctionTest, WorksFor10Arguments) { EXPECT_EQ(2, foo.Call(true, 'a', 0, 0, 0, 0, 0, 'b', 1, false)); } -#if GTEST_HAS_STD_FUNCTION_ TEST(MockFunctionTest, AsStdFunction) { MockFunction<int(int)> foo; auto call = [](const std::function<int(int)> &f, int i) { @@ -614,7 +631,6 @@ TEST(MockFunctionTest, AsStdFunctionWithReferenceParameter) { EXPECT_EQ(-1, call(foo.AsStdFunction(), i)); } -#endif // GTEST_HAS_STD_FUNCTION_ struct MockMethodSizes0 { MOCK_METHOD0(func, void()); |