Googletest export
Allow construction of an Action from a callable of zero args Action already allows construction from a callable with the same args as the mocked function, without needing to wrap the callable in Invoke. However, if you don't care about the arguments to the mocked function you need to either accept all of them or wrap your callable in InvokeWithoutArgs. This change makes both of those unnecessary, since it allows you to pass a no-args callable to Action directly. PiperOrigin-RevId: 296117034
This commit is contained in:
@@ -1470,8 +1470,19 @@ TEST(FunctorActionTest, TypeConversion) {
|
||||
EXPECT_EQ(1, s2.Perform(std::make_tuple("hello")));
|
||||
|
||||
// Also between the lambda and the action itself.
|
||||
const Action<bool(std::string)> x = [](Unused) { return 42; };
|
||||
EXPECT_TRUE(x.Perform(std::make_tuple("hello")));
|
||||
const Action<bool(std::string)> x1 = [](Unused) { return 42; };
|
||||
const Action<bool(std::string)> x2 = [] { return 42; };
|
||||
EXPECT_TRUE(x1.Perform(std::make_tuple("hello")));
|
||||
EXPECT_TRUE(x2.Perform(std::make_tuple("hello")));
|
||||
|
||||
// Ensure decay occurs where required.
|
||||
std::function<int()> f = [] { return 7; };
|
||||
Action<int(int)> d = f;
|
||||
f = nullptr;
|
||||
EXPECT_EQ(7, d.Perform(std::make_tuple(1)));
|
||||
|
||||
// Ensure creation of an empty action succeeds.
|
||||
Action<void(int)>(nullptr);
|
||||
}
|
||||
|
||||
TEST(FunctorActionTest, UnusedArguments) {
|
||||
|
||||
Reference in New Issue
Block a user