From 53d49dc43ea3f34a61f4a017d33ac5a0b650a68d Mon Sep 17 00:00:00 2001 From: kosak Date: Thu, 8 Jan 2015 03:03:09 +0000 Subject: Make ReturnNull() support unique_ptr and shared_ptr. --- test/gmock-actions_test.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/gmock-actions_test.cc') diff --git a/test/gmock-actions_test.cc b/test/gmock-actions_test.cc index 8089a81d..a0551941 100644 --- a/test/gmock-actions_test.cc +++ b/test/gmock-actions_test.cc @@ -604,6 +604,18 @@ TEST(ReturnNullTest, WorksInPointerReturningFunction) { EXPECT_TRUE(a2.Perform(make_tuple(true)) == NULL); } +#if GTEST_HAS_STD_UNIQUE_PTR_ +// Tests that ReturnNull() returns NULL for shared_ptr and unique_ptr returning +// functions. +TEST(ReturnNullTest, WorksInSmartPointerReturningFunction) { + const Action()> a1 = ReturnNull(); + EXPECT_TRUE(a1.Perform(make_tuple()) == nullptr); + + const Action(std::string)> a2 = ReturnNull(); + EXPECT_TRUE(a2.Perform(make_tuple("foo")) == nullptr); +} +#endif // GTEST_HAS_STD_UNIQUE_PTR_ + // Tests that ReturnRef(v) works for reference types. TEST(ReturnRefTest, WorksForReference) { const int n = 0; -- cgit v1.2.3