diff options
Diffstat (limited to 'googlemock/test/gmock-function-mocker_test.cc')
-rw-r--r-- | googlemock/test/gmock-function-mocker_test.cc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc index 019e3cb..94aaafb 100644 --- a/googlemock/test/gmock-function-mocker_test.cc +++ b/googlemock/test/gmock-function-mocker_test.cc @@ -40,6 +40,7 @@ # include <objbase.h> #endif // GTEST_OS_WINDOWS +#include <functional> #include <map> #include <string> #include <type_traits> @@ -778,6 +779,56 @@ TEST(MockMethodMockFunctionTest, AsStdFunctionWithReferenceParameter) { EXPECT_EQ(-1, call(foo.AsStdFunction(), i)); } +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, + IsMockFunctionTemplateArgumentDeducedForRawSignature) { + using Argument = TypeParam; + MockFunction<Argument> foo; + EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<Argument>(foo)); +} + +TYPED_TEST(MockMethodMockFunctionSignatureTest, + IsMockFunctionTemplateArgumentDeducedForStdFunction) { + using Argument = std::function<TypeParam>; + MockFunction<Argument> foo; + EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<Argument>(foo)); +} + +TYPED_TEST( + MockMethodMockFunctionSignatureTest, + IsMockFunctionCallMethodSignatureTheSameForRawSignatureAndStdFunction) { + using ForRawSignature = decltype(&MockFunction<TypeParam>::Call); + using ForStdFunction = + decltype(&MockFunction<std::function<TypeParam>>::Call); + EXPECT_TRUE((std::is_same<ForRawSignature, ForStdFunction>::value)); +} + +TYPED_TEST( + MockMethodMockFunctionSignatureTest, + IsMockFunctionAsStdFunctionMethodSignatureTheSameForRawSignatureAndStdFunction) { + using ForRawSignature = decltype(&MockFunction<TypeParam>::AsStdFunction); + using ForStdFunction = + decltype(&MockFunction<std::function<TypeParam>>::AsStdFunction); + EXPECT_TRUE((std::is_same<ForRawSignature, ForStdFunction>::value)); +} struct MockMethodSizes0 { MOCK_METHOD(void, func, ()); |