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, with up-to 10 arguments. Therefore
55 // you can write NiceMock<MockFoo>(5, "a") to construct a nice mock
56 // where MockFoo has a constructor that accepts (int, const char*),
57 // for example.
58 //
59 // A known limitation is that NiceMock<MockFoo>, NaggyMock<MockFoo>,
60 // and StrictMock<MockFoo> only works for mock methods defined using
61 // the MOCK_METHOD* family of macros DIRECTLY in the MockFoo class.
62 // If a mock method is defined in a base class of MockFoo, the "nice"
63 // or "strict" modifier may not affect it, depending on the compiler.
64 // In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
65 // supported.
66 //
67 // Another known limitation is that the constructors of the base mock
68 // cannot have arguments passed by non-const reference, which are
69 // banned by the Google C++ style guide anyway.
70 
71 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
72 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
73 
76 
77 namespace testing
78 {
79 
80 template <class MockClass>
81 class NiceMock : public MockClass
82 {
83 public:
84  // We don't factor out the constructor body to a common method, as
85  // we have to avoid a possible clash with members of MockClass.
87  {
88  ::testing::Mock::AllowUninterestingCalls(
89  internal::ImplicitCast_<MockClass *>(this));
90  }
91 
92  // C++ doesn't (yet) allow inheritance of constructors, so we have
93  // to define it for each arity.
94  template <typename A1>
95  explicit NiceMock(const A1 & a1) : MockClass(a1)
96  {
97  ::testing::Mock::AllowUninterestingCalls(
98  internal::ImplicitCast_<MockClass *>(this));
99  }
100  template <typename A1, typename A2>
101  NiceMock(const A1 & a1, const A2 & a2) : MockClass(a1, a2)
102  {
103  ::testing::Mock::AllowUninterestingCalls(
104  internal::ImplicitCast_<MockClass *>(this));
105  }
106 
107  template <typename A1, typename A2, typename A3>
108  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3) : MockClass(a1, a2, a3)
109  {
110  ::testing::Mock::AllowUninterestingCalls(
111  internal::ImplicitCast_<MockClass *>(this));
112  }
113 
114  template <typename A1, typename A2, typename A3, typename A4>
115  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3,
116  const A4 & a4) : MockClass(a1, a2, a3, a4)
117  {
118  ::testing::Mock::AllowUninterestingCalls(
119  internal::ImplicitCast_<MockClass *>(this));
120  }
121 
122  template <typename A1, typename A2, typename A3, typename A4, typename A5>
123  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
124  const A5 & a5) : MockClass(a1, a2, a3, a4, a5)
125  {
126  ::testing::Mock::AllowUninterestingCalls(
127  internal::ImplicitCast_<MockClass *>(this));
128  }
129 
130  template <typename A1, typename A2, typename A3, typename A4, typename A5,
131  typename A6>
132  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
133  const A5 & a5, const A6 & a6) : MockClass(a1, a2, a3, a4, a5, a6)
134  {
135  ::testing::Mock::AllowUninterestingCalls(
136  internal::ImplicitCast_<MockClass *>(this));
137  }
138 
139  template <typename A1, typename A2, typename A3, typename A4, typename A5,
140  typename A6, typename A7>
141  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
142  const A5 & a5, const A6 & a6, const A7 & a7) : MockClass(a1, a2, a3, a4, a5,
143  a6, a7)
144  {
145  ::testing::Mock::AllowUninterestingCalls(
146  internal::ImplicitCast_<MockClass *>(this));
147  }
148 
149  template <typename A1, typename A2, typename A3, typename A4, typename A5,
150  typename A6, typename A7, typename A8>
151  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
152  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8) : MockClass(a1,
153  a2, a3, a4, a5, a6, a7, a8)
154  {
155  ::testing::Mock::AllowUninterestingCalls(
156  internal::ImplicitCast_<MockClass *>(this));
157  }
158 
159  template <typename A1, typename A2, typename A3, typename A4, typename A5,
160  typename A6, typename A7, typename A8, typename A9>
161  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
162  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8,
163  const A9 & a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9)
164  {
165  ::testing::Mock::AllowUninterestingCalls(
166  internal::ImplicitCast_<MockClass *>(this));
167  }
168 
169  template <typename A1, typename A2, typename A3, typename A4, typename A5,
170  typename A6, typename A7, typename A8, typename A9, typename A10>
171  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
172  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8, const A9 & a9,
173  const A10 & a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
174  {
175  ::testing::Mock::AllowUninterestingCalls(
176  internal::ImplicitCast_<MockClass *>(this));
177  }
178 
179  virtual ~NiceMock()
180  {
181  ::testing::Mock::UnregisterCallReaction(
182  internal::ImplicitCast_<MockClass *>(this));
183  }
184 
185 private:
187 };
188 
189 template <class MockClass>
190 class NaggyMock : public MockClass
191 {
192 public:
193  // We don't factor out the constructor body to a common method, as
194  // we have to avoid a possible clash with members of MockClass.
196  {
197  ::testing::Mock::WarnUninterestingCalls(
198  internal::ImplicitCast_<MockClass *>(this));
199  }
200 
201  // C++ doesn't (yet) allow inheritance of constructors, so we have
202  // to define it for each arity.
203  template <typename A1>
204  explicit NaggyMock(const A1 & a1) : MockClass(a1)
205  {
206  ::testing::Mock::WarnUninterestingCalls(
207  internal::ImplicitCast_<MockClass *>(this));
208  }
209  template <typename A1, typename A2>
210  NaggyMock(const A1 & a1, const A2 & a2) : MockClass(a1, a2)
211  {
212  ::testing::Mock::WarnUninterestingCalls(
213  internal::ImplicitCast_<MockClass *>(this));
214  }
215 
216  template <typename A1, typename A2, typename A3>
217  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3) : MockClass(a1, a2, a3)
218  {
219  ::testing::Mock::WarnUninterestingCalls(
220  internal::ImplicitCast_<MockClass *>(this));
221  }
222 
223  template <typename A1, typename A2, typename A3, typename A4>
224  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3,
225  const A4 & a4) : MockClass(a1, a2, a3, a4)
226  {
227  ::testing::Mock::WarnUninterestingCalls(
228  internal::ImplicitCast_<MockClass *>(this));
229  }
230 
231  template <typename A1, typename A2, typename A3, typename A4, typename A5>
232  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
233  const A5 & a5) : MockClass(a1, a2, a3, a4, a5)
234  {
235  ::testing::Mock::WarnUninterestingCalls(
236  internal::ImplicitCast_<MockClass *>(this));
237  }
238 
239  template <typename A1, typename A2, typename A3, typename A4, typename A5,
240  typename A6>
241  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
242  const A5 & a5, const A6 & a6) : MockClass(a1, a2, a3, a4, a5, a6)
243  {
244  ::testing::Mock::WarnUninterestingCalls(
245  internal::ImplicitCast_<MockClass *>(this));
246  }
247 
248  template <typename A1, typename A2, typename A3, typename A4, typename A5,
249  typename A6, typename A7>
250  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
251  const A5 & a5, const A6 & a6, const A7 & a7) : MockClass(a1, a2, a3, a4, a5,
252  a6, a7)
253  {
254  ::testing::Mock::WarnUninterestingCalls(
255  internal::ImplicitCast_<MockClass *>(this));
256  }
257 
258  template <typename A1, typename A2, typename A3, typename A4, typename A5,
259  typename A6, typename A7, typename A8>
260  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
261  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8) : MockClass(a1,
262  a2, a3, a4, a5, a6, a7, a8)
263  {
264  ::testing::Mock::WarnUninterestingCalls(
265  internal::ImplicitCast_<MockClass *>(this));
266  }
267 
268  template <typename A1, typename A2, typename A3, typename A4, typename A5,
269  typename A6, typename A7, typename A8, typename A9>
270  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
271  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8,
272  const A9 & a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9)
273  {
274  ::testing::Mock::WarnUninterestingCalls(
275  internal::ImplicitCast_<MockClass *>(this));
276  }
277 
278  template <typename A1, typename A2, typename A3, typename A4, typename A5,
279  typename A6, typename A7, typename A8, typename A9, typename A10>
280  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
281  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8, const A9 & a9,
282  const A10 & a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
283  {
284  ::testing::Mock::WarnUninterestingCalls(
285  internal::ImplicitCast_<MockClass *>(this));
286  }
287 
288  virtual ~NaggyMock()
289  {
290  ::testing::Mock::UnregisterCallReaction(
291  internal::ImplicitCast_<MockClass *>(this));
292  }
293 
294 private:
296 };
297 
298 template <class MockClass>
299 class StrictMock : public MockClass
300 {
301 public:
302  // We don't factor out the constructor body to a common method, as
303  // we have to avoid a possible clash with members of MockClass.
305  {
306  ::testing::Mock::FailUninterestingCalls(
307  internal::ImplicitCast_<MockClass *>(this));
308  }
309 
310  // C++ doesn't (yet) allow inheritance of constructors, so we have
311  // to define it for each arity.
312  template <typename A1>
313  explicit StrictMock(const A1 & a1) : MockClass(a1)
314  {
315  ::testing::Mock::FailUninterestingCalls(
316  internal::ImplicitCast_<MockClass *>(this));
317  }
318  template <typename A1, typename A2>
319  StrictMock(const A1 & a1, const A2 & a2) : MockClass(a1, a2)
320  {
321  ::testing::Mock::FailUninterestingCalls(
322  internal::ImplicitCast_<MockClass *>(this));
323  }
324 
325  template <typename A1, typename A2, typename A3>
326  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3) : MockClass(a1, a2, a3)
327  {
328  ::testing::Mock::FailUninterestingCalls(
329  internal::ImplicitCast_<MockClass *>(this));
330  }
331 
332  template <typename A1, typename A2, typename A3, typename A4>
333  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3,
334  const A4 & a4) : MockClass(a1, a2, a3, a4)
335  {
336  ::testing::Mock::FailUninterestingCalls(
337  internal::ImplicitCast_<MockClass *>(this));
338  }
339 
340  template <typename A1, typename A2, typename A3, typename A4, typename A5>
341  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
342  const A5 & a5) : MockClass(a1, a2, a3, a4, a5)
343  {
344  ::testing::Mock::FailUninterestingCalls(
345  internal::ImplicitCast_<MockClass *>(this));
346  }
347 
348  template <typename A1, typename A2, typename A3, typename A4, typename A5,
349  typename A6>
350  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
351  const A5 & a5, const A6 & a6) : MockClass(a1, a2, a3, a4, a5, a6)
352  {
353  ::testing::Mock::FailUninterestingCalls(
354  internal::ImplicitCast_<MockClass *>(this));
355  }
356 
357  template <typename A1, typename A2, typename A3, typename A4, typename A5,
358  typename A6, typename A7>
359  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
360  const A5 & a5, const A6 & a6, const A7 & a7) : MockClass(a1, a2, a3, a4, a5,
361  a6, a7)
362  {
363  ::testing::Mock::FailUninterestingCalls(
364  internal::ImplicitCast_<MockClass *>(this));
365  }
366 
367  template <typename A1, typename A2, typename A3, typename A4, typename A5,
368  typename A6, typename A7, typename A8>
369  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
370  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8) : MockClass(a1,
371  a2, a3, a4, a5, a6, a7, a8)
372  {
373  ::testing::Mock::FailUninterestingCalls(
374  internal::ImplicitCast_<MockClass *>(this));
375  }
376 
377  template <typename A1, typename A2, typename A3, typename A4, typename A5,
378  typename A6, typename A7, typename A8, typename A9>
379  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
380  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8,
381  const A9 & a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9)
382  {
383  ::testing::Mock::FailUninterestingCalls(
384  internal::ImplicitCast_<MockClass *>(this));
385  }
386 
387  template <typename A1, typename A2, typename A3, typename A4, typename A5,
388  typename A6, typename A7, typename A8, typename A9, typename A10>
389  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
390  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8, const A9 & a9,
391  const A10 & a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
392  {
393  ::testing::Mock::FailUninterestingCalls(
394  internal::ImplicitCast_<MockClass *>(this));
395  }
396 
397  virtual ~StrictMock()
398  {
399  ::testing::Mock::UnregisterCallReaction(
400  internal::ImplicitCast_<MockClass *>(this));
401  }
402 
403 private:
405 };
406 
407 // The following specializations catch some (relatively more common)
408 // user errors of nesting nice and strict mocks. They do NOT catch
409 // all possible errors.
410 
411 // These specializations are declared but not defined, as NiceMock,
412 // NaggyMock, and StrictMock cannot be nested.
413 
414 template <typename MockClass>
415 class NiceMock<NiceMock<MockClass> >;
416 template <typename MockClass>
417 class NiceMock<NaggyMock<MockClass> >;
418 template <typename MockClass>
419 class NiceMock<StrictMock<MockClass> >;
420 
421 template <typename MockClass>
422 class NaggyMock<NiceMock<MockClass> >;
423 template <typename MockClass>
424 class NaggyMock<NaggyMock<MockClass> >;
425 template <typename MockClass>
426 class NaggyMock<StrictMock<MockClass> >;
427 
428 template <typename MockClass>
429 class StrictMock<NiceMock<MockClass> >;
430 template <typename MockClass>
431 class StrictMock<NaggyMock<MockClass> >;
432 template <typename MockClass>
433 class StrictMock<StrictMock<MockClass> >;
434 
435 } // namespace testing
436 
437 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
NaggyMock(const A1 &a1, const A2 &a2)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
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)
NiceMock(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, const A4 &a4)
NiceMock(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)
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3)
StrictMock(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, 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, 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, const A10 &a10)
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, const A9 &a9)
GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3)
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)
NaggyMock(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)
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3)
NiceMock(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, const A9 &a9)
StrictMock(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)
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)
StrictMock(const A1 &a1, const A2 &a2)


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:06:05