summaryrefslogtreecommitdiffstats
path: root/googlemock/test/gmock-matchers_test.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-09-25 22:40:52 (GMT)
committerGennadiy Civil <misterg@google.com>2019-09-27 20:48:33 (GMT)
commitcb3f7ce1deef5084306c929528a9728afdb17164 (patch)
tree1e25e13562a6eabd76d9ba4abc0d1832927e09c1 /googlemock/test/gmock-matchers_test.cc
parenta783ade7c2448d7feabe9874aecf8c83b67422c0 (diff)
downloadgoogletest-cb3f7ce1deef5084306c929528a9728afdb17164.zip
googletest-cb3f7ce1deef5084306c929528a9728afdb17164.tar.gz
googletest-cb3f7ce1deef5084306c929528a9728afdb17164.tar.bz2
Googletest export
Makes testing::ResultOf() work with non-copyable arguments. PiperOrigin-RevId: 271222632
Diffstat (limited to 'googlemock/test/gmock-matchers_test.cc')
-rw-r--r--googlemock/test/gmock-matchers_test.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc
index 88f144d..0373526 100644
--- a/googlemock/test/gmock-matchers_test.cc
+++ b/googlemock/test/gmock-matchers_test.cc
@@ -4318,6 +4318,16 @@ TEST(ResultOfTest, WorksForLambdas) {
EXPECT_FALSE(matcher.Matches(1));
}
+TEST(ResultOfTest, WorksForNonCopyableArguments) {
+ Matcher<std::unique_ptr<int>> matcher = ResultOf(
+ [](const std::unique_ptr<int>& str_len) {
+ return std::string(static_cast<size_t>(*str_len), 'x');
+ },
+ "xxx");
+ EXPECT_TRUE(matcher.Matches(std::unique_ptr<int>(new int(3))));
+ EXPECT_FALSE(matcher.Matches(std::unique_ptr<int>(new int(1))));
+}
+
const int* ReferencingFunction(const int& n) { return &n; }
struct ReferencingFunctor {