63#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
64#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
69#include "gmock/gmock-spec-builders.h"
70#include "gmock/internal/gmock-port.h"
73template <
class MockClass>
75template <
class MockClass>
77template <
class MockClass>
82std::true_type StrictnessModifierProbe(
const NiceMock<T>&);
84std::true_type StrictnessModifierProbe(
const NaggyMock<T>&);
86std::true_type StrictnessModifierProbe(
const StrictMock<T>&);
87std::false_type StrictnessModifierProbe(...);
90constexpr bool HasStrictnessModifier() {
91 return decltype(StrictnessModifierProbe(std::declval<const T&>()))::value;
101#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW && \
102 (defined(_MSC_VER) || defined(__clang__))
105#define GTEST_INTERNAL_EMPTY_BASE_CLASS __declspec(empty_bases)
107#define GTEST_INTERNAL_EMPTY_BASE_CLASS
110template <
typename Base>
114 ::testing::Mock::AllowUninterestingCalls(
reinterpret_cast<uintptr_t
>(
this));
118 ::testing::Mock::UnregisterCallReaction(
reinterpret_cast<uintptr_t
>(
this));
122template <
typename Base>
126 ::testing::Mock::WarnUninterestingCalls(
reinterpret_cast<uintptr_t
>(
this));
130 ::testing::Mock::UnregisterCallReaction(
reinterpret_cast<uintptr_t
>(
this));
134template <
typename Base>
138 ::testing::Mock::FailUninterestingCalls(
reinterpret_cast<uintptr_t
>(
this));
142 ::testing::Mock::UnregisterCallReaction(
reinterpret_cast<uintptr_t
>(
this));
148template <
class MockClass>
153 static_assert(!internal::HasStrictnessModifier<MockClass>(),
154 "Can't apply NiceMock to a class hierarchy that already has a "
155 "strictness modifier. See "
156 "https://google.github.io/googletest/"
157 "gmock_cook_book.html#NiceStrictNaggy");
159 static_assert(
sizeof(*this) ==
sizeof(MockClass),
160 "The impl subclass shouldn't introduce any padding");
170 template <
typename A>
171 explicit NiceMock(A&& arg) : MockClass(std::forward<A>(arg)) {
172 static_assert(
sizeof(*this) ==
sizeof(MockClass),
173 "The impl subclass shouldn't introduce any padding");
176 template <
typename TArg1,
typename TArg2,
typename... An>
177 NiceMock(TArg1&& arg1, TArg2&& arg2, An&&... args)
178 : MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2),
179 std::forward<An>(args)...) {
180 static_assert(
sizeof(*this) ==
sizeof(MockClass),
181 "The impl subclass shouldn't introduce any padding");
189template <
class MockClass>
193 static_assert(!internal::HasStrictnessModifier<MockClass>(),
194 "Can't apply NaggyMock to a class hierarchy that already has a "
195 "strictness modifier. See "
196 "https://google.github.io/googletest/"
197 "gmock_cook_book.html#NiceStrictNaggy");
201 static_assert(
sizeof(*this) ==
sizeof(MockClass),
202 "The impl subclass shouldn't introduce any padding");
212 template <
typename A>
213 explicit NaggyMock(A&& arg) : MockClass(std::forward<A>(arg)) {
214 static_assert(
sizeof(*this) ==
sizeof(MockClass),
215 "The impl subclass shouldn't introduce any padding");
218 template <
typename TArg1,
typename TArg2,
typename... An>
219 NaggyMock(TArg1&& arg1, TArg2&& arg2, An&&... args)
220 : MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2),
221 std::forward<An>(args)...) {
222 static_assert(
sizeof(*this) ==
sizeof(MockClass),
223 "The impl subclass shouldn't introduce any padding");
231template <
class MockClass>
237 !internal::HasStrictnessModifier<MockClass>(),
238 "Can't apply StrictMock to a class hierarchy that already has a "
239 "strictness modifier. See "
240 "https://google.github.io/googletest/"
241 "gmock_cook_book.html#NiceStrictNaggy");
243 static_assert(
sizeof(*this) ==
sizeof(MockClass),
244 "The impl subclass shouldn't introduce any padding");
254 template <
typename A>
255 explicit StrictMock(A&& arg) : MockClass(std::forward<A>(arg)) {
256 static_assert(
sizeof(*this) ==
sizeof(MockClass),
257 "The impl subclass shouldn't introduce any padding");
260 template <
typename TArg1,
typename TArg2,
typename... An>
261 StrictMock(TArg1&& arg1, TArg2&& arg2, An&&... args)
262 : MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2),
263 std::forward<An>(args)...) {
264 static_assert(
sizeof(*this) ==
sizeof(MockClass),
265 "The impl subclass shouldn't introduce any padding");
273#undef GTEST_INTERNAL_EMPTY_BASE_CLASS
Definition gmock-nice-strict.h:192
Definition gmock-nice-strict.h:151
Definition gmock-nice-strict.h:234
Definition gmock-nice-strict.h:123
Definition gmock-nice-strict.h:111
Definition gmock-nice-strict.h:135