Googletest export

Fix DoAll to work with move-only sink arguments.

This changes types of the first n - 1 actions so that they only get a readonly
view of the arguments. The last action will accept move only objects.

PiperOrigin-RevId: 324600664
This commit is contained in:
Abseil Team
2020-08-03 10:34:37 -04:00
committed by Derek Mauro
parent e6e2d3b761
commit 48ec64092a
3 changed files with 21 additions and 7 deletions

View File

@@ -422,6 +422,15 @@ TEST(DoAllTest, TenActions) {
EXPECT_EQ('g', g);
}
TEST(DoAllTest, MoveOnlyArgs) {
bool ran_first = false;
Action<int(std::unique_ptr<int>)> a =
DoAll(InvokeWithoutArgs([&] { ran_first = true; }),
[](std::unique_ptr<int> p) { return *p; });
EXPECT_EQ(7, a.Perform(std::make_tuple(std::unique_ptr<int>(new int(7)))));
EXPECT_TRUE(ran_first);
}
// The ACTION*() macros trigger warning C4100 (unreferenced formal
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
// the macro definition, as the warnings are generated when the macro