Skip to content

Commit

Permalink
Add tests for MockFunction deduction (google#2277)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adambadura committed Mar 18, 2020
1 parent 482ac6e commit e41f31f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions googlemock/test/gmock-function-mocker_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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, ());
};
Expand Down

0 comments on commit e41f31f

Please sign in to comment.