summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2024-03-15 06:59:31 (GMT)
committerCopybara-Service <copybara-worker@google.com>2024-03-15 07:00:12 (GMT)
commitc231e6f5b152029dbd5fa4a9e0c04095035aec3f (patch)
tree7862176f3ba4125153d36892c13d63ea331fe48b
parentb479e7a3c161d7087113a05f8cb034b870313a55 (diff)
downloadgoogletest-c231e6f5b152029dbd5fa4a9e0c04095035aec3f.zip
googletest-c231e6f5b152029dbd5fa4a9e0c04095035aec3f.tar.gz
googletest-c231e6f5b152029dbd5fa4a9e0c04095035aec3f.tar.bz2
Add test for move-only type in `Action` signature
PiperOrigin-RevId: 616031018 Change-Id: Ie724f9562174387eab866a824d28106f344c558d
-rw-r--r--googlemock/test/gmock-more-actions_test.cc16
1 files changed, 16 insertions, 0 deletions
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<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;