Index: ext/googletest/googlemock/include/gmock/gmock-generated-nice-strict.h.pump =================================================================== diff -u -N -r4a481bbe77043e0bda2435c6d62a02700b3e46c5 -r2e4eacb299f21d06196fe13140b4b0d095abdca9 --- ext/googletest/googlemock/include/gmock/gmock-generated-nice-strict.h.pump (.../gmock-generated-nice-strict.h.pump) (revision 4a481bbe77043e0bda2435c6d62a02700b3e46c5) +++ ext/googletest/googlemock/include/gmock/gmock-generated-nice-strict.h.pump (.../gmock-generated-nice-strict.h.pump) (revision 2e4eacb299f21d06196fe13140b4b0d095abdca9) @@ -1,6 +1,6 @@ $$ -*- mode: c++; -*- -$$ This is a Pump source file. Please use Pump to convert it to -$$ gmock-generated-nice-strict.h. +$$ This is a Pump source file. Please use Pump to convert +$$ it to gmock-generated-nice-strict.h. $$ $var n = 10 $$ The maximum arity we support. // Copyright 2008, Google Inc. @@ -31,9 +31,8 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) + // Implements class templates NiceMock, NaggyMock, and StrictMock. // // Given a mock class MockFoo that is created using Google Mock, @@ -52,10 +51,9 @@ // NiceMock. // // NiceMock, NaggyMock, and StrictMock "inherit" the constructors of -// their respective base class, with up-to $n arguments. Therefore -// you can write NiceMock(5, "a") to construct a nice mock -// where MockFoo has a constructor that accepts (int, const char*), -// for example. +// their respective base class. Therefore you can write +// NiceMock(5, "a") to construct a nice mock where MockFoo +// has a constructor that accepts (int, const char*), for example. // // A known limitation is that NiceMock, NaggyMock, // and StrictMock only works for mock methods defined using @@ -64,11 +62,9 @@ // or "strict" modifier may not affect it, depending on the compiler. // In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT // supported. -// -// Another known limitation is that the constructors of the base mock -// cannot have arguments passed by non-const reference, which are -// banned by the Google C++ style guide anyway. +// GOOGLETEST_CM0002 DO NOT DELETE + #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_ @@ -91,15 +87,35 @@ template class $clazz : public MockClass { public: - // We don't factor out the constructor body to a common method, as - // we have to avoid a possible clash with members of MockClass. - $clazz() { + $clazz() : MockClass() { ::testing::Mock::$method( internal::ImplicitCast_(this)); } - // C++ doesn't (yet) allow inheritance of constructors, so we have - // to define it for each arity. +#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 + explicit $clazz(A&& arg) : MockClass(std::forward(arg)) { + ::testing::Mock::$method( + internal::ImplicitCast_(this)); + } + + template + $clazz(A1&& arg1, A2&& arg2, An&&... args) + : MockClass(std::forward(arg1), std::forward(arg2), + std::forward(args)...) { + ::testing::Mock::$method( + internal::ImplicitCast_(this)); + } +#else + // C++98 doesn't have variadic templates, so we have to define one + // for each arity. template explicit $clazz(const A1& a1) : MockClass(a1) { ::testing::Mock::$method( @@ -117,7 +133,9 @@ ]] - virtual ~$clazz() { +#endif // GTEST_LANG_CXX11 + + ~$clazz() { ::testing::Mock::UnregisterCallReaction( internal::ImplicitCast_(this)); }