Add test for move-only type in `Action` signature
PiperOrigin-RevId: 616031018
Change-Id: Ie724f9562174387eab866a824d28106f344c558d
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 @@
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<Marker>, std::function<int()>), ());
+ } 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;