summaryrefslogtreecommitdiffstats
path: root/googlemock/test
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2020-02-20 04:05:01 (GMT)
committerCJ Johnson <johnsoncj@google.com>2020-02-28 21:40:53 (GMT)
commitfd538161f484c202e68512ca37aaa73f2e06f606 (patch)
treed3b2bbc727b7808154f3893ee102aaa98a33e68a /googlemock/test
parent23b2a3b1cf803999fb38175f6e9e038a4495c8a5 (diff)
downloadgoogletest-fd538161f484c202e68512ca37aaa73f2e06f606.zip
googletest-fd538161f484c202e68512ca37aaa73f2e06f606.tar.gz
googletest-fd538161f484c202e68512ca37aaa73f2e06f606.tar.bz2
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
Diffstat (limited to 'googlemock/test')
-rw-r--r--googlemock/test/gmock-actions_test.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc
index 58a2d35..d1229ac 100644
--- a/googlemock/test/gmock-actions_test.cc
+++ b/googlemock/test/gmock-actions_test.cc
@@ -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) {