summaryrefslogtreecommitdiffstats
path: root/googlemock/test
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2021-05-13 15:57:24 (GMT)
committerCJ Johnson <johnsoncj@google.com>2021-05-13 19:08:57 (GMT)
commit662fe38e44900c007eccb65a5d2ea19df7bd520e (patch)
tree2148e950225e042f49d2634c6c312e7653c536fc /googlemock/test
parentd69a112956a700fefdfed9fc87a8c2568ec83407 (diff)
downloadgoogletest-662fe38e44900c007eccb65a5d2ea19df7bd520e.zip
googletest-662fe38e44900c007eccb65a5d2ea19df7bd520e.tar.gz
googletest-662fe38e44900c007eccb65a5d2ea19df7bd520e.tar.bz2
Googletest export
Support templating MockFunction over function objects besides std::function. PiperOrigin-RevId: 373586967
Diffstat (limited to 'googlemock/test')
-rw-r--r--googlemock/test/gmock-function-mocker_test.cc24
1 files changed, 18 insertions, 6 deletions
diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc
index 45a524e..cf76fa9 100644
--- a/googlemock/test/gmock-function-mocker_test.cc
+++ b/googlemock/test/gmock-function-mocker_test.cc
@@ -849,7 +849,7 @@ namespace {
template <typename Expected, typename F>
static constexpr bool IsMockFunctionTemplateArgumentDeducedTo(
- const MockFunction<F>&) {
+ const internal::MockFunction<F>&) {
return std::is_same<F, Expected>::value;
}
@@ -868,14 +868,14 @@ TYPED_TEST(MockMethodMockFunctionSignatureTest,
IsMockFunctionTemplateArgumentDeducedForRawSignature) {
using Argument = TypeParam;
MockFunction<Argument> foo;
- EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<Argument>(foo));
+ EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
}
TYPED_TEST(MockMethodMockFunctionSignatureTest,
IsMockFunctionTemplateArgumentDeducedForStdFunction) {
using Argument = std::function<TypeParam>;
MockFunction<Argument> foo;
- EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<Argument>(foo));
+ EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
}
TYPED_TEST(
@@ -887,15 +887,27 @@ TYPED_TEST(
EXPECT_TRUE((std::is_same<ForRawSignature, ForStdFunction>::value));
}
+template <typename F>
+struct AlternateCallable {
+};
+
+TYPED_TEST(MockMethodMockFunctionSignatureTest,
+ IsMockFunctionTemplateArgumentDeducedForAlternateCallable) {
+ using Argument = AlternateCallable<TypeParam>;
+ MockFunction<Argument> foo;
+ EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
+}
+
TYPED_TEST(
MockMethodMockFunctionSignatureTest,
- IsMockFunctionAsStdFunctionMethodSignatureTheSameForRawSignatureAndStdFunction) {
- using ForRawSignature = decltype(&MockFunction<TypeParam>::AsStdFunction);
+ IsMockFunctionCallMethodSignatureTheSameForAlternateCallable) {
+ using ForRawSignature = decltype(&MockFunction<TypeParam>::Call);
using ForStdFunction =
- decltype(&MockFunction<std::function<TypeParam>>::AsStdFunction);
+ decltype(&MockFunction<std::function<TypeParam>>::Call);
EXPECT_TRUE((std::is_same<ForRawSignature, ForStdFunction>::value));
}
+
struct MockMethodSizes0 {
MOCK_METHOD(void, func, ());
};