From c231e6f5b152029dbd5fa4a9e0c04095035aec3f Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 14 Mar 2024 23:59:31 -0700 Subject: Add test for move-only type in `Action` signature PiperOrigin-RevId: 616031018 Change-Id: Ie724f9562174387eab866a824d28106f344c558d --- googlemock/test/gmock-more-actions_test.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc index 7ed89a9..354a79b 100644 --- a/googlemock/test/gmock-more-actions_test.cc +++ b/googlemock/test/gmock-more-actions_test.cc @@ -828,6 +828,22 @@ TEST(InvokeArgumentTest, ByExplicitConstReferenceFunction) { EXPECT_FALSE(a.Perform(std::make_tuple(&ReferencesGlobalDouble))); } +TEST(InvokeArgumentTest, MoveOnlyType) { + struct Marker {}; + struct { + // Method takes a unique_ptr (to a type we don't care about), and an + // invocable type. + MOCK_METHOD(bool, MockMethod, + (std::unique_ptr, std::function), ()); + } mock; + + ON_CALL(mock, MockMethod(_, _)).WillByDefault(InvokeArgument<1>()); + + // This compiles, but is a little opaque as a workaround: + ON_CALL(mock, MockMethod(_, _)) + .WillByDefault(WithArg<1>(InvokeArgument<0>())); +} + // Tests DoAll(a1, a2). TEST(DoAllTest, TwoActions) { int n = 0; -- cgit v0.12