diff options
author | Adam Badura <adam.f.badura@gmail.com> | 2019-12-26 01:32:37 +0100 |
---|---|---|
committer | Adam Badura <adam.f.badura@gmail.com> | 2020-03-18 01:11:30 +0100 |
commit | e41f31f2af3a713e8652d1e091a13bed22781ec3 (patch) | |
tree | 2d1d4b59e096e1ef712897c9d8f763b0402bf6d8 /googlemock | |
parent | 482ac6ee63429af2aa9c44f4e6427873fb68fb1f (diff) | |
download | googletest-e41f31f2af3a713e8652d1e091a13bed22781ec3.tar.gz googletest-e41f31f2af3a713e8652d1e091a13bed22781ec3.tar.bz2 googletest-e41f31f2af3a713e8652d1e091a13bed22781ec3.zip |
Add tests for MockFunction deduction (#2277)
Add tests checking that ::testing::MockFunction template argument can
be deduced in a function call context. This is a property raised in the
review, however, not checked before by any tests.
Diffstat (limited to 'googlemock')
-rw-r--r-- | googlemock/test/gmock-function-mocker_test.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc index 019e3cb9..164c6b47 100644 --- a/googlemock/test/gmock-function-mocker_test.cc +++ b/googlemock/test/gmock-function-mocker_test.cc @@ -779,6 +779,36 @@ TEST(MockMethodMockFunctionTest, AsStdFunctionWithReferenceParameter) { } +namespace { + +template <typename Expected, typename F> +static constexpr bool IsMockFunctionTemplateArgumentDeducedTo(const MockFunction<F>&) { + return std::is_same<F, Expected>::value; +} + +} // namespace + +template <typename F> +class MockMethodMockFunctionSignatureTest : public Test { +}; + +using MockMethodMockFunctionSignatureTypes = Types< + void(), + int(), + void(int), + int(int), + int(bool, int), + int(bool, char, int, int, int, int, int, char, int, bool) +>; +TYPED_TEST_SUITE(MockMethodMockFunctionSignatureTest, MockMethodMockFunctionSignatureTypes); + +TYPED_TEST(MockMethodMockFunctionSignatureTest, IsMockFunctionTemplateArgumentDeduced) { + using Argument = TypeParam; + MockFunction<Argument> foo; + EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<Argument>(foo)); +} + + struct MockMethodSizes0 { MOCK_METHOD(void, func, ()); }; |