From e41f31f2af3a713e8652d1e091a13bed22781ec3 Mon Sep 17 00:00:00 2001 From: Adam Badura Date: Thu, 26 Dec 2019 01:32:37 +0100 Subject: 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. --- googlemock/test/gmock-function-mocker_test.cc | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 +static constexpr bool IsMockFunctionTemplateArgumentDeducedTo(const MockFunction&) { + return std::is_same::value; +} + +} // namespace + +template +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 foo; + EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo(foo)); +} + + struct MockMethodSizes0 { MOCK_METHOD(void, func, ()); }; -- cgit v1.2.3