From a79851f2c26755324bf0340eed3538d3a047b7a7 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Thu, 12 Apr 2018 14:00:38 -0400 Subject: merging --- .../include/gmock/gmock-generated-nice-strict.h | 15 +++++++ .../gmock/gmock-generated-nice-strict.h.pump | 5 +++ googlemock/test/gmock-nice-strict_test.cc | 50 ++++++++++++++++++++-- 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/googlemock/include/gmock/gmock-generated-nice-strict.h b/googlemock/include/gmock/gmock-generated-nice-strict.h index 5e1386b..8e56873 100644 --- a/googlemock/include/gmock/gmock-generated-nice-strict.h +++ b/googlemock/include/gmock/gmock-generated-nice-strict.h @@ -80,6 +80,11 @@ class NiceMock : public MockClass { } #if GTEST_LANG_CXX11 + // Ideally, we would inherit base class's constructors through a using + // declaration, which would preserve their visibility. However, many existing + // tests rely on the fact that current implementation reexports protected + // constructors as public. These tests would need to be cleaned up first. + // Single argument constructor is special-cased so that it can be // made explicit. template @@ -193,6 +198,11 @@ class NaggyMock : public MockClass { } #if GTEST_LANG_CXX11 + // Ideally, we would inherit base class's constructors through a using + // declaration, which would preserve their visibility. However, many existing + // tests rely on the fact that current implementation reexports protected + // constructors as public. These tests would need to be cleaned up first. + // Single argument constructor is special-cased so that it can be // made explicit. template @@ -306,6 +316,11 @@ class StrictMock : public MockClass { } #if GTEST_LANG_CXX11 + // Ideally, we would inherit base class's constructors through a using + // declaration, which would preserve their visibility. However, many existing + // tests rely on the fact that current implementation reexports protected + // constructors as public. These tests would need to be cleaned up first. + // Single argument constructor is special-cased so that it can be // made explicit. template diff --git a/googlemock/include/gmock/gmock-generated-nice-strict.h.pump b/googlemock/include/gmock/gmock-generated-nice-strict.h.pump index 2e50e98..2f443ae 100644 --- a/googlemock/include/gmock/gmock-generated-nice-strict.h.pump +++ b/googlemock/include/gmock/gmock-generated-nice-strict.h.pump @@ -92,6 +92,11 @@ class $clazz : public MockClass { } #if GTEST_LANG_CXX11 + // Ideally, we would inherit base class's constructors through a using + // declaration, which would preserve their visibility. However, many existing + // tests rely on the fact that current implementation reexports protected + // constructors as public. These tests would need to be cleaned up first. + // Single argument constructor is special-cased so that it can be // made explicit. template diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc index 7812f62..c419494 100644 --- a/googlemock/test/gmock-nice-strict_test.cc +++ b/googlemock/test/gmock-nice-strict_test.cc @@ -32,9 +32,10 @@ #include "gmock/gmock-generated-nice-strict.h" #include +#include #include "gmock/gmock.h" -#include "gtest/gtest.h" #include "gtest/gtest-spi.h" +#include "gtest/gtest.h" // This must not be defined inside the ::testing namespace, or it will // clash with ::testing::Mock. @@ -114,6 +115,24 @@ class MockBar { GTEST_DISALLOW_COPY_AND_ASSIGN_(MockBar); }; +#if GTEST_GTEST_LANG_CXX11 + +class MockBaz { + public: + class MoveOnly { + MoveOnly() = default; + + MoveOnly(const MoveOnly&) = delete; + operator=(const MoveOnly&) = delete; + + MoveOnly(MoveOnly&&) = default; + operator=(MoveOnly&&) = default; + }; + + MockBaz(MoveOnly) {} +} +#endif // GTEST_GTEST_LANG_CXX11 && GTEST_HAS_STD_MOVE_ + #if GTEST_HAS_STREAM_REDIRECTION // Tests that a raw mock generates warnings for uninteresting calls. @@ -214,8 +233,9 @@ TEST(NiceMockTest, AllowsExpectedCall) { nice_foo.DoThis(); } -// Tests that an unexpected call on a nice mock which returns a not-default-constructible -// type throws an exception and the exception contains the method's name. +// Tests that an unexpected call on a nice mock which returns a +// not-default-constructible type throws an exception and the exception contains +// the method's name. TEST(NiceMockTest, ThrowsExceptionForUnknownReturnTypes) { NiceMock nice_foo; #if GTEST_HAS_EXCEPTIONS @@ -266,6 +286,14 @@ TEST(NiceMockTest, AllowLeak) { leaked->DoThis(); } +#if GTEST_GTEST_LANG_CXX11 && GTEST_HAS_STD_MOVE_ + +TEST(NiceMockTest, MoveOnlyConstructor) { + NiceMock nice_baz(MockBaz::MoveOnly()); +} + +#endif // GTEST_LANG_CXX11 && GTEST_HAS_STD_MOVE_ + #if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE // Tests that NiceMock compiles where Mock is a user-defined // class (as opposed to ::testing::Mock). We had to work around an @@ -366,6 +394,14 @@ TEST(NaggyMockTest, AllowLeak) { leaked->DoThis(); } +#if GTEST_GTEST_LANG_CXX11 && GTEST_HAS_STD_MOVE_ + +TEST(NaggyMockTest, MoveOnlyConstructor) { + NaggyMock naggy_baz(MockBaz::MoveOnly()); +} + +#endif // GTEST_LANG_CXX11 && GTEST_HAS_STD_MOVE_ + #if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE // Tests that NaggyMock compiles where Mock is a user-defined // class (as opposed to ::testing::Mock). We had to work around an @@ -447,6 +483,14 @@ TEST(StrictMockTest, AllowLeak) { leaked->DoThis(); } +#if GTEST_GTEST_LANG_CXX11 && GTEST_HAS_STD_MOVE_ + +TEST(StrictMockTest, MoveOnlyConstructor) { + StrictMock strict_baz(MockBaz::MoveOnly()); +} + +#endif // GTEST_LANG_CXX11 && GTEST_HAS_STD_MOVE_ + #if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE // Tests that StrictMock compiles where Mock is a user-defined // class (as opposed to ::testing::Mock). We had to work around an -- cgit v0.12