Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
gmock-generated-nice-strict.h
Go to the documentation of this file.
1// This file was GENERATED by command:
2// pump.py gmock-generated-nice-strict.h.pump
3// DO NOT EDIT BY HAND!!!
4
5// Copyright 2008, Google Inc.
6// All rights reserved.
7//
8// Redistribution and use in source and binary forms, with or without
9// modification, are permitted provided that the following conditions are
10// met:
11//
12// * Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14// * Redistributions in binary form must reproduce the above
15// copyright notice, this list of conditions and the following disclaimer
16// in the documentation and/or other materials provided with the
17// distribution.
18// * Neither the name of Google Inc. nor the names of its
19// contributors may be used to endorse or promote products derived from
20// this software without specific prior written permission.
21//
22// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33//
34// Author: wan@google.com (Zhanyong Wan)
35
36// Implements class templates NiceMock, NaggyMock, and StrictMock.
37//
38// Given a mock class MockFoo that is created using Google Mock,
39// NiceMock<MockFoo> is a subclass of MockFoo that allows
40// uninteresting calls (i.e. calls to mock methods that have no
41// EXPECT_CALL specs), NaggyMock<MockFoo> is a subclass of MockFoo
42// that prints a warning when an uninteresting call occurs, and
43// StrictMock<MockFoo> is a subclass of MockFoo that treats all
44// uninteresting calls as errors.
45//
46// Currently a mock is naggy by default, so MockFoo and
47// NaggyMock<MockFoo> behave like the same. However, we will soon
48// switch the default behavior of mocks to be nice, as that in general
49// leads to more maintainable tests. When that happens, MockFoo will
50// stop behaving like NaggyMock<MockFoo> and start behaving like
51// NiceMock<MockFoo>.
52//
53// NiceMock, NaggyMock, and StrictMock "inherit" the constructors of
54// their respective base class. Therefore you can write
55// NiceMock<MockFoo>(5, "a") to construct a nice mock where MockFoo
56// has a constructor that accepts (int, const char*), for example.
57//
58// A known limitation is that NiceMock<MockFoo>, NaggyMock<MockFoo>,
59// and StrictMock<MockFoo> only works for mock methods defined using
60// the MOCK_METHOD* family of macros DIRECTLY in the MockFoo class.
61// If a mock method is defined in a base class of MockFoo, the "nice"
62// or "strict" modifier may not affect it, depending on the compiler.
63// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
64// supported.
65
66#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
67#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
68
71
72namespace testing {
73
74template <class MockClass>
75class NiceMock : public MockClass {
76 public:
77 NiceMock() : MockClass() {
78 ::testing::Mock::AllowUninterestingCalls(
80 }
81
82#if GTEST_LANG_CXX11
83 // Ideally, we would inherit base class's constructors through a using
84 // declaration, which would preserve their visibility. However, many existing
85 // tests rely on the fact that current implementation reexports protected
86 // constructors as public. These tests would need to be cleaned up first.
87
88 // Single argument constructor is special-cased so that it can be
89 // made explicit.
90 template <typename A>
91 explicit NiceMock(A&& arg) : MockClass(std::forward<A>(arg)) {
92 ::testing::Mock::AllowUninterestingCalls(
94 }
95
96 template <typename A1, typename A2, typename... An>
97 NiceMock(A1&& arg1, A2&& arg2, An&&... args)
98 : MockClass(std::forward<A1>(arg1), std::forward<A2>(arg2),
99 std::forward<An>(args)...) {
100 ::testing::Mock::AllowUninterestingCalls(
102 }
103#else
104 // C++98 doesn't have variadic templates, so we have to define one
105 // for each arity.
106 template <typename A1>
107 explicit NiceMock(const A1& a1) : MockClass(a1) {
108 ::testing::Mock::AllowUninterestingCalls(
110 }
111 template <typename A1, typename A2>
112 NiceMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
113 ::testing::Mock::AllowUninterestingCalls(
115 }
116
117 template <typename A1, typename A2, typename A3>
118 NiceMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
119 ::testing::Mock::AllowUninterestingCalls(
121 }
122
123 template <typename A1, typename A2, typename A3, typename A4>
124 NiceMock(const A1& a1, const A2& a2, const A3& a3,
125 const A4& a4) : MockClass(a1, a2, a3, a4) {
126 ::testing::Mock::AllowUninterestingCalls(
128 }
129
130 template <typename A1, typename A2, typename A3, typename A4, typename A5>
131 NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
132 const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
133 ::testing::Mock::AllowUninterestingCalls(
135 }
136
137 template <typename A1, typename A2, typename A3, typename A4, typename A5,
138 typename A6>
139 NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
140 const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
141 ::testing::Mock::AllowUninterestingCalls(
143 }
144
145 template <typename A1, typename A2, typename A3, typename A4, typename A5,
146 typename A6, typename A7>
147 NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
148 const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
149 a6, a7) {
150 ::testing::Mock::AllowUninterestingCalls(
152 }
153
154 template <typename A1, typename A2, typename A3, typename A4, typename A5,
155 typename A6, typename A7, typename A8>
156 NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
157 const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
158 a2, a3, a4, a5, a6, a7, a8) {
159 ::testing::Mock::AllowUninterestingCalls(
161 }
162
163 template <typename A1, typename A2, typename A3, typename A4, typename A5,
164 typename A6, typename A7, typename A8, typename A9>
165 NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
166 const A5& a5, const A6& a6, const A7& a7, const A8& a8,
167 const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
168 ::testing::Mock::AllowUninterestingCalls(
170 }
171
172 template <typename A1, typename A2, typename A3, typename A4, typename A5,
173 typename A6, typename A7, typename A8, typename A9, typename A10>
174 NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
175 const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
176 const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
177 ::testing::Mock::AllowUninterestingCalls(
179 }
180
181#endif // GTEST_LANG_CXX11
182
184 ::testing::Mock::UnregisterCallReaction(
186 }
187
188 private:
190};
191
192template <class MockClass>
193class NaggyMock : public MockClass {
194 public:
195 NaggyMock() : MockClass() {
196 ::testing::Mock::WarnUninterestingCalls(
198 }
199
200#if GTEST_LANG_CXX11
201 // Ideally, we would inherit base class's constructors through a using
202 // declaration, which would preserve their visibility. However, many existing
203 // tests rely on the fact that current implementation reexports protected
204 // constructors as public. These tests would need to be cleaned up first.
205
206 // Single argument constructor is special-cased so that it can be
207 // made explicit.
208 template <typename A>
209 explicit NaggyMock(A&& arg) : MockClass(std::forward<A>(arg)) {
210 ::testing::Mock::WarnUninterestingCalls(
212 }
213
214 template <typename A1, typename A2, typename... An>
215 NaggyMock(A1&& arg1, A2&& arg2, An&&... args)
216 : MockClass(std::forward<A1>(arg1), std::forward<A2>(arg2),
217 std::forward<An>(args)...) {
218 ::testing::Mock::WarnUninterestingCalls(
220 }
221#else
222 // C++98 doesn't have variadic templates, so we have to define one
223 // for each arity.
224 template <typename A1>
225 explicit NaggyMock(const A1& a1) : MockClass(a1) {
226 ::testing::Mock::WarnUninterestingCalls(
228 }
229 template <typename A1, typename A2>
230 NaggyMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
231 ::testing::Mock::WarnUninterestingCalls(
233 }
234
235 template <typename A1, typename A2, typename A3>
236 NaggyMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
237 ::testing::Mock::WarnUninterestingCalls(
239 }
240
241 template <typename A1, typename A2, typename A3, typename A4>
242 NaggyMock(const A1& a1, const A2& a2, const A3& a3,
243 const A4& a4) : MockClass(a1, a2, a3, a4) {
244 ::testing::Mock::WarnUninterestingCalls(
246 }
247
248 template <typename A1, typename A2, typename A3, typename A4, typename A5>
249 NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
250 const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
251 ::testing::Mock::WarnUninterestingCalls(
253 }
254
255 template <typename A1, typename A2, typename A3, typename A4, typename A5,
256 typename A6>
257 NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
258 const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
259 ::testing::Mock::WarnUninterestingCalls(
261 }
262
263 template <typename A1, typename A2, typename A3, typename A4, typename A5,
264 typename A6, typename A7>
265 NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
266 const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
267 a6, a7) {
268 ::testing::Mock::WarnUninterestingCalls(
270 }
271
272 template <typename A1, typename A2, typename A3, typename A4, typename A5,
273 typename A6, typename A7, typename A8>
274 NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
275 const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
276 a2, a3, a4, a5, a6, a7, a8) {
277 ::testing::Mock::WarnUninterestingCalls(
279 }
280
281 template <typename A1, typename A2, typename A3, typename A4, typename A5,
282 typename A6, typename A7, typename A8, typename A9>
283 NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
284 const A5& a5, const A6& a6, const A7& a7, const A8& a8,
285 const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
286 ::testing::Mock::WarnUninterestingCalls(
288 }
289
290 template <typename A1, typename A2, typename A3, typename A4, typename A5,
291 typename A6, typename A7, typename A8, typename A9, typename A10>
292 NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
293 const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
294 const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
295 ::testing::Mock::WarnUninterestingCalls(
297 }
298
299#endif // GTEST_LANG_CXX11
300
302 ::testing::Mock::UnregisterCallReaction(
304 }
305
306 private:
308};
309
310template <class MockClass>
311class StrictMock : public MockClass {
312 public:
313 StrictMock() : MockClass() {
314 ::testing::Mock::FailUninterestingCalls(
316 }
317
318#if GTEST_LANG_CXX11
319 // Ideally, we would inherit base class's constructors through a using
320 // declaration, which would preserve their visibility. However, many existing
321 // tests rely on the fact that current implementation reexports protected
322 // constructors as public. These tests would need to be cleaned up first.
323
324 // Single argument constructor is special-cased so that it can be
325 // made explicit.
326 template <typename A>
327 explicit StrictMock(A&& arg) : MockClass(std::forward<A>(arg)) {
328 ::testing::Mock::FailUninterestingCalls(
330 }
331
332 template <typename A1, typename A2, typename... An>
333 StrictMock(A1&& arg1, A2&& arg2, An&&... args)
334 : MockClass(std::forward<A1>(arg1), std::forward<A2>(arg2),
335 std::forward<An>(args)...) {
336 ::testing::Mock::FailUninterestingCalls(
338 }
339#else
340 // C++98 doesn't have variadic templates, so we have to define one
341 // for each arity.
342 template <typename A1>
343 explicit StrictMock(const A1& a1) : MockClass(a1) {
344 ::testing::Mock::FailUninterestingCalls(
346 }
347 template <typename A1, typename A2>
348 StrictMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
349 ::testing::Mock::FailUninterestingCalls(
351 }
352
353 template <typename A1, typename A2, typename A3>
354 StrictMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
355 ::testing::Mock::FailUninterestingCalls(
357 }
358
359 template <typename A1, typename A2, typename A3, typename A4>
360 StrictMock(const A1& a1, const A2& a2, const A3& a3,
361 const A4& a4) : MockClass(a1, a2, a3, a4) {
362 ::testing::Mock::FailUninterestingCalls(
364 }
365
366 template <typename A1, typename A2, typename A3, typename A4, typename A5>
367 StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
368 const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
369 ::testing::Mock::FailUninterestingCalls(
371 }
372
373 template <typename A1, typename A2, typename A3, typename A4, typename A5,
374 typename A6>
375 StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
376 const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
377 ::testing::Mock::FailUninterestingCalls(
379 }
380
381 template <typename A1, typename A2, typename A3, typename A4, typename A5,
382 typename A6, typename A7>
383 StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
384 const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
385 a6, a7) {
386 ::testing::Mock::FailUninterestingCalls(
388 }
389
390 template <typename A1, typename A2, typename A3, typename A4, typename A5,
391 typename A6, typename A7, typename A8>
392 StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
393 const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
394 a2, a3, a4, a5, a6, a7, a8) {
395 ::testing::Mock::FailUninterestingCalls(
397 }
398
399 template <typename A1, typename A2, typename A3, typename A4, typename A5,
400 typename A6, typename A7, typename A8, typename A9>
401 StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
402 const A5& a5, const A6& a6, const A7& a7, const A8& a8,
403 const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
404 ::testing::Mock::FailUninterestingCalls(
406 }
407
408 template <typename A1, typename A2, typename A3, typename A4, typename A5,
409 typename A6, typename A7, typename A8, typename A9, typename A10>
410 StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
411 const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
412 const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
413 ::testing::Mock::FailUninterestingCalls(
415 }
416
417#endif // GTEST_LANG_CXX11
418
420 ::testing::Mock::UnregisterCallReaction(
422 }
423
424 private:
426};
427
428// The following specializations catch some (relatively more common)
429// user errors of nesting nice and strict mocks. They do NOT catch
430// all possible errors.
431
432// These specializations are declared but not defined, as NiceMock,
433// NaggyMock, and StrictMock cannot be nested.
434
435template <typename MockClass>
436class NiceMock<NiceMock<MockClass> >;
437template <typename MockClass>
438class NiceMock<NaggyMock<MockClass> >;
439template <typename MockClass>
440class NiceMock<StrictMock<MockClass> >;
441
442template <typename MockClass>
443class NaggyMock<NiceMock<MockClass> >;
444template <typename MockClass>
445class NaggyMock<NaggyMock<MockClass> >;
446template <typename MockClass>
447class NaggyMock<StrictMock<MockClass> >;
448
449template <typename MockClass>
450class StrictMock<NiceMock<MockClass> >;
451template <typename MockClass>
452class StrictMock<NaggyMock<MockClass> >;
453template <typename MockClass>
454class StrictMock<StrictMock<MockClass> >;
455
456} // namespace testing
457
458#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
NaggyMock(const A1 &a1, const A2 &a2)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3)
NiceMock(const A1 &a1, const A2 &a2)
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10)
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9)
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8)
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
StrictMock(const A1 &a1, const A2 &a2)
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9)
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10)
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8)
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3)
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
Definition gtest-port.h:917
Definition name.hpp:106
To ImplicitCast_(To x)