diff options
Diffstat (limited to 'googlemock/test/gmock-actions_test.cc')
-rw-r--r-- | googlemock/test/gmock-actions_test.cc | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index f2d3042..da1675c 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -37,14 +37,18 @@ #include <functional> #include <iterator> #include <memory> +#include <sstream> #include <string> +#include <tuple> #include <type_traits> +#include <utility> #include <vector> #include "gmock/gmock.h" #include "gmock/internal/gmock-port.h" #include "gtest/gtest-spi.h" #include "gtest/gtest.h" +#include "gtest/internal/gtest-port.h" // Silence C4100 (unreferenced formal parameter) and C4503 (decorated name // length exceeded) for MSVC. @@ -218,7 +222,8 @@ TEST(TypeTraits, IsInvocableRV) { // In C++17 and above, where it's guaranteed that functions can return // non-moveable objects, everything should work fine for non-moveable rsult // types too. -#if defined(__cplusplus) && __cplusplus >= 201703L +#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \ + GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L { struct NonMoveable { NonMoveable() = default; @@ -444,7 +449,7 @@ TEST(DefaultValueTest, GetWorksForMoveOnlyIfSet) { EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists()); EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Get() == nullptr); DefaultValue<std::unique_ptr<int>>::SetFactory( - [] { return std::unique_ptr<int>(new int(42)); }); + [] { return std::make_unique<int>(42); }); EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists()); std::unique_ptr<int> i = DefaultValue<std::unique_ptr<int>>::Get(); EXPECT_EQ(42, *i); @@ -982,7 +987,7 @@ TEST(ReturnRoundRobinTest, WorksForVector) { class MockClass { public: - MockClass() {} + MockClass() = default; MOCK_METHOD1(IntFunc, int(bool flag)); // NOLINT MOCK_METHOD0(Foo, MyNonDefaultConstructible()); @@ -1592,7 +1597,7 @@ TEST(WithArgsTest, RefQualifiedInnerAction) { EXPECT_EQ(19, mock.AsStdFunction()(0, 17)); } -#if !GTEST_OS_WINDOWS_MOBILE +#ifndef GTEST_OS_WINDOWS_MOBILE class SetErrnoAndReturnTest : public testing::Test { protected: @@ -1751,9 +1756,7 @@ TEST(ReturnNewTest, ConstructorThatTakes10Arguments) { delete c; } -std::unique_ptr<int> UniquePtrSource() { - return std::unique_ptr<int>(new int(19)); -} +std::unique_ptr<int> UniquePtrSource() { return std::make_unique<int>(19); } std::vector<std::unique_ptr<int>> VectorUniquePtrSource() { std::vector<std::unique_ptr<int>> out; @@ -1802,7 +1805,7 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) { // Check default value DefaultValue<std::unique_ptr<int>>::SetFactory( - [] { return std::unique_ptr<int>(new int(42)); }); + [] { return std::make_unique<int>(42); }); EXPECT_EQ(42, *mock.MakeUnique()); EXPECT_CALL(mock, MakeUnique()).WillRepeatedly(Invoke(UniquePtrSource)); @@ -1822,7 +1825,7 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) { TEST(MockMethodTest, CanTakeMoveOnlyValue) { MockClass mock; - auto make = [](int i) { return std::unique_ptr<int>(new int(i)); }; + auto make = [](int i) { return std::make_unique<int>(i); }; EXPECT_CALL(mock, TakeUnique(_)).WillRepeatedly([](std::unique_ptr<int> i) { return *i; @@ -2053,9 +2056,7 @@ struct Double { } }; -std::unique_ptr<int> UniqueInt(int i) { - return std::unique_ptr<int>(new int(i)); -} +std::unique_ptr<int> UniqueInt(int i) { return std::make_unique<int>(i); } TEST(FunctorActionTest, ActionFromFunction) { Action<int(int, int&, int*)> a = &Add; |