Skip to content

Commit c231e6f

Browse files
Abseil Teamcopybara-github
Abseil Team
authored andcommitted
Add test for move-only type in Action signature
PiperOrigin-RevId: 616031018 Change-Id: Ie724f9562174387eab866a824d28106f344c558d
1 parent b479e7a commit c231e6f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

googlemock/test/gmock-more-actions_test.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,22 @@ TEST(InvokeArgumentTest, ByExplicitConstReferenceFunction) {
828828
EXPECT_FALSE(a.Perform(std::make_tuple(&ReferencesGlobalDouble)));
829829
}
830830

831+
TEST(InvokeArgumentTest, MoveOnlyType) {
832+
struct Marker {};
833+
struct {
834+
// Method takes a unique_ptr (to a type we don't care about), and an
835+
// invocable type.
836+
MOCK_METHOD(bool, MockMethod,
837+
(std::unique_ptr<Marker>, std::function<int()>), ());
838+
} mock;
839+
840+
ON_CALL(mock, MockMethod(_, _)).WillByDefault(InvokeArgument<1>());
841+
842+
// This compiles, but is a little opaque as a workaround:
843+
ON_CALL(mock, MockMethod(_, _))
844+
.WillByDefault(WithArg<1>(InvokeArgument<0>()));
845+
}
846+
831847
// Tests DoAll(a1, a2).
832848
TEST(DoAllTest, TwoActions) {
833849
int n = 0;

0 commit comments

Comments
 (0)