63#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
64#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
68#include "gmock/gmock-spec-builders.h"
69#include "gmock/internal/gmock-port.h"
72template <
class MockClass>
74template <
class MockClass>
76template <
class MockClass>
81std::true_type StrictnessModifierProbe(
const NiceMock<T>&);
83std::true_type StrictnessModifierProbe(
const NaggyMock<T>&);
85std::true_type StrictnessModifierProbe(
const StrictMock<T>&);
86std::false_type StrictnessModifierProbe(...);
89constexpr bool HasStrictnessModifier() {
90 return decltype(StrictnessModifierProbe(std::declval<const T&>()))::value;
100#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW && \
101 (defined(_MSC_VER) || defined(__clang__))
104#define GTEST_INTERNAL_EMPTY_BASE_CLASS __declspec(empty_bases)
106#define GTEST_INTERNAL_EMPTY_BASE_CLASS
109template <
typename Base>
112 NiceMockImpl() { ::testing::Mock::AllowUninterestingCalls(
this); }
114 ~NiceMockImpl() { ::testing::Mock::UnregisterCallReaction(
this); }
117template <
typename Base>
120 NaggyMockImpl() { ::testing::Mock::WarnUninterestingCalls(
this); }
122 ~NaggyMockImpl() { ::testing::Mock::UnregisterCallReaction(
this); }
125template <
typename Base>
128 StrictMockImpl() { ::testing::Mock::FailUninterestingCalls(
this); }
135template <
class MockClass>
141 !internal::HasStrictnessModifier<MockClass>(),
142 "Can't apply NiceMock to a class hierarchy that already has a "
143 "strictness modifier. See "
144 "https://github.com/google/googletest/blob/master/googlemock/docs/"
145 "cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy");
147 static_assert(
sizeof(*this) ==
sizeof(MockClass),
148 "The impl subclass shouldn't introduce any padding");
158 template <
typename A>
159 explicit NiceMock(A&& arg) : MockClass(std::forward<A>(arg)) {
160 static_assert(
sizeof(*this) ==
sizeof(MockClass),
161 "The impl subclass shouldn't introduce any padding");
164 template <
typename TArg1,
typename TArg2,
typename... An>
165 NiceMock(TArg1&& arg1, TArg2&& arg2, An&&... args)
166 : MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2),
167 std::forward<An>(args)...) {
168 static_assert(
sizeof(*this) ==
sizeof(MockClass),
169 "The impl subclass shouldn't introduce any padding");
173 GTEST_DISALLOW_COPY_AND_ASSIGN_(
NiceMock);
176template <
class MockClass>
181 !internal::HasStrictnessModifier<MockClass>(),
182 "Can't apply NaggyMock to a class hierarchy that already has a "
183 "strictness modifier. See "
184 "https://github.com/google/googletest/blob/master/googlemock/docs/"
185 "cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy");
189 static_assert(
sizeof(*this) ==
sizeof(MockClass),
190 "The impl subclass shouldn't introduce any padding");
200 template <
typename A>
201 explicit NaggyMock(A&& arg) : MockClass(std::forward<A>(arg)) {
202 static_assert(
sizeof(*this) ==
sizeof(MockClass),
203 "The impl subclass shouldn't introduce any padding");
206 template <
typename TArg1,
typename TArg2,
typename... An>
207 NaggyMock(TArg1&& arg1, TArg2&& arg2, An&&... args)
208 : MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2),
209 std::forward<An>(args)...) {
210 static_assert(
sizeof(*this) ==
sizeof(MockClass),
211 "The impl subclass shouldn't introduce any padding");
215 GTEST_DISALLOW_COPY_AND_ASSIGN_(
NaggyMock);
218template <
class MockClass>
224 !internal::HasStrictnessModifier<MockClass>(),
225 "Can't apply StrictMock to a class hierarchy that already has a "
226 "strictness modifier. See "
227 "https://github.com/google/googletest/blob/master/googlemock/docs/"
228 "cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy");
230 static_assert(
sizeof(*this) ==
sizeof(MockClass),
231 "The impl subclass shouldn't introduce any padding");
241 template <
typename A>
242 explicit StrictMock(A&& arg) : MockClass(std::forward<A>(arg)) {
243 static_assert(
sizeof(*this) ==
sizeof(MockClass),
244 "The impl subclass shouldn't introduce any padding");
247 template <
typename TArg1,
typename TArg2,
typename... An>
248 StrictMock(TArg1&& arg1, TArg2&& arg2, An&&... args)
249 : MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2),
250 std::forward<An>(args)...) {
251 static_assert(
sizeof(*this) ==
sizeof(MockClass),
252 "The impl subclass shouldn't introduce any padding");
259#undef GTEST_INTERNAL_EMPTY_BASE_CLASS
Definition gmock-nice-strict.h:179
Definition gmock-nice-strict.h:138
Definition gmock-nice-strict.h:221
Definition gmock-nice-strict.h:118
Definition gmock-nice-strict.h:110
Definition gmock-nice-strict.h:126