"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "googlemock/include/gmock/gmock-nice-strict.h" between
googletest-release-1.11.0.tar.gz and googletest-release-1.12.0.tar.gz

About: GoogleTest is Google's (unit) testing and mocking framework for C++ tests.

gmock-nice-strict.h  (googletest-release-1.11.0):gmock-nice-strict.h  (googletest-release-1.12.0)
skipping to change at line 60 skipping to change at line 60
// has a constructor that accepts (int, const char*), for example. // has a constructor that accepts (int, const char*), for example.
// //
// A known limitation is that NiceMock<MockFoo>, NaggyMock<MockFoo>, // A known limitation is that NiceMock<MockFoo>, NaggyMock<MockFoo>,
// and StrictMock<MockFoo> only works for mock methods defined using // and StrictMock<MockFoo> only works for mock methods defined using
// the MOCK_METHOD* family of macros DIRECTLY in the MockFoo class. // the MOCK_METHOD* family of macros DIRECTLY in the MockFoo class.
// If a mock method is defined in a base class of MockFoo, the "nice" // If a mock method is defined in a base class of MockFoo, the "nice"
// or "strict" modifier may not affect it, depending on the compiler. // or "strict" modifier may not affect it, depending on the compiler.
// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT // In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
// supported. // supported.
// GOOGLETEST_CM0002 DO NOT DELETE // IWYU pragma: private, include "gmock/gmock.h"
// IWYU pragma: friend gmock/.*
#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_ #ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_ #define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
#include <cstdint>
#include <type_traits> #include <type_traits>
#include "gmock/gmock-spec-builders.h" #include "gmock/gmock-spec-builders.h"
#include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-port.h"
namespace testing { namespace testing {
template <class MockClass> template <class MockClass>
class NiceMock; class NiceMock;
template <class MockClass> template <class MockClass>
class NaggyMock; class NaggyMock;
skipping to change at line 111 skipping to change at line 113
// We need to mark these classes with this declspec to ensure that // We need to mark these classes with this declspec to ensure that
// the empty base class optimization is performed. // the empty base class optimization is performed.
#define GTEST_INTERNAL_EMPTY_BASE_CLASS __declspec(empty_bases) #define GTEST_INTERNAL_EMPTY_BASE_CLASS __declspec(empty_bases)
#else #else
#define GTEST_INTERNAL_EMPTY_BASE_CLASS #define GTEST_INTERNAL_EMPTY_BASE_CLASS
#endif #endif
template <typename Base> template <typename Base>
class NiceMockImpl { class NiceMockImpl {
public: public:
NiceMockImpl() { ::testing::Mock::AllowUninterestingCalls(this); } NiceMockImpl() {
::testing::Mock::AllowUninterestingCalls(reinterpret_cast<uintptr_t>(this));
}
~NiceMockImpl() { ::testing::Mock::UnregisterCallReaction(this); } ~NiceMockImpl() {
::testing::Mock::UnregisterCallReaction(reinterpret_cast<uintptr_t>(this));
}
}; };
template <typename Base> template <typename Base>
class NaggyMockImpl { class NaggyMockImpl {
public: public:
NaggyMockImpl() { ::testing::Mock::WarnUninterestingCalls(this); } NaggyMockImpl() {
::testing::Mock::WarnUninterestingCalls(reinterpret_cast<uintptr_t>(this));
}
~NaggyMockImpl() { ::testing::Mock::UnregisterCallReaction(this); } ~NaggyMockImpl() {
::testing::Mock::UnregisterCallReaction(reinterpret_cast<uintptr_t>(this));
}
}; };
template <typename Base> template <typename Base>
class StrictMockImpl { class StrictMockImpl {
public: public:
StrictMockImpl() { ::testing::Mock::FailUninterestingCalls(this); } StrictMockImpl() {
::testing::Mock::FailUninterestingCalls(reinterpret_cast<uintptr_t>(this));
}
~StrictMockImpl() { ::testing::Mock::UnregisterCallReaction(this); } ~StrictMockImpl() {
::testing::Mock::UnregisterCallReaction(reinterpret_cast<uintptr_t>(this));
}
}; };
} // namespace internal } // namespace internal
template <class MockClass> template <class MockClass>
class GTEST_INTERNAL_EMPTY_BASE_CLASS NiceMock class GTEST_INTERNAL_EMPTY_BASE_CLASS NiceMock
: private internal::NiceMockImpl<MockClass>, : private internal::NiceMockImpl<MockClass>,
public MockClass { public MockClass {
public: public:
static_assert(!internal::HasStrictnessModifier<MockClass>(), static_assert(!internal::HasStrictnessModifier<MockClass>(),
skipping to change at line 171 skipping to change at line 185
template <typename TArg1, typename TArg2, typename... An> template <typename TArg1, typename TArg2, typename... An>
NiceMock(TArg1&& arg1, TArg2&& arg2, An&&... args) NiceMock(TArg1&& arg1, TArg2&& arg2, An&&... args)
: MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2), : MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2),
std::forward<An>(args)...) { std::forward<An>(args)...) {
static_assert(sizeof(*this) == sizeof(MockClass), static_assert(sizeof(*this) == sizeof(MockClass),
"The impl subclass shouldn't introduce any padding"); "The impl subclass shouldn't introduce any padding");
} }
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock); NiceMock(const NiceMock&) = delete;
NiceMock& operator=(const NiceMock&) = delete;
}; };
template <class MockClass> template <class MockClass>
class GTEST_INTERNAL_EMPTY_BASE_CLASS NaggyMock class GTEST_INTERNAL_EMPTY_BASE_CLASS NaggyMock
: private internal::NaggyMockImpl<MockClass>, : private internal::NaggyMockImpl<MockClass>,
public MockClass { public MockClass {
static_assert(!internal::HasStrictnessModifier<MockClass>(), static_assert(!internal::HasStrictnessModifier<MockClass>(),
"Can't apply NaggyMock to a class hierarchy that already has a " "Can't apply NaggyMock to a class hierarchy that already has a "
"strictness modifier. See " "strictness modifier. See "
"https://google.github.io/googletest/" "https://google.github.io/googletest/"
skipping to change at line 212 skipping to change at line 227
template <typename TArg1, typename TArg2, typename... An> template <typename TArg1, typename TArg2, typename... An>
NaggyMock(TArg1&& arg1, TArg2&& arg2, An&&... args) NaggyMock(TArg1&& arg1, TArg2&& arg2, An&&... args)
: MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2), : MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2),
std::forward<An>(args)...) { std::forward<An>(args)...) {
static_assert(sizeof(*this) == sizeof(MockClass), static_assert(sizeof(*this) == sizeof(MockClass),
"The impl subclass shouldn't introduce any padding"); "The impl subclass shouldn't introduce any padding");
} }
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(NaggyMock); NaggyMock(const NaggyMock&) = delete;
NaggyMock& operator=(const NaggyMock&) = delete;
}; };
template <class MockClass> template <class MockClass>
class GTEST_INTERNAL_EMPTY_BASE_CLASS StrictMock class GTEST_INTERNAL_EMPTY_BASE_CLASS StrictMock
: private internal::StrictMockImpl<MockClass>, : private internal::StrictMockImpl<MockClass>,
public MockClass { public MockClass {
public: public:
static_assert( static_assert(
!internal::HasStrictnessModifier<MockClass>(), !internal::HasStrictnessModifier<MockClass>(),
"Can't apply StrictMock to a class hierarchy that already has a " "Can't apply StrictMock to a class hierarchy that already has a "
skipping to change at line 253 skipping to change at line 269
template <typename TArg1, typename TArg2, typename... An> template <typename TArg1, typename TArg2, typename... An>
StrictMock(TArg1&& arg1, TArg2&& arg2, An&&... args) StrictMock(TArg1&& arg1, TArg2&& arg2, An&&... args)
: MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2), : MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2),
std::forward<An>(args)...) { std::forward<An>(args)...) {
static_assert(sizeof(*this) == sizeof(MockClass), static_assert(sizeof(*this) == sizeof(MockClass),
"The impl subclass shouldn't introduce any padding"); "The impl subclass shouldn't introduce any padding");
} }
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock); StrictMock(const StrictMock&) = delete;
StrictMock& operator=(const StrictMock&) = delete;
}; };
#undef GTEST_INTERNAL_EMPTY_BASE_CLASS #undef GTEST_INTERNAL_EMPTY_BASE_CLASS
} // namespace testing } // namespace testing
#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_ #endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
 End of changes. 11 change blocks. 
10 lines changed or deleted 27 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)