fused-src/gmock/gmock.h
Go to the documentation of this file.
1 // Copyright 2007, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // Author: wan@google.com (Zhanyong Wan)
31 
32 // Google Mock - a framework for writing C++ mock classes.
33 //
34 // This is the main header file a user should include.
35 
36 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_H_
37 #define GMOCK_INCLUDE_GMOCK_GMOCK_H_
38 
39 // This file implements the following syntax:
40 //
41 // ON_CALL(mock_object.Method(...))
42 // .With(...) ?
43 // .WillByDefault(...);
44 //
45 // where With() is optional and WillByDefault() must appear exactly
46 // once.
47 //
48 // EXPECT_CALL(mock_object.Method(...))
49 // .With(...) ?
50 // .Times(...) ?
51 // .InSequence(...) *
52 // .WillOnce(...) *
53 // .WillRepeatedly(...) ?
54 // .RetiresOnSaturation() ? ;
55 //
56 // where all clauses are optional and WillOnce() can be repeated.
57 
58 // Copyright 2007, Google Inc.
59 // All rights reserved.
60 //
61 // Redistribution and use in source and binary forms, with or without
62 // modification, are permitted provided that the following conditions are
63 // met:
64 //
65 // * Redistributions of source code must retain the above copyright
66 // notice, this list of conditions and the following disclaimer.
67 // * Redistributions in binary form must reproduce the above
68 // copyright notice, this list of conditions and the following disclaimer
69 // in the documentation and/or other materials provided with the
70 // distribution.
71 // * Neither the name of Google Inc. nor the names of its
72 // contributors may be used to endorse or promote products derived from
73 // this software without specific prior written permission.
74 //
75 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
76 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
77 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
78 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
79 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
80 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
81 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
82 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
83 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
85 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86 //
87 // Author: wan@google.com (Zhanyong Wan)
88 
89 // Google Mock - a framework for writing C++ mock classes.
90 //
91 // This file implements some commonly used actions.
92 
93 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
94 #define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
95 
96 #ifndef _WIN32_WCE
97 # include <errno.h>
98 #endif
99 
100 #include <algorithm>
101 #include <string>
102 
103 // Copyright 2007, Google Inc.
104 // All rights reserved.
105 //
106 // Redistribution and use in source and binary forms, with or without
107 // modification, are permitted provided that the following conditions are
108 // met:
109 //
110 // * Redistributions of source code must retain the above copyright
111 // notice, this list of conditions and the following disclaimer.
112 // * Redistributions in binary form must reproduce the above
113 // copyright notice, this list of conditions and the following disclaimer
114 // in the documentation and/or other materials provided with the
115 // distribution.
116 // * Neither the name of Google Inc. nor the names of its
117 // contributors may be used to endorse or promote products derived from
118 // this software without specific prior written permission.
119 //
120 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
121 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
122 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
123 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
124 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
125 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
126 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
127 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
128 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
129 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
130 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
131 //
132 // Author: wan@google.com (Zhanyong Wan)
133 
134 // Google Mock - a framework for writing C++ mock classes.
135 //
136 // This file defines some utilities useful for implementing Google
137 // Mock. They are subject to change without notice, so please DO NOT
138 // USE THEM IN USER CODE.
139 
140 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
141 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
142 
143 #include <stdio.h>
144 #include <ostream> // NOLINT
145 #include <string>
146 
147 // This file was GENERATED by command:
148 // pump.py gmock-generated-internal-utils.h.pump
149 // DO NOT EDIT BY HAND!!!
150 
151 // Copyright 2007, Google Inc.
152 // All rights reserved.
153 //
154 // Redistribution and use in source and binary forms, with or without
155 // modification, are permitted provided that the following conditions are
156 // met:
157 //
158 // * Redistributions of source code must retain the above copyright
159 // notice, this list of conditions and the following disclaimer.
160 // * Redistributions in binary form must reproduce the above
161 // copyright notice, this list of conditions and the following disclaimer
162 // in the documentation and/or other materials provided with the
163 // distribution.
164 // * Neither the name of Google Inc. nor the names of its
165 // contributors may be used to endorse or promote products derived from
166 // this software without specific prior written permission.
167 //
168 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
169 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
170 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
171 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
172 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
173 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
174 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
175 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
176 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
177 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
178 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
179 //
180 // Author: wan@google.com (Zhanyong Wan)
181 
182 // Google Mock - a framework for writing C++ mock classes.
183 //
184 // This file contains template meta-programming utility classes needed
185 // for implementing Google Mock.
186 
187 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
188 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
189 
190 // Copyright 2008, Google Inc.
191 // All rights reserved.
192 //
193 // Redistribution and use in source and binary forms, with or without
194 // modification, are permitted provided that the following conditions are
195 // met:
196 //
197 // * Redistributions of source code must retain the above copyright
198 // notice, this list of conditions and the following disclaimer.
199 // * Redistributions in binary form must reproduce the above
200 // copyright notice, this list of conditions and the following disclaimer
201 // in the documentation and/or other materials provided with the
202 // distribution.
203 // * Neither the name of Google Inc. nor the names of its
204 // contributors may be used to endorse or promote products derived from
205 // this software without specific prior written permission.
206 //
207 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
208 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
209 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
210 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
211 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
213 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
214 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
215 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
216 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
217 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
218 //
219 // Author: vadimb@google.com (Vadim Berman)
220 //
221 // Low-level types and utilities for porting Google Mock to various
222 // platforms. They are subject to change without notice. DO NOT USE
223 // THEM IN USER CODE.
224 
225 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
226 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
227 
228 #include <assert.h>
229 #include <stdlib.h>
230 #include <iostream>
231 
232 // Most of the types needed for porting Google Mock are also required
233 // for Google Test and are defined in gtest-port.h.
234 #include "gtest/gtest.h"
235 
236 // To avoid conditional compilation everywhere, we make it
237 // gmock-port.h's responsibility to #include the header implementing
238 // tr1/tuple. gmock-port.h does this via gtest-port.h, which is
239 // guaranteed to pull in the tuple header.
240 
241 // For MS Visual C++, check the compiler version. At least VS 2003 is
242 // required to compile Google Mock.
243 #if defined(_MSC_VER) && _MSC_VER < 1310
244 # error "At least Visual C++ 2003 (7.1) is required to compile Google Mock."
245 #endif
246 
247 // Macro for referencing flags. This is public as we want the user to
248 // use this syntax to reference Google Mock flags.
249 #define GMOCK_FLAG(name) FLAGS_gmock_##name
250 
251 // Macros for declaring flags.
252 #define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name)
253 #define GMOCK_DECLARE_int32_(name) \
254  extern GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name)
255 #define GMOCK_DECLARE_string_(name) \
256  extern GTEST_API_ ::std::string GMOCK_FLAG(name)
257 
258 // Macros for defining flags.
259 #define GMOCK_DEFINE_bool_(name, default_val, doc) \
260  GTEST_API_ bool GMOCK_FLAG(name) = (default_val)
261 #define GMOCK_DEFINE_int32_(name, default_val, doc) \
262  GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)
263 #define GMOCK_DEFINE_string_(name, default_val, doc) \
264  GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)
265 
266 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
267 
268 namespace testing
269 {
270 
271 template <typename T>
272 class Matcher;
273 
274 namespace internal
275 {
276 
277 // An IgnoredValue object can be implicitly constructed from ANY value.
278 // This is used in implementing the IgnoreResult(a) action.
280 {
281 public:
282  // This constructor template allows any value to be implicitly
283  // converted to IgnoredValue. The object has no data member and
284  // doesn't try to remember anything about the argument. We
285  // deliberately omit the 'explicit' keyword in order to allow the
286  // conversion to be implicit.
287  template <typename T>
288  IgnoredValue(const T & /* ignored */) {} // NOLINT(runtime/explicit)
289 };
290 
291 // MatcherTuple<T>::type is a tuple type where each field is a Matcher
292 // for the corresponding field in tuple type T.
293 template <typename Tuple>
295 
296 template <>
298 {
299  typedef ::std::tr1::tuple< > type;
300 };
301 
302 template <typename A1>
304 {
305  typedef ::std::tr1::tuple<Matcher<A1> > type;
306 };
307 
308 template <typename A1, typename A2>
309 struct MatcherTuple< ::std::tr1::tuple<A1, A2> >
310 {
311  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2> > type;
312 };
313 
314 template <typename A1, typename A2, typename A3>
315 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3> >
316 {
317  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
318 };
319 
320 template <typename A1, typename A2, typename A3, typename A4>
321 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4> >
322 {
323  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>,
325 };
326 
327 template <typename A1, typename A2, typename A3, typename A4, typename A5>
328 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5> >
329 {
330  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
332 };
333 
334 template <typename A1, typename A2, typename A3, typename A4, typename A5,
335  typename A6>
336 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> >
337 {
338  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
340 };
341 
342 template <typename A1, typename A2, typename A3, typename A4, typename A5,
343  typename A6, typename A7>
344 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> >
345 {
346  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
348 };
349 
350 template <typename A1, typename A2, typename A3, typename A4, typename A5,
351  typename A6, typename A7, typename A8>
352 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> >
353 {
354  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
356 };
357 
358 template <typename A1, typename A2, typename A3, typename A4, typename A5,
359  typename A6, typename A7, typename A8, typename A9>
360 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> >
361 {
362  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
364 };
365 
366 template <typename A1, typename A2, typename A3, typename A4, typename A5,
367  typename A6, typename A7, typename A8, typename A9, typename A10>
368 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
369  A10> >
370 {
371  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
374 };
375 
376 // Template struct Function<F>, where F must be a function type, contains
377 // the following typedefs:
378 //
379 // Result: the function's return type.
380 // ArgumentN: the type of the N-th argument, where N starts with 1.
381 // ArgumentTuple: the tuple type consisting of all parameters of F.
382 // ArgumentMatcherTuple: the tuple type consisting of Matchers for all
383 // parameters of F.
384 // MakeResultVoid: the function type obtained by substituting void
385 // for the return type of F.
386 // MakeResultIgnoredValue:
387 // the function type obtained by substituting Something
388 // for the return type of F.
389 template <typename F>
390 struct Function;
391 
392 template <typename R>
393 struct Function<R()>
394 {
395  typedef R Result;
396  typedef ::std::tr1::tuple<> ArgumentTuple;
398  typedef void MakeResultVoid();
400 };
401 
402 template <typename R, typename A1>
403 struct Function<R(A1)>
404 : Function<R()>
405 {
406  typedef A1 Argument1;
407  typedef ::std::tr1::tuple<A1> ArgumentTuple;
409  typedef void MakeResultVoid(A1);
411 };
412 
413 template <typename R, typename A1, typename A2>
414 struct Function<R(A1, A2)>
415 : Function<R(A1)>
416 {
417  typedef A2 Argument2;
418  typedef ::std::tr1::tuple<A1, A2> ArgumentTuple;
420  typedef void MakeResultVoid(A1, A2);
422 };
423 
424 template <typename R, typename A1, typename A2, typename A3>
425 struct Function<R(A1, A2, A3)>
426 : Function<R(A1, A2)>
427 {
428  typedef A3 Argument3;
429  typedef ::std::tr1::tuple<A1, A2, A3> ArgumentTuple;
431  typedef void MakeResultVoid(A1, A2, A3);
433 };
434 
435 template <typename R, typename A1, typename A2, typename A3, typename A4>
436 struct Function<R(A1, A2, A3, A4)>
437 : Function<R(A1, A2, A3)>
438 {
439  typedef A4 Argument4;
440  typedef ::std::tr1::tuple<A1, A2, A3, A4> ArgumentTuple;
442  typedef void MakeResultVoid(A1, A2, A3, A4);
443  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4);
444 };
445 
446 template <typename R, typename A1, typename A2, typename A3, typename A4,
447  typename A5>
448 struct Function<R(A1, A2, A3, A4, A5)>
449 : Function<R(A1, A2, A3, A4)>
450 {
451  typedef A5 Argument5;
452  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
454  typedef void MakeResultVoid(A1, A2, A3, A4, A5);
455  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5);
456 };
457 
458 template <typename R, typename A1, typename A2, typename A3, typename A4,
459  typename A5, typename A6>
460 struct Function<R(A1, A2, A3, A4, A5, A6)>
461 : Function<R(A1, A2, A3, A4, A5)>
462 {
463  typedef A6 Argument6;
464  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
466  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6);
467  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6);
468 };
469 
470 template <typename R, typename A1, typename A2, typename A3, typename A4,
471  typename A5, typename A6, typename A7>
472 struct Function<R(A1, A2, A3, A4, A5, A6, A7)>
473 : Function<R(A1, A2, A3, A4, A5, A6)>
474 {
475  typedef A7 Argument7;
476  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> ArgumentTuple;
478  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7);
479  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7);
480 };
481 
482 template <typename R, typename A1, typename A2, typename A3, typename A4,
483  typename A5, typename A6, typename A7, typename A8>
484 struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>
485 : Function<R(A1, A2, A3, A4, A5, A6, A7)>
486 {
487  typedef A8 Argument8;
488  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> ArgumentTuple;
490  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8);
491  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8);
492 };
493 
494 template <typename R, typename A1, typename A2, typename A3, typename A4,
495  typename A5, typename A6, typename A7, typename A8, typename A9>
496 struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
497 : Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>
498 {
499  typedef A9 Argument9;
500  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> ArgumentTuple;
502  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9);
503  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
504  A9);
505 };
506 
507 template <typename R, typename A1, typename A2, typename A3, typename A4,
508  typename A5, typename A6, typename A7, typename A8, typename A9,
509  typename A10>
510 struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
511 : Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
512 {
513  typedef A10 Argument10;
514  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
517  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
518  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
519  A9, A10);
520 };
521 
522 } // namespace internal
523 
524 } // namespace testing
525 
526 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
527 
528 namespace testing
529 {
530 namespace internal
531 {
532 
533 // Converts an identifier name to a space-separated list of lower-case
534 // words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
535 // treated as one word. For example, both "FooBar123" and
536 // "foo_bar_123" are converted to "foo bar 123".
537 GTEST_API_ string ConvertIdentifierNameToWords(const char * id_name);
538 
539 // PointeeOf<Pointer>::type is the type of a value pointed to by a
540 // Pointer, which can be either a smart pointer or a raw pointer. The
541 // following default implementation is for the case where Pointer is a
542 // smart pointer.
543 template <typename Pointer>
544 struct PointeeOf
545 {
546  // Smart pointer classes define type element_type as the type of
547  // their pointees.
548  typedef typename Pointer::element_type type;
549 };
550 // This specialization is for the raw pointer case.
551 template <typename T>
552 struct PointeeOf<T *> { typedef T type; }; // NOLINT
553 
554 // GetRawPointer(p) returns the raw pointer underlying p when p is a
555 // smart pointer, or returns p itself when p is already a raw pointer.
556 // The following default implementation is for the smart pointer case.
557 template <typename Pointer>
558 inline const typename Pointer::element_type * GetRawPointer(const Pointer & p)
559 {
560  return p.get();
561 }
562 // This overloaded version is for the raw pointer case.
563 template <typename Element>
564 inline Element * GetRawPointer(Element * p) { return p; }
565 
566 // This comparator allows linked_ptr to be stored in sets.
567 template <typename T>
569 {
570  bool operator()(const ::testing::internal::linked_ptr<T> & lhs,
571  const ::testing::internal::linked_ptr<T> & rhs) const
572  {
573  return lhs.get() < rhs.get();
574  }
575 };
576 
577 // Symbian compilation can be done with wchar_t being either a native
578 // type or a typedef. Using Google Mock with OpenC without wchar_t
579 // should require the definition of _STLP_NO_WCHAR_T.
580 //
581 // MSVC treats wchar_t as a native type usually, but treats it as the
582 // same as unsigned short when the compiler option /Zc:wchar_t- is
583 // specified. It defines _NATIVE_WCHAR_T_DEFINED symbol when wchar_t
584 // is a native type.
585 #if (GTEST_OS_SYMBIAN && defined(_STLP_NO_WCHAR_T)) || \
586  (defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED))
587 // wchar_t is a typedef.
588 #else
589 # define GMOCK_WCHAR_T_IS_NATIVE_ 1
590 #endif
591 
592 // signed wchar_t and unsigned wchar_t are NOT in the C++ standard.
593 // Using them is a bad practice and not portable. So DON'T use them.
594 //
595 // Still, Google Mock is designed to work even if the user uses signed
596 // wchar_t or unsigned wchar_t (obviously, assuming the compiler
597 // supports them).
598 //
599 // To gcc,
600 // wchar_t == signed wchar_t != unsigned wchar_t == unsigned int
601 #ifdef __GNUC__
602 // signed/unsigned wchar_t are valid types.
603 # define GMOCK_HAS_SIGNED_WCHAR_T_ 1
604 #endif
605 
606 // In what follows, we use the term "kind" to indicate whether a type
607 // is bool, an integer type (excluding bool), a floating-point type,
608 // or none of them. This categorization is useful for determining
609 // when a matcher argument type can be safely converted to another
610 // type in the implementation of SafeMatcherCast.
612 {
614 };
615 
616 // KindOf<T>::value is the kind of type T.
617 template <typename T> struct KindOf
618 {
619  enum { value = kOther }; // The default kind.
620 };
621 
622 // This macro declares that the kind of 'type' is 'kind'.
623 #define GMOCK_DECLARE_KIND_(type, kind) \
624  template <> struct KindOf<type> { enum { value = kind }; }
625 
627 
628 // All standard integer types.
630 GMOCK_DECLARE_KIND_(signed char, kInteger);
631 GMOCK_DECLARE_KIND_(unsigned char, kInteger);
632 GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT
633 GMOCK_DECLARE_KIND_(unsigned short, kInteger); // NOLINT
635 GMOCK_DECLARE_KIND_(unsigned int, kInteger);
636 GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT
637 GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT
638 
639 #if GMOCK_WCHAR_T_IS_NATIVE_
640 GMOCK_DECLARE_KIND_(wchar_t, kInteger);
641 #endif
642 
643 // Non-standard integer types.
646 
647 // All standard floating-point types.
650 GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
651 
652 #undef GMOCK_DECLARE_KIND_
653 
654 // Evaluates to the kind of 'type'.
655 #define GMOCK_KIND_OF_(type) \
656  static_cast< ::testing::internal::TypeKind>( \
657  ::testing::internal::KindOf<type>::value)
658 
659 // Evaluates to true iff integer type T is signed.
660 #define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0)
661 
662 // LosslessArithmeticConvertibleImpl<kFromKind, From, kToKind, To>::value
663 // is true iff arithmetic type From can be losslessly converted to
664 // arithmetic type To.
665 //
666 // It's the user's responsibility to ensure that both From and To are
667 // raw (i.e. has no CV modifier, is not a pointer, and is not a
668 // reference) built-in arithmetic types, kFromKind is the kind of
669 // From, and kToKind is the kind of To; the value is
670 // implementation-defined when the above pre-condition is violated.
671 template <TypeKind kFromKind, typename From, TypeKind kToKind, typename To>
673 
674 // Converting bool to bool is lossless.
675 template <>
677  : public true_type {}; // NOLINT
678 
679 // Converting bool to any integer type is lossless.
680 template <typename To>
682  : public true_type {}; // NOLINT
683 
684 // Converting bool to any floating-point type is lossless.
685 template <typename To>
687  : public true_type {}; // NOLINT
688 
689 // Converting an integer to bool is lossy.
690 template <typename From>
692  : public false_type {}; // NOLINT
693 
694 // Converting an integer to another non-bool integer is lossless iff
695 // the target type's range encloses the source type's range.
696 template <typename From, typename To>
698  : public bool_constant <
699 // When converting from a smaller size to a larger size, we are
700 // fine as long as we are not converting from signed to unsigned.
701  ((sizeof(From) < sizeof(To)) &&
702  (!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
703  // When converting between the same size, the signedness must match.
704  ((sizeof(From) == sizeof(To)) &&
705  (GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To))) > {}; // NOLINT
706 
707 #undef GMOCK_IS_SIGNED_
708 
709 // Converting an integer to a floating-point type may be lossy, since
710 // the format of a floating-point number is implementation-defined.
711 template <typename From, typename To>
712 struct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To>
713  : public false_type {}; // NOLINT
714 
715 // Converting a floating-point to bool is lossy.
716 template <typename From>
717 struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool>
718  : public false_type {}; // NOLINT
719 
720 // Converting a floating-point to an integer is lossy.
721 template <typename From, typename To>
722 struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
723  : public false_type {}; // NOLINT
724 
725 // Converting a floating-point to another floating-point is lossless
726 // iff the target type is at least as big as the source type.
727 template <typename From, typename To>
728 struct LosslessArithmeticConvertibleImpl <
729  kFloatingPoint, From, kFloatingPoint, To >
730 : public bool_constant < sizeof(From) <= sizeof(To) > {}; // NOLINT
731 
732 // LosslessArithmeticConvertible<From, To>::value is true iff arithmetic
733 // type From can be losslessly converted to arithmetic type To.
734 //
735 // It's the user's responsibility to ensure that both From and To are
736 // raw (i.e. has no CV modifier, is not a pointer, and is not a
737 // reference) built-in arithmetic types; the value is
738 // implementation-defined when the above pre-condition is violated.
739 template <typename From, typename To>
740 struct LosslessArithmeticConvertible
741  : public LosslessArithmeticConvertibleImpl <
742  GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To > {}; // NOLINT
743 
744 // This interface knows how to report a Google Mock failure (either
745 // non-fatal or fatal).
746 class FailureReporterInterface
747 {
748 public:
749  // The type of a failure (either non-fatal or fatal).
750  enum FailureType
751  {
752  kNonfatal, kFatal
753  };
754 
755  virtual ~FailureReporterInterface() {}
756 
757  // Reports a failure that occurred at the given source file location.
758  virtual void ReportFailure(FailureType type, const char * file, int line,
759  const string & message) = 0;
760 };
761 
762 // Returns the failure reporter used by Google Mock.
763 GTEST_API_ FailureReporterInterface * GetFailureReporter();
764 
765 // Asserts that condition is true; aborts the process with the given
766 // message if condition is false. We cannot use LOG(FATAL) or CHECK()
767 // as Google Mock might be used to mock the log sink itself. We
768 // inline this function to prevent it from showing up in the stack
769 // trace.
770 inline void Assert(bool condition, const char * file, int line,
771  const string & msg)
772 {
773  if (!condition)
774  {
775  GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,
776  file, line, msg);
777  }
778 }
779 inline void Assert(bool condition, const char * file, int line)
780 {
781  Assert(condition, file, line, "Assertion failed.");
782 }
783 
784 // Verifies that condition is true; generates a non-fatal failure if
785 // condition is false.
786 inline void Expect(bool condition, const char * file, int line,
787  const string & msg)
788 {
789  if (!condition)
790  {
791  GetFailureReporter()->ReportFailure(FailureReporterInterface::kNonfatal,
792  file, line, msg);
793  }
794 }
795 inline void Expect(bool condition, const char * file, int line)
796 {
797  Expect(condition, file, line, "Expectation failed.");
798 }
799 
800 // Severity level of a log.
802 {
803  kInfo = 0,
805 };
806 
807 // Valid values for the --gmock_verbose flag.
808 
809 // All logs (informational and warnings) are printed.
810 const char kInfoVerbosity[] = "info";
811 // Only warnings are printed.
812 const char kWarningVerbosity[] = "warning";
813 // No logs are printed.
814 const char kErrorVerbosity[] = "error";
815 
816 // Returns true iff a log with the given severity is visible according
817 // to the --gmock_verbose flag.
818 GTEST_API_ bool LogIsVisible(LogSeverity severity);
819 
820 // Prints the given message to stdout iff 'severity' >= the level
821 // specified by the --gmock_verbose flag. If stack_frames_to_skip >=
822 // 0, also prints the stack trace excluding the top
823 // stack_frames_to_skip frames. In opt mode, any positive
824 // stack_frames_to_skip is treated as 0, since we don't know which
825 // function calls will be inlined by the compiler and need to be
826 // conservative.
827 GTEST_API_ void Log(LogSeverity severity,
828  const string & message,
829  int stack_frames_to_skip);
830 
831 // TODO(wan@google.com): group all type utilities together.
832 
833 // Type traits.
834 
835 // is_reference<T>::value is non-zero iff T is a reference type.
836 template <typename T> struct is_reference : public false_type {};
837 template <typename T> struct is_reference<T &> : public true_type {};
838 
839 // type_equals<T1, T2>::value is non-zero iff T1 and T2 are the same type.
840 template <typename T1, typename T2> struct type_equals : public false_type {};
841 template <typename T> struct type_equals<T, T> : public true_type {};
842 
843 // remove_reference<T>::type removes the reference from type T, if any.
844 template <typename T> struct remove_reference { typedef T type; }; // NOLINT
845 template <typename T> struct remove_reference<T &> { typedef T type; }; // NOLINT
846 
847 // DecayArray<T>::type turns an array type U[N] to const U* and preserves
848 // other types. Useful for saving a copy of a function argument.
849 template <typename T> struct DecayArray { typedef T type; }; // NOLINT
850 template <typename T, size_t N> struct DecayArray<T[N]>
851 {
852  typedef const T * type;
853 };
854 // Sometimes people use arrays whose size is not available at the use site
855 // (e.g. extern const char kNamePrefix[]). This specialization covers that
856 // case.
857 template <typename T> struct DecayArray<T[]>
858 {
859  typedef const T * type;
860 };
861 
862 // Invalid<T>() returns an invalid value of type T. This is useful
863 // when a value of type T is needed for compilation, but the statement
864 // will not really be executed (or we don't care if the statement
865 // crashes).
866 template <typename T>
867 inline T Invalid()
868 {
869  return const_cast<typename remove_reference<T>::type &>(
870  *static_cast<volatile typename remove_reference<T>::type *>(NULL));
871 }
872 template <>
873 inline void Invalid<void>() {}
874 
875 // Given a raw type (i.e. having no top-level reference or const
876 // modifier) RawContainer that's either an STL-style container or a
877 // native array, class StlContainerView<RawContainer> has the
878 // following members:
879 //
880 // - type is a type that provides an STL-style container view to
881 // (i.e. implements the STL container concept for) RawContainer;
882 // - const_reference is a type that provides a reference to a const
883 // RawContainer;
884 // - ConstReference(raw_container) returns a const reference to an STL-style
885 // container view to raw_container, which is a RawContainer.
886 // - Copy(raw_container) returns an STL-style container view of a
887 // copy of raw_container, which is a RawContainer.
888 //
889 // This generic version is used when RawContainer itself is already an
890 // STL-style container.
891 template <class RawContainer>
893 {
894 public:
895  typedef RawContainer type;
896  typedef const type & const_reference;
897 
898  static const_reference ConstReference(const RawContainer & container)
899  {
900  // Ensures that RawContainer is not a const type.
901  testing::StaticAssertTypeEq<RawContainer,
902  GTEST_REMOVE_CONST_(RawContainer)>();
903  return container;
904  }
905  static type Copy(const RawContainer & container) { return container; }
906 };
907 
908 // This specialization is used when RawContainer is a native array type.
909 template <typename Element, size_t N>
910 class StlContainerView<Element[N]>
911 {
912 public:
913  typedef GTEST_REMOVE_CONST_(Element) RawElement;
915  // NativeArray<T> can represent a native array either by value or by
916  // reference (selected by a constructor argument), so 'const type'
917  // can be used to reference a const native array. We cannot
918  // 'typedef const type& const_reference' here, as that would mean
919  // ConstReference() has to return a reference to a local variable.
920  typedef const type const_reference;
921 
922  static const_reference ConstReference(const Element(&array)[N])
923  {
924  // Ensures that Element is not a const type.
925  testing::StaticAssertTypeEq<Element, RawElement>();
926 #if GTEST_OS_SYMBIAN
927  // The Nokia Symbian compiler confuses itself in template instantiation
928  // for this call without the cast to Element*:
929  // function call '[testing::internal::NativeArray<char *>].NativeArray(
930  // {lval} const char *[4], long, testing::internal::RelationToSource)'
931  // does not match
932  // 'testing::internal::NativeArray<char *>::NativeArray(
933  // char *const *, unsigned int, testing::internal::RelationToSource)'
934  // (instantiating: 'testing::internal::ContainsMatcherImpl
935  // <const char * (&)[4]>::Matches(const char * (&)[4]) const')
936  // (instantiating: 'testing::internal::StlContainerView<char *[4]>::
937  // ConstReference(const char * (&)[4])')
938  // (and though the N parameter type is mismatched in the above explicit
939  // conversion of it doesn't help - only the conversion of the array).
940  return type(const_cast<Element *>(&array[0]), N, kReference);
941 #else
942  return type(array, N, kReference);
943 #endif // GTEST_OS_SYMBIAN
944  }
945  static type Copy(const Element(&array)[N])
946  {
947 #if GTEST_OS_SYMBIAN
948  return type(const_cast<Element *>(&array[0]), N, kCopy);
949 #else
950  return type(array, N, kCopy);
951 #endif // GTEST_OS_SYMBIAN
952  }
953 };
954 
955 // This specialization is used when RawContainer is a native array
956 // represented as a (pointer, size) tuple.
957 template <typename ElementPointer, typename Size>
958 class StlContainerView< ::std::tr1::tuple<ElementPointer, Size> >
959 {
960 public:
961  typedef GTEST_REMOVE_CONST_(
962  typename internal::PointeeOf<ElementPointer>::type) RawElement;
964  typedef const type const_reference;
965 
966  static const_reference ConstReference(
967  const ::std::tr1::tuple<ElementPointer, Size> & array)
968  {
970  return type(get<0>(array), get<1>(array), kReference);
971  }
972  static type Copy(const ::std::tr1::tuple<ElementPointer, Size> & array)
973  {
975  return type(get<0>(array), get<1>(array), kCopy);
976  }
977 };
978 
979 // The following specialization prevents the user from instantiating
980 // StlContainer with a reference type.
981 template <typename T> class StlContainerView<T &>;
982 
983 // A type transform to remove constness from the first part of a pair.
984 // Pairs like that are used as the value_type of associative containers,
985 // and this transform produces a similar but assignable pair.
986 template <typename T>
988 {
989  typedef T type;
990 };
991 
992 // Partially specialized to remove constness from std::pair<const K, V>.
993 template <typename K, typename V>
994 struct RemoveConstFromKey<std::pair<const K, V> >
995 {
996  typedef std::pair<K, V> type;
997 };
998 
999 // Mapping from booleans to types. Similar to boost::bool_<kValue> and
1000 // std::integral_constant<bool, kValue>.
1001 template <bool kValue>
1003 
1004 } // namespace internal
1005 } // namespace testing
1006 
1007 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
1008 
1009 namespace testing
1010 {
1011 
1012 // To implement an action Foo, define:
1013 // 1. a class FooAction that implements the ActionInterface interface, and
1014 // 2. a factory function that creates an Action object from a
1015 // const FooAction*.
1016 //
1017 // The two-level delegation design follows that of Matcher, providing
1018 // consistency for extension developers. It also eases ownership
1019 // management as Action objects can now be copied like plain values.
1020 
1021 namespace internal
1022 {
1023 
1024 template <typename F1, typename F2>
1026 
1027 // BuiltInDefaultValue<T>::Get() returns the "built-in" default
1028 // value for type T, which is NULL when T is a pointer type, 0 when T
1029 // is a numeric type, false when T is bool, or "" when T is string or
1030 // std::string. For any other type T, this value is undefined and the
1031 // function will abort the process.
1032 template <typename T>
1034 {
1035 public:
1036  // This function returns true iff type T has a built-in default value.
1037  static bool Exists() { return false; }
1038  static T Get()
1039  {
1040  Assert(false, __FILE__, __LINE__,
1041  "Default action undefined for the function return type.");
1042  return internal::Invalid<T>();
1043  // The above statement will never be reached, but is required in
1044  // order for this function to compile.
1045  }
1046 };
1047 
1048 // This partial specialization says that we use the same built-in
1049 // default value for T and const T.
1050 template <typename T>
1051 class BuiltInDefaultValue<const T>
1052 {
1053 public:
1054  static bool Exists() { return BuiltInDefaultValue<T>::Exists(); }
1055  static T Get() { return BuiltInDefaultValue<T>::Get(); }
1056 };
1057 
1058 // This partial specialization defines the default values for pointer
1059 // types.
1060 template <typename T>
1062 {
1063 public:
1064  static bool Exists() { return true; }
1065  static T * Get() { return NULL; }
1066 };
1067 
1068 // The following specializations define the default values for
1069 // specific types we care about.
1070 #define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
1071  template <> \
1072  class BuiltInDefaultValue<type> { \
1073  public: \
1074  static bool Exists() { return true; } \
1075  static type Get() { return value; } \
1076  }
1077 
1079 #if GTEST_HAS_GLOBAL_STRING
1081 #endif // GTEST_HAS_GLOBAL_STRING
1087 
1088 // There's no need for a default action for signed wchar_t, as that
1089 // type is the same as wchar_t for gcc, and invalid for MSVC.
1090 //
1091 // There's also no need for a default action for unsigned wchar_t, as
1092 // that type is the same as unsigned int for gcc, and invalid for
1093 // MSVC.
1094 #if GMOCK_WCHAR_T_IS_NATIVE_
1095 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(wchar_t, 0U); // NOLINT
1096 #endif
1097 
1098 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U); // NOLINT
1099 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0); // NOLINT
1102 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL); // NOLINT
1103 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L); // NOLINT
1108 
1109 #undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
1110 
1111 } // namespace internal
1112 
1113 // When an unexpected function call is encountered, Google Mock will
1114 // let it return a default value if the user has specified one for its
1115 // return type, or if the return type has a built-in default value;
1116 // otherwise Google Mock won't know what value to return and will have
1117 // to abort the process.
1118 //
1119 // The DefaultValue<T> class allows a user to specify the
1120 // default value for a type T that is both copyable and publicly
1121 // destructible (i.e. anything that can be used as a function return
1122 // type). The usage is:
1123 //
1124 // // Sets the default value for type T to be foo.
1125 // DefaultValue<T>::Set(foo);
1126 template <typename T>
1128 {
1129 public:
1130  // Sets the default value for type T; requires T to be
1131  // copy-constructable and have a public destructor.
1132  static void Set(T x)
1133  {
1134  delete value_;
1135  value_ = new T(x);
1136  }
1137 
1138  // Unsets the default value for type T.
1139  static void Clear()
1140  {
1141  delete value_;
1142  value_ = NULL;
1143  }
1144 
1145  // Returns true iff the user has set the default value for type T.
1146  static bool IsSet() { return value_ != NULL; }
1147 
1148  // Returns true if T has a default return value set by the user or there
1149  // exists a built-in default value.
1150  static bool Exists()
1151  {
1152  return IsSet() || internal::BuiltInDefaultValue<T>::Exists();
1153  }
1154 
1155  // Returns the default value for type T if the user has set one;
1156  // otherwise returns the built-in default value if there is one;
1157  // otherwise aborts the process.
1158  static T Get()
1159  {
1160  return value_ == NULL ?
1162  }
1163 
1164 private:
1165  static const T * value_;
1166 };
1167 
1168 // This partial specialization allows a user to set default values for
1169 // reference types.
1170 template <typename T>
1171 class DefaultValue<T &>
1172 {
1173 public:
1174  // Sets the default value for type T&.
1175  static void Set(T & x) // NOLINT
1176  {
1177  address_ = &x;
1178  }
1179 
1180  // Unsets the default value for type T&.
1181  static void Clear()
1182  {
1183  address_ = NULL;
1184  }
1185 
1186  // Returns true iff the user has set the default value for type T&.
1187  static bool IsSet() { return address_ != NULL; }
1188 
1189  // Returns true if T has a default return value set by the user or there
1190  // exists a built-in default value.
1191  static bool Exists()
1192  {
1193  return IsSet() || internal::BuiltInDefaultValue<T &>::Exists();
1194  }
1195 
1196  // Returns the default value for type T& if the user has set one;
1197  // otherwise returns the built-in default value if there is one;
1198  // otherwise aborts the process.
1199  static T & Get()
1200  {
1201  return address_ == NULL ?
1203  }
1204 
1205 private:
1206  static T * address_;
1207 };
1208 
1209 // This specialization allows DefaultValue<void>::Get() to
1210 // compile.
1211 template <>
1212 class DefaultValue<void>
1213 {
1214 public:
1215  static bool Exists() { return true; }
1216  static void Get() {}
1217 };
1218 
1219 // Points to the user-set default value for type T.
1220 template <typename T>
1221 const T * DefaultValue<T>::value_ = NULL;
1222 
1223 // Points to the user-set default value for type T&.
1224 template <typename T>
1225 T * DefaultValue<T &>::address_ = NULL;
1226 
1227 // Implement this interface to define an action for function type F.
1228 template <typename F>
1230 {
1231 public:
1234 
1236  virtual ~ActionInterface() {}
1237 
1238  // Performs the action. This method is not const, as in general an
1239  // action can have side effects and be stateful. For example, a
1240  // get-the-next-element-from-the-collection action will need to
1241  // remember the current element.
1242  virtual Result Perform(const ArgumentTuple & args) = 0;
1243 
1244 private:
1246 };
1247 
1248 // An Action<F> is a copyable and IMMUTABLE (except by assignment)
1249 // object that represents an action to be taken when a mock function
1250 // of type F is called. The implementation of Action<T> is just a
1251 // linked_ptr to const ActionInterface<T>, so copying is fairly cheap.
1252 // Don't inherit from Action!
1253 //
1254 // You can view an object implementing ActionInterface<F> as a
1255 // concrete action (including its current state), and an Action<F>
1256 // object as a handle to it.
1257 template <typename F>
1258 class Action
1259 {
1260 public:
1263 
1264  // Constructs a null Action. Needed for storing Action objects in
1265  // STL containers.
1266  Action() : impl_(NULL) {}
1267 
1268  // Constructs an Action from its implementation. A NULL impl is
1269  // used to represent the "do-default" action.
1270  explicit Action(ActionInterface<F> * impl) : impl_(impl) {}
1271 
1272  // Copy constructor.
1273  Action(const Action & action) : impl_(action.impl_) {}
1274 
1275  // This constructor allows us to turn an Action<Func> object into an
1276  // Action<F>, as long as F's arguments can be implicitly converted
1277  // to Func's and Func's return type can be implicitly converted to
1278  // F's.
1279  template <typename Func>
1280  explicit Action(const Action<Func> & action);
1281 
1282  // Returns true iff this is the DoDefault() action.
1283  bool IsDoDefault() const { return impl_.get() == NULL; }
1284 
1285  // Performs the action. Note that this method is const even though
1286  // the corresponding method in ActionInterface is not. The reason
1287  // is that a const Action<F> means that it cannot be re-bound to
1288  // another concrete action, not that the concrete action it binds to
1289  // cannot change state. (Think of the difference between a const
1290  // pointer and a pointer to const.)
1291  Result Perform(const ArgumentTuple & args) const
1292  {
1294  !IsDoDefault(), __FILE__, __LINE__,
1295  "You are using DoDefault() inside a composite action like "
1296  "DoAll() or WithArgs(). This is not supported for technical "
1297  "reasons. Please instead spell out the default action, or "
1298  "assign the default action to an Action variable and use "
1299  "the variable in various places.");
1300  return impl_->Perform(args);
1301  }
1302 
1303 private:
1304  template <typename F1, typename F2>
1306 
1308 };
1309 
1310 // The PolymorphicAction class template makes it easy to implement a
1311 // polymorphic action (i.e. an action that can be used in mock
1312 // functions of than one type, e.g. Return()).
1313 //
1314 // To define a polymorphic action, a user first provides a COPYABLE
1315 // implementation class that has a Perform() method template:
1316 //
1317 // class FooAction {
1318 // public:
1319 // template <typename Result, typename ArgumentTuple>
1320 // Result Perform(const ArgumentTuple& args) const {
1321 // // Processes the arguments and returns a result, using
1322 // // tr1::get<N>(args) to get the N-th (0-based) argument in the tuple.
1323 // }
1324 // ...
1325 // };
1326 //
1327 // Then the user creates the polymorphic action using
1328 // MakePolymorphicAction(object) where object has type FooAction. See
1329 // the definition of Return(void) and SetArgumentPointee<N>(value) for
1330 // complete examples.
1331 template <typename Impl>
1333 {
1334 public:
1335  explicit PolymorphicAction(const Impl & impl) : impl_(impl) {}
1336 
1337  template <typename F>
1338  operator Action<F>() const
1339  {
1340  return Action<F>(new MonomorphicImpl<F>(impl_));
1341  }
1342 
1343 private:
1344  template <typename F>
1346  {
1347  public:
1350 
1351  explicit MonomorphicImpl(const Impl & impl) : impl_(impl) {}
1352 
1353  virtual Result Perform(const ArgumentTuple & args)
1354  {
1355  return impl_.template Perform<Result>(args);
1356  }
1357 
1358  private:
1359  Impl impl_;
1360 
1362  };
1363 
1364  Impl impl_;
1365 
1367 };
1368 
1369 // Creates an Action from its implementation and returns it. The
1370 // created Action object owns the implementation.
1371 template <typename F>
1373 {
1374  return Action<F>(impl);
1375 }
1376 
1377 // Creates a polymorphic action from its implementation. This is
1378 // easier to use than the PolymorphicAction<Impl> constructor as it
1379 // doesn't require you to explicitly write the template argument, e.g.
1380 //
1381 // MakePolymorphicAction(foo);
1382 // vs
1383 // PolymorphicAction<TypeOfFoo>(foo);
1384 template <typename Impl>
1386 {
1387  return PolymorphicAction<Impl>(impl);
1388 }
1389 
1390 namespace internal
1391 {
1392 
1393 // Allows an Action<F2> object to pose as an Action<F1>, as long as F2
1394 // and F1 are compatible.
1395 template <typename F1, typename F2>
1396 class ActionAdaptor : public ActionInterface<F1>
1397 {
1398 public:
1401 
1402  explicit ActionAdaptor(const Action<F2> & from) : impl_(from.impl_) {}
1403 
1404  virtual Result Perform(const ArgumentTuple & args)
1405  {
1406  return impl_->Perform(args);
1407  }
1408 
1409 private:
1411 
1413 };
1414 
1415 // Implements the polymorphic Return(x) action, which can be used in
1416 // any function that returns the type of x, regardless of the argument
1417 // types.
1418 //
1419 // Note: The value passed into Return must be converted into
1420 // Function<F>::Result when this action is cast to Action<F> rather than
1421 // when that action is performed. This is important in scenarios like
1422 //
1423 // MOCK_METHOD1(Method, T(U));
1424 // ...
1425 // {
1426 // Foo foo;
1427 // X x(&foo);
1428 // EXPECT_CALL(mock, Method(_)).WillOnce(Return(x));
1429 // }
1430 //
1431 // In the example above the variable x holds reference to foo which leaves
1432 // scope and gets destroyed. If copying X just copies a reference to foo,
1433 // that copy will be left with a hanging reference. If conversion to T
1434 // makes a copy of foo, the above code is safe. To support that scenario, we
1435 // need to make sure that the type conversion happens inside the EXPECT_CALL
1436 // statement, and conversion of the result of Return to Action<T(U)> is a
1437 // good place for that.
1438 //
1439 template <typename R>
1441 {
1442 public:
1443  // Constructs a ReturnAction object from the value to be returned.
1444  // 'value' is passed by value instead of by const reference in order
1445  // to allow Return("string literal") to compile.
1446  explicit ReturnAction(R value) : value_(value) {}
1447 
1448  // This template type conversion operator allows Return(x) to be
1449  // used in ANY function that returns x's type.
1450  template <typename F>
1451  operator Action<F>() const
1452  {
1453  // Assert statement belongs here because this is the best place to verify
1454  // conditions on F. It produces the clearest error messages
1455  // in most compilers.
1456  // Impl really belongs in this scope as a local class but can't
1457  // because MSVC produces duplicate symbols in different translation units
1458  // in this case. Until MS fixes that bug we put Impl into the class scope
1459  // and put the typedef both here (for use in assert statement) and
1460  // in the Impl class. But both definitions must be the same.
1461  typedef typename Function<F>::Result Result;
1464  use_ReturnRef_instead_of_Return_to_return_a_reference);
1465  return Action<F>(new Impl<F>(value_));
1466  }
1467 
1468 private:
1469  // Implements the Return(x) action for a particular function type F.
1470  template <typename F>
1471  class Impl : public ActionInterface<F>
1472  {
1473  public:
1474  typedef typename Function<F>::Result Result;
1476 
1477  // The implicit cast is necessary when Result has more than one
1478  // single-argument constructor (e.g. Result is std::vector<int>) and R
1479  // has a type conversion operator template. In that case, value_(value)
1480  // won't compile as the compiler doesn't known which constructor of
1481  // Result to call. ImplicitCast_ forces the compiler to convert R to
1482  // Result without considering explicit constructors, thus resolving the
1483  // ambiguity. value_ is then initialized using its copy constructor.
1484  explicit Impl(R value)
1485  : value_(::testing::internal::ImplicitCast_<Result>(value)) {}
1486 
1487  virtual Result Perform(const ArgumentTuple &) { return value_; }
1488 
1489  private:
1491  Result_cannot_be_a_reference_type);
1492  Result value_;
1493 
1495  };
1496 
1498 
1500 };
1501 
1502 // Implements the ReturnNull() action.
1504 {
1505 public:
1506  // Allows ReturnNull() to be used in any pointer-returning function.
1507  template <typename Result, typename ArgumentTuple>
1508  static Result Perform(const ArgumentTuple &)
1509  {
1511  ReturnNull_can_be_used_to_return_a_pointer_only);
1512  return NULL;
1513  }
1514 };
1515 
1516 // Implements the Return() action.
1518 {
1519 public:
1520  // Allows Return() to be used in any void-returning function.
1521  template <typename Result, typename ArgumentTuple>
1522  static void Perform(const ArgumentTuple &)
1523  {
1525  }
1526 };
1527 
1528 // Implements the polymorphic ReturnRef(x) action, which can be used
1529 // in any function that returns a reference to the type of x,
1530 // regardless of the argument types.
1531 template <typename T>
1533 {
1534 public:
1535  // Constructs a ReturnRefAction object from the reference to be returned.
1536  explicit ReturnRefAction(T & ref) : ref_(ref) {} // NOLINT
1537 
1538  // This template type conversion operator allows ReturnRef(x) to be
1539  // used in ANY function that returns a reference to x's type.
1540  template <typename F>
1541  operator Action<F>() const
1542  {
1543  typedef typename Function<F>::Result Result;
1544  // Asserts that the function return type is a reference. This
1545  // catches the user error of using ReturnRef(x) when Return(x)
1546  // should be used, and generates some helpful error message.
1548  use_Return_instead_of_ReturnRef_to_return_a_value);
1549  return Action<F>(new Impl<F>(ref_));
1550  }
1551 
1552 private:
1553  // Implements the ReturnRef(x) action for a particular function type F.
1554  template <typename F>
1555  class Impl : public ActionInterface<F>
1556  {
1557  public:
1558  typedef typename Function<F>::Result Result;
1560 
1561  explicit Impl(T & ref) : ref_(ref) {} // NOLINT
1562 
1563  virtual Result Perform(const ArgumentTuple &)
1564  {
1565  return ref_;
1566  }
1567 
1568  private:
1569  T & ref_;
1570 
1572  };
1573 
1574  T & ref_;
1575 
1577 };
1578 
1579 // Implements the polymorphic ReturnRefOfCopy(x) action, which can be
1580 // used in any function that returns a reference to the type of x,
1581 // regardless of the argument types.
1582 template <typename T>
1584 {
1585 public:
1586  // Constructs a ReturnRefOfCopyAction object from the reference to
1587  // be returned.
1588  explicit ReturnRefOfCopyAction(const T & value) : value_(value) {} // NOLINT
1589 
1590  // This template type conversion operator allows ReturnRefOfCopy(x) to be
1591  // used in ANY function that returns a reference to x's type.
1592  template <typename F>
1593  operator Action<F>() const
1594  {
1595  typedef typename Function<F>::Result Result;
1596  // Asserts that the function return type is a reference. This
1597  // catches the user error of using ReturnRefOfCopy(x) when Return(x)
1598  // should be used, and generates some helpful error message.
1601  use_Return_instead_of_ReturnRefOfCopy_to_return_a_value);
1602  return Action<F>(new Impl<F>(value_));
1603  }
1604 
1605 private:
1606  // Implements the ReturnRefOfCopy(x) action for a particular function type F.
1607  template <typename F>
1608  class Impl : public ActionInterface<F>
1609  {
1610  public:
1611  typedef typename Function<F>::Result Result;
1613 
1614  explicit Impl(const T & value) : value_(value) {} // NOLINT
1615 
1616  virtual Result Perform(const ArgumentTuple &)
1617  {
1618  return value_;
1619  }
1620 
1621  private:
1623 
1625  };
1626 
1627  const T value_;
1628 
1630 };
1631 
1632 // Implements the polymorphic DoDefault() action.
1634 {
1635 public:
1636  // This template type conversion operator allows DoDefault() to be
1637  // used in any function.
1638  template <typename F>
1639  operator Action<F>() const { return Action<F>(NULL); }
1640 };
1641 
1642 // Implements the Assign action to set a given pointer referent to a
1643 // particular value.
1644 template <typename T1, typename T2>
1646 {
1647 public:
1648  AssignAction(T1 * ptr, T2 value) : ptr_(ptr), value_(value) {}
1649 
1650  template <typename Result, typename ArgumentTuple>
1651  void Perform(const ArgumentTuple & /* args */) const
1652  {
1653  *ptr_ = value_;
1654  }
1655 
1656 private:
1657  T1 * const ptr_;
1658  const T2 value_;
1659 
1661 };
1662 
1663 #if !GTEST_OS_WINDOWS_MOBILE
1664 
1665 // Implements the SetErrnoAndReturn action to simulate return from
1666 // various system calls and libc functions.
1667 template <typename T>
1669 {
1670 public:
1671  SetErrnoAndReturnAction(int errno_value, T result)
1672  : errno_(errno_value),
1673  result_(result) {}
1674  template <typename Result, typename ArgumentTuple>
1675  Result Perform(const ArgumentTuple & /* args */) const
1676  {
1677  errno = errno_;
1678  return result_;
1679  }
1680 
1681 private:
1682  const int errno_;
1683  const T result_;
1684 
1686 };
1687 
1688 #endif // !GTEST_OS_WINDOWS_MOBILE
1689 
1690 // Implements the SetArgumentPointee<N>(x) action for any function
1691 // whose N-th argument (0-based) is a pointer to x's type. The
1692 // template parameter kIsProto is true iff type A is ProtocolMessage,
1693 // proto2::Message, or a sub-class of those.
1694 template <size_t N, typename A, bool kIsProto>
1696 {
1697 public:
1698  // Constructs an action that sets the variable pointed to by the
1699  // N-th function argument to 'value'.
1700  explicit SetArgumentPointeeAction(const A & value) : value_(value) {}
1701 
1702  template <typename Result, typename ArgumentTuple>
1703  void Perform(const ArgumentTuple & args) const
1704  {
1706  *::std::tr1::get<N>(args) = value_;
1707  }
1708 
1709 private:
1710  const A value_;
1711 
1713 };
1714 
1715 template <size_t N, typename Proto>
1716 class SetArgumentPointeeAction<N, Proto, true>
1717 {
1718 public:
1719  // Constructs an action that sets the variable pointed to by the
1720  // N-th function argument to 'proto'. Both ProtocolMessage and
1721  // proto2::Message have the CopyFrom() method, so the same
1722  // implementation works for both.
1723  explicit SetArgumentPointeeAction(const Proto & proto) : proto_(new Proto)
1724  {
1725  proto_->CopyFrom(proto);
1726  }
1727 
1728  template <typename Result, typename ArgumentTuple>
1729  void Perform(const ArgumentTuple & args) const
1730  {
1732  ::std::tr1::get<N>(args)->CopyFrom(*proto_);
1733  }
1734 
1735 private:
1737 
1739 };
1740 
1741 // Implements the InvokeWithoutArgs(f) action. The template argument
1742 // FunctionImpl is the implementation type of f, which can be either a
1743 // function pointer or a functor. InvokeWithoutArgs(f) can be used as an
1744 // Action<F> as long as f's type is compatible with F (i.e. f can be
1745 // assigned to a tr1::function<F>).
1746 template <typename FunctionImpl>
1748 {
1749 public:
1750  // The c'tor makes a copy of function_impl (either a function
1751  // pointer or a functor).
1752  explicit InvokeWithoutArgsAction(FunctionImpl function_impl)
1753  : function_impl_(function_impl) {}
1754 
1755  // Allows InvokeWithoutArgs(f) to be used as any action whose type is
1756  // compatible with f.
1757  template <typename Result, typename ArgumentTuple>
1758  Result Perform(const ArgumentTuple &) { return function_impl_(); }
1759 
1760 private:
1761  FunctionImpl function_impl_;
1762 
1764 };
1765 
1766 // Implements the InvokeWithoutArgs(object_ptr, &Class::Method) action.
1767 template <class Class, typename MethodPtr>
1769 {
1770 public:
1771  InvokeMethodWithoutArgsAction(Class * obj_ptr, MethodPtr method_ptr)
1772  : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}
1773 
1774  template <typename Result, typename ArgumentTuple>
1775  Result Perform(const ArgumentTuple &) const
1776  {
1777  return (obj_ptr_->*method_ptr_)();
1778  }
1779 
1780 private:
1781  Class * const obj_ptr_;
1782  const MethodPtr method_ptr_;
1783 
1785 };
1786 
1787 // Implements the IgnoreResult(action) action.
1788 template <typename A>
1790 {
1791 public:
1792  explicit IgnoreResultAction(const A & action) : action_(action) {}
1793 
1794  template <typename F>
1795  operator Action<F>() const
1796  {
1797  // Assert statement belongs here because this is the best place to verify
1798  // conditions on F. It produces the clearest error messages
1799  // in most compilers.
1800  // Impl really belongs in this scope as a local class but can't
1801  // because MSVC produces duplicate symbols in different translation units
1802  // in this case. Until MS fixes that bug we put Impl into the class scope
1803  // and put the typedef both here (for use in assert statement) and
1804  // in the Impl class. But both definitions must be the same.
1805  typedef typename internal::Function<F>::Result Result;
1806 
1807  // Asserts at compile time that F returns void.
1809 
1810  return Action<F>(new Impl<F>(action_));
1811  }
1812 
1813 private:
1814  template <typename F>
1815  class Impl : public ActionInterface<F>
1816  {
1817  public:
1820 
1821  explicit Impl(const A & action) : action_(action) {}
1822 
1823  virtual void Perform(const ArgumentTuple & args)
1824  {
1825  // Performs the action and ignores its result.
1826  action_.Perform(args);
1827  }
1828 
1829  private:
1830  // Type OriginalFunction is the same as F except that its return
1831  // type is IgnoredValue.
1834 
1836 
1838  };
1839 
1840  const A action_;
1841 
1843 };
1844 
1845 // A ReferenceWrapper<T> object represents a reference to type T,
1846 // which can be either const or not. It can be explicitly converted
1847 // from, and implicitly converted to, a T&. Unlike a reference,
1848 // ReferenceWrapper<T> can be copied and can survive template type
1849 // inference. This is used to support by-reference arguments in the
1850 // InvokeArgument<N>(...) action. The idea was from "reference
1851 // wrappers" in tr1, which we don't have in our source tree yet.
1852 template <typename T>
1854 {
1855 public:
1856  // Constructs a ReferenceWrapper<T> object from a T&.
1857  explicit ReferenceWrapper(T & l_value) : pointer_(&l_value) {} // NOLINT
1858 
1859  // Allows a ReferenceWrapper<T> object to be implicitly converted to
1860  // a T&.
1861  operator T & () const { return *pointer_; }
1862 private:
1864 };
1865 
1866 // Allows the expression ByRef(x) to be printed as a reference to x.
1867 template <typename T>
1868 void PrintTo(const ReferenceWrapper<T> & ref, ::std::ostream * os)
1869 {
1870  T & value = ref;
1871  UniversalPrinter<T &>::Print(value, os);
1872 }
1873 
1874 // Does two actions sequentially. Used for implementing the DoAll(a1,
1875 // a2, ...) action.
1876 template <typename Action1, typename Action2>
1878 {
1879 public:
1880  DoBothAction(Action1 action1, Action2 action2)
1881  : action1_(action1), action2_(action2) {}
1882 
1883  // This template type conversion operator allows DoAll(a1, ..., a_n)
1884  // to be used in ANY function of compatible type.
1885  template <typename F>
1886  operator Action<F>() const
1887  {
1888  return Action<F>(new Impl<F>(action1_, action2_));
1889  }
1890 
1891 private:
1892  // Implements the DoAll(...) action for a particular function type F.
1893  template <typename F>
1894  class Impl : public ActionInterface<F>
1895  {
1896  public:
1897  typedef typename Function<F>::Result Result;
1900 
1901  Impl(const Action<VoidResult> & action1, const Action<F> & action2)
1902  : action1_(action1), action2_(action2) {}
1903 
1904  virtual Result Perform(const ArgumentTuple & args)
1905  {
1906  action1_.Perform(args);
1907  return action2_.Perform(args);
1908  }
1909 
1910  private:
1913 
1915  };
1916 
1917  Action1 action1_;
1918  Action2 action2_;
1919 
1921 };
1922 
1923 } // namespace internal
1924 
1925 // An Unused object can be implicitly constructed from ANY value.
1926 // This is handy when defining actions that ignore some or all of the
1927 // mock function arguments. For example, given
1928 //
1929 // MOCK_METHOD3(Foo, double(const string& label, double x, double y));
1930 // MOCK_METHOD3(Bar, double(int index, double x, double y));
1931 //
1932 // instead of
1933 //
1934 // double DistanceToOriginWithLabel(const string& label, double x, double y) {
1935 // return sqrt(x*x + y*y);
1936 // }
1937 // double DistanceToOriginWithIndex(int index, double x, double y) {
1938 // return sqrt(x*x + y*y);
1939 // }
1940 // ...
1941 // EXEPCT_CALL(mock, Foo("abc", _, _))
1942 // .WillOnce(Invoke(DistanceToOriginWithLabel));
1943 // EXEPCT_CALL(mock, Bar(5, _, _))
1944 // .WillOnce(Invoke(DistanceToOriginWithIndex));
1945 //
1946 // you could write
1947 //
1948 // // We can declare any uninteresting argument as Unused.
1949 // double DistanceToOrigin(Unused, double x, double y) {
1950 // return sqrt(x*x + y*y);
1951 // }
1952 // ...
1953 // EXEPCT_CALL(mock, Foo("abc", _, _)).WillOnce(Invoke(DistanceToOrigin));
1954 // EXEPCT_CALL(mock, Bar(5, _, _)).WillOnce(Invoke(DistanceToOrigin));
1956 
1957 // This constructor allows us to turn an Action<From> object into an
1958 // Action<To>, as long as To's arguments can be implicitly converted
1959 // to From's and From's return type cann be implicitly converted to
1960 // To's.
1961 template <typename To>
1962 template <typename From>
1964  : impl_(new internal::ActionAdaptor<To, From>(from)) {}
1965 
1966 // Creates an action that returns 'value'. 'value' is passed by value
1967 // instead of const reference - otherwise Return("string literal")
1968 // will trigger a compiler error about using array as initializer.
1969 template <typename R>
1971 {
1972  return internal::ReturnAction<R>(value);
1973 }
1974 
1975 // Creates an action that returns NULL.
1977 {
1979 }
1980 
1981 // Creates an action that returns from a void function.
1983 {
1985 }
1986 
1987 // Creates an action that returns the reference to a variable.
1988 template <typename R>
1990 {
1991  return internal::ReturnRefAction<R>(x);
1992 }
1993 
1994 // Creates an action that returns the reference to a copy of the
1995 // argument. The copy is created when the action is constructed and
1996 // lives as long as the action.
1997 template <typename R>
1999 {
2001 }
2002 
2003 // Creates an action that does the default action for the give mock function.
2005 {
2006  return internal::DoDefaultAction();
2007 }
2008 
2009 // Creates an action that sets the variable pointed by the N-th
2010 // (0-based) function argument to 'value'.
2011 template <size_t N, typename T>
2015 SetArgPointee(const T & x)
2016 {
2019 }
2020 
2021 #if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)
2022 // This overload allows SetArgPointee() to accept a string literal.
2023 // GCC prior to the version 4.0 and Symbian C++ compiler cannot distinguish
2024 // this overload from the templated version and emit a compile error.
2025 template <size_t N>
2028 SetArgPointee(const char * p)
2029 {
2031  N, const char *, false > (p));
2032 }
2033 
2034 template <size_t N>
2037 SetArgPointee(const wchar_t * p)
2038 {
2040  N, const wchar_t *, false > (p));
2041 }
2042 #endif
2043 
2044 // The following version is DEPRECATED.
2045 template <size_t N, typename T>
2050 {
2053 }
2054 
2055 // Creates an action that sets a pointer referent to a given value.
2056 template <typename T1, typename T2>
2058 {
2060 }
2061 
2062 #if !GTEST_OS_WINDOWS_MOBILE
2063 
2064 // Creates an action that sets errno and returns the appropriate error.
2065 template <typename T>
2067 SetErrnoAndReturn(int errval, T result)
2068 {
2069  return MakePolymorphicAction(
2070  internal::SetErrnoAndReturnAction<T>(errval, result));
2071 }
2072 
2073 #endif // !GTEST_OS_WINDOWS_MOBILE
2074 
2075 // Various overloads for InvokeWithoutArgs().
2076 
2077 // Creates an action that invokes 'function_impl' with no argument.
2078 template <typename FunctionImpl>
2080 InvokeWithoutArgs(FunctionImpl function_impl)
2081 {
2082  return MakePolymorphicAction(
2084 }
2085 
2086 // Creates an action that invokes the given method on the given object
2087 // with no argument.
2088 template <class Class, typename MethodPtr>
2090 InvokeWithoutArgs(Class * obj_ptr, MethodPtr method_ptr)
2091 {
2092  return MakePolymorphicAction(
2094  obj_ptr, method_ptr));
2095 }
2096 
2097 // Creates an action that performs an_action and throws away its
2098 // result. In other words, it changes the return type of an_action to
2099 // void. an_action MUST NOT return void, or the code won't compile.
2100 template <typename A>
2102 {
2103  return internal::IgnoreResultAction<A>(an_action);
2104 }
2105 
2106 // Creates a reference wrapper for the given L-value. If necessary,
2107 // you can explicitly specify the type of the reference. For example,
2108 // suppose 'derived' is an object of type Derived, ByRef(derived)
2109 // would wrap a Derived&. If you want to wrap a const Base& instead,
2110 // where Base is a base class of Derived, just write:
2111 //
2112 // ByRef<const Base>(derived)
2113 template <typename T>
2114 inline internal::ReferenceWrapper<T> ByRef(T & l_value) // NOLINT
2115 {
2116  return internal::ReferenceWrapper<T>(l_value);
2117 }
2118 
2119 } // namespace testing
2120 
2121 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
2122 // Copyright 2007, Google Inc.
2123 // All rights reserved.
2124 //
2125 // Redistribution and use in source and binary forms, with or without
2126 // modification, are permitted provided that the following conditions are
2127 // met:
2128 //
2129 // * Redistributions of source code must retain the above copyright
2130 // notice, this list of conditions and the following disclaimer.
2131 // * Redistributions in binary form must reproduce the above
2132 // copyright notice, this list of conditions and the following disclaimer
2133 // in the documentation and/or other materials provided with the
2134 // distribution.
2135 // * Neither the name of Google Inc. nor the names of its
2136 // contributors may be used to endorse or promote products derived from
2137 // this software without specific prior written permission.
2138 //
2139 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2140 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2141 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2142 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2143 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2144 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2145 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2146 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2147 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2148 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2149 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2150 //
2151 // Author: wan@google.com (Zhanyong Wan)
2152 
2153 // Google Mock - a framework for writing C++ mock classes.
2154 //
2155 // This file implements some commonly used cardinalities. More
2156 // cardinalities can be defined by the user implementing the
2157 // CardinalityInterface interface if necessary.
2158 
2159 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
2160 #define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
2161 
2162 #include <limits.h>
2163 #include <ostream> // NOLINT
2164 
2165 namespace testing
2166 {
2167 
2168 // To implement a cardinality Foo, define:
2169 // 1. a class FooCardinality that implements the
2170 // CardinalityInterface interface, and
2171 // 2. a factory function that creates a Cardinality object from a
2172 // const FooCardinality*.
2173 //
2174 // The two-level delegation design follows that of Matcher, providing
2175 // consistency for extension developers. It also eases ownership
2176 // management as Cardinality objects can now be copied like plain values.
2177 
2178 // The implementation of a cardinality.
2180 {
2181 public:
2183 
2184  // Conservative estimate on the lower/upper bound of the number of
2185  // calls allowed.
2186  virtual int ConservativeLowerBound() const { return 0; }
2187  virtual int ConservativeUpperBound() const { return INT_MAX; }
2188 
2189  // Returns true iff call_count calls will satisfy this cardinality.
2190  virtual bool IsSatisfiedByCallCount(int call_count) const = 0;
2191 
2192  // Returns true iff call_count calls will saturate this cardinality.
2193  virtual bool IsSaturatedByCallCount(int call_count) const = 0;
2194 
2195  // Describes self to an ostream.
2196  virtual void DescribeTo(::std::ostream * os) const = 0;
2197 };
2198 
2199 // A Cardinality is a copyable and IMMUTABLE (except by assignment)
2200 // object that specifies how many times a mock function is expected to
2201 // be called. The implementation of Cardinality is just a linked_ptr
2202 // to const CardinalityInterface, so copying is fairly cheap.
2203 // Don't inherit from Cardinality!
2205 {
2206 public:
2207  // Constructs a null cardinality. Needed for storing Cardinality
2208  // objects in STL containers.
2210 
2211  // Constructs a Cardinality from its implementation.
2212  explicit Cardinality(const CardinalityInterface * impl) : impl_(impl) {}
2213 
2214  // Conservative estimate on the lower/upper bound of the number of
2215  // calls allowed.
2216  int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); }
2217  int ConservativeUpperBound() const { return impl_->ConservativeUpperBound(); }
2218 
2219  // Returns true iff call_count calls will satisfy this cardinality.
2220  bool IsSatisfiedByCallCount(int call_count) const
2221  {
2222  return impl_->IsSatisfiedByCallCount(call_count);
2223  }
2224 
2225  // Returns true iff call_count calls will saturate this cardinality.
2226  bool IsSaturatedByCallCount(int call_count) const
2227  {
2228  return impl_->IsSaturatedByCallCount(call_count);
2229  }
2230 
2231  // Returns true iff call_count calls will over-saturate this
2232  // cardinality, i.e. exceed the maximum number of allowed calls.
2233  bool IsOverSaturatedByCallCount(int call_count) const
2234  {
2235  return impl_->IsSaturatedByCallCount(call_count) &&
2236  !impl_->IsSatisfiedByCallCount(call_count);
2237  }
2238 
2239  // Describes self to an ostream
2240  void DescribeTo(::std::ostream * os) const { impl_->DescribeTo(os); }
2241 
2242  // Describes the given actual call count to an ostream.
2243  static void DescribeActualCallCountTo(int actual_call_count,
2244  ::std::ostream * os);
2245 
2246 private:
2248 };
2249 
2250 // Creates a cardinality that allows at least n calls.
2252 
2253 // Creates a cardinality that allows at most n calls.
2255 
2256 // Creates a cardinality that allows any number of calls.
2258 
2259 // Creates a cardinality that allows between min and max calls.
2260 GTEST_API_ Cardinality Between(int min, int max);
2261 
2262 // Creates a cardinality that allows exactly n calls.
2264 
2265 // Creates a cardinality from its implementation.
2267 {
2268  return Cardinality(c);
2269 }
2270 
2271 } // namespace testing
2272 
2273 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
2274 // This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
2275 
2276 // Copyright 2007, Google Inc.
2277 // All rights reserved.
2278 //
2279 // Redistribution and use in source and binary forms, with or without
2280 // modification, are permitted provided that the following conditions are
2281 // met:
2282 //
2283 // * Redistributions of source code must retain the above copyright
2284 // notice, this list of conditions and the following disclaimer.
2285 // * Redistributions in binary form must reproduce the above
2286 // copyright notice, this list of conditions and the following disclaimer
2287 // in the documentation and/or other materials provided with the
2288 // distribution.
2289 // * Neither the name of Google Inc. nor the names of its
2290 // contributors may be used to endorse or promote products derived from
2291 // this software without specific prior written permission.
2292 //
2293 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2294 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2295 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2296 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2297 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2298 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2299 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2300 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2301 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2302 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2303 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2304 //
2305 // Author: wan@google.com (Zhanyong Wan)
2306 
2307 // Google Mock - a framework for writing C++ mock classes.
2308 //
2309 // This file implements some commonly used variadic actions.
2310 
2311 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
2312 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
2313 
2314 
2315 namespace testing
2316 {
2317 namespace internal
2318 {
2319 
2320 // InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary
2321 // function or method with the unpacked values, where F is a function
2322 // type that takes N arguments.
2323 template <typename Result, typename ArgumentTuple>
2325 
2326 template <typename R>
2328 {
2329 public:
2330  template <typename Function>
2331  static R Invoke(Function function, const ::std::tr1::tuple<> &)
2332  {
2333  return function();
2334  }
2335 
2336  template <class Class, typename MethodPtr>
2337  static R InvokeMethod(Class * obj_ptr,
2338  MethodPtr method_ptr,
2339  const ::std::tr1::tuple<> &)
2340  {
2341  return (obj_ptr->*method_ptr)();
2342  }
2343 };
2344 
2345 template <typename R, typename A1>
2347 {
2348 public:
2349  template <typename Function>
2350  static R Invoke(Function function, const ::std::tr1::tuple<A1> & args)
2351  {
2353  return function(get<0>(args));
2354  }
2355 
2356  template <class Class, typename MethodPtr>
2357  static R InvokeMethod(Class * obj_ptr,
2358  MethodPtr method_ptr,
2359  const ::std::tr1::tuple<A1> & args)
2360  {
2362  return (obj_ptr->*method_ptr)(get<0>(args));
2363  }
2364 };
2365 
2366 template <typename R, typename A1, typename A2>
2367 class InvokeHelper<R, ::std::tr1::tuple<A1, A2> >
2368 {
2369 public:
2370  template <typename Function>
2371  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2> & args)
2372  {
2374  return function(get<0>(args), get<1>(args));
2375  }
2376 
2377  template <class Class, typename MethodPtr>
2378  static R InvokeMethod(Class * obj_ptr,
2379  MethodPtr method_ptr,
2380  const ::std::tr1::tuple<A1, A2> & args)
2381  {
2383  return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args));
2384  }
2385 };
2386 
2387 template <typename R, typename A1, typename A2, typename A3>
2388 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3> >
2389 {
2390 public:
2391  template <typename Function>
2392  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2,
2393  A3> & args)
2394  {
2396  return function(get<0>(args), get<1>(args), get<2>(args));
2397  }
2398 
2399  template <class Class, typename MethodPtr>
2400  static R InvokeMethod(Class * obj_ptr,
2401  MethodPtr method_ptr,
2402  const ::std::tr1::tuple<A1, A2, A3> & args)
2403  {
2405  return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args));
2406  }
2407 };
2408 
2409 template <typename R, typename A1, typename A2, typename A3, typename A4>
2410 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4> >
2411 {
2412 public:
2413  template <typename Function>
2414  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3,
2415  A4> & args)
2416  {
2418  return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args));
2419  }
2420 
2421  template <class Class, typename MethodPtr>
2422  static R InvokeMethod(Class * obj_ptr,
2423  MethodPtr method_ptr,
2424  const ::std::tr1::tuple<A1, A2, A3, A4> & args)
2425  {
2427  return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
2428  get<3>(args));
2429  }
2430 };
2431 
2432 template <typename R, typename A1, typename A2, typename A3, typename A4,
2433  typename A5>
2434 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5> >
2435 {
2436 public:
2437  template <typename Function>
2438  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
2439  A5> & args)
2440  {
2442  return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
2443  get<4>(args));
2444  }
2445 
2446  template <class Class, typename MethodPtr>
2447  static R InvokeMethod(Class * obj_ptr,
2448  MethodPtr method_ptr,
2449  const ::std::tr1::tuple<A1, A2, A3, A4, A5> & args)
2450  {
2452  return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
2453  get<3>(args), get<4>(args));
2454  }
2455 };
2456 
2457 template <typename R, typename A1, typename A2, typename A3, typename A4,
2458  typename A5, typename A6>
2459 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> >
2460 {
2461 public:
2462  template <typename Function>
2463  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
2464  A5, A6> & args)
2465  {
2467  return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
2468  get<4>(args), get<5>(args));
2469  }
2470 
2471  template <class Class, typename MethodPtr>
2472  static R InvokeMethod(Class * obj_ptr,
2473  MethodPtr method_ptr,
2474  const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> & args)
2475  {
2477  return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
2478  get<3>(args), get<4>(args), get<5>(args));
2479  }
2480 };
2481 
2482 template <typename R, typename A1, typename A2, typename A3, typename A4,
2483  typename A5, typename A6, typename A7>
2484 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> >
2485 {
2486 public:
2487  template <typename Function>
2488  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
2489  A5, A6, A7> & args)
2490  {
2492  return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
2493  get<4>(args), get<5>(args), get<6>(args));
2494  }
2495 
2496  template <class Class, typename MethodPtr>
2497  static R InvokeMethod(Class * obj_ptr,
2498  MethodPtr method_ptr,
2499  const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6,
2500  A7> & args)
2501  {
2503  return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
2504  get<3>(args), get<4>(args), get<5>(args), get<6>(args));
2505  }
2506 };
2507 
2508 template <typename R, typename A1, typename A2, typename A3, typename A4,
2509  typename A5, typename A6, typename A7, typename A8>
2510 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> >
2511 {
2512 public:
2513  template <typename Function>
2514  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
2515  A5, A6, A7, A8> & args)
2516  {
2518  return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
2519  get<4>(args), get<5>(args), get<6>(args), get<7>(args));
2520  }
2521 
2522  template <class Class, typename MethodPtr>
2523  static R InvokeMethod(Class * obj_ptr,
2524  MethodPtr method_ptr,
2525  const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7,
2526  A8> & args)
2527  {
2529  return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
2530  get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args));
2531  }
2532 };
2533 
2534 template <typename R, typename A1, typename A2, typename A3, typename A4,
2535  typename A5, typename A6, typename A7, typename A8, typename A9>
2536 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> >
2537 {
2538 public:
2539  template <typename Function>
2540  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
2541  A5, A6, A7, A8, A9> & args)
2542  {
2544  return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
2545  get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args));
2546  }
2547 
2548  template <class Class, typename MethodPtr>
2549  static R InvokeMethod(Class * obj_ptr,
2550  MethodPtr method_ptr,
2551  const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
2552  A9> & args)
2553  {
2555  return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
2556  get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args),
2557  get<8>(args));
2558  }
2559 };
2560 
2561 template <typename R, typename A1, typename A2, typename A3, typename A4,
2562  typename A5, typename A6, typename A7, typename A8, typename A9,
2563  typename A10>
2564 class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
2565  A10> >
2566 {
2567 public:
2568  template <typename Function>
2569  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
2570  A5, A6, A7, A8, A9, A10> & args)
2571  {
2573  return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
2574  get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
2575  get<9>(args));
2576  }
2577 
2578  template <class Class, typename MethodPtr>
2579  static R InvokeMethod(Class * obj_ptr,
2580  MethodPtr method_ptr,
2581  const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
2582  A9, A10> & args)
2583  {
2585  return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
2586  get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args),
2587  get<8>(args), get<9>(args));
2588  }
2589 };
2590 
2591 // CallableHelper has static methods for invoking "callables",
2592 // i.e. function pointers and functors. It uses overloading to
2593 // provide a uniform interface for invoking different kinds of
2594 // callables. In particular, you can use:
2595 //
2596 // CallableHelper<R>::Call(callable, a1, a2, ..., an)
2597 //
2598 // to invoke an n-ary callable, where R is its return type. If an
2599 // argument, say a2, needs to be passed by reference, you should write
2600 // ByRef(a2) instead of a2 in the above expression.
2601 template <typename R>
2603 {
2604 public:
2605  // Calls a nullary callable.
2606  template <typename Function>
2607  static R Call(Function function) { return function(); }
2608 
2609  // Calls a unary callable.
2610 
2611  // We deliberately pass a1 by value instead of const reference here
2612  // in case it is a C-string literal. If we had declared the
2613  // parameter as 'const A1& a1' and write Call(function, "Hi"), the
2614  // compiler would've thought A1 is 'char[3]', which causes trouble
2615  // when you need to copy a value of type A1. By declaring the
2616  // parameter as 'A1 a1', the compiler will correctly infer that A1
2617  // is 'const char*' when it sees Call(function, "Hi").
2618  //
2619  // Since this function is defined inline, the compiler can get rid
2620  // of the copying of the arguments. Therefore the performance won't
2621  // be hurt.
2622  template <typename Function, typename A1>
2623  static R Call(Function function, A1 a1) { return function(a1); }
2624 
2625  // Calls a binary callable.
2626  template <typename Function, typename A1, typename A2>
2627  static R Call(Function function, A1 a1, A2 a2)
2628  {
2629  return function(a1, a2);
2630  }
2631 
2632  // Calls a ternary callable.
2633  template <typename Function, typename A1, typename A2, typename A3>
2634  static R Call(Function function, A1 a1, A2 a2, A3 a3)
2635  {
2636  return function(a1, a2, a3);
2637  }
2638 
2639  // Calls a 4-ary callable.
2640  template <typename Function, typename A1, typename A2, typename A3,
2641  typename A4>
2642  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4)
2643  {
2644  return function(a1, a2, a3, a4);
2645  }
2646 
2647  // Calls a 5-ary callable.
2648  template <typename Function, typename A1, typename A2, typename A3,
2649  typename A4, typename A5>
2650  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
2651  {
2652  return function(a1, a2, a3, a4, a5);
2653  }
2654 
2655  // Calls a 6-ary callable.
2656  template <typename Function, typename A1, typename A2, typename A3,
2657  typename A4, typename A5, typename A6>
2658  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
2659  {
2660  return function(a1, a2, a3, a4, a5, a6);
2661  }
2662 
2663  // Calls a 7-ary callable.
2664  template <typename Function, typename A1, typename A2, typename A3,
2665  typename A4, typename A5, typename A6, typename A7>
2666  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
2667  A7 a7)
2668  {
2669  return function(a1, a2, a3, a4, a5, a6, a7);
2670  }
2671 
2672  // Calls a 8-ary callable.
2673  template <typename Function, typename A1, typename A2, typename A3,
2674  typename A4, typename A5, typename A6, typename A7, typename A8>
2675  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
2676  A7 a7, A8 a8)
2677  {
2678  return function(a1, a2, a3, a4, a5, a6, a7, a8);
2679  }
2680 
2681  // Calls a 9-ary callable.
2682  template <typename Function, typename A1, typename A2, typename A3,
2683  typename A4, typename A5, typename A6, typename A7, typename A8,
2684  typename A9>
2685  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
2686  A7 a7, A8 a8, A9 a9)
2687  {
2688  return function(a1, a2, a3, a4, a5, a6, a7, a8, a9);
2689  }
2690 
2691  // Calls a 10-ary callable.
2692  template <typename Function, typename A1, typename A2, typename A3,
2693  typename A4, typename A5, typename A6, typename A7, typename A8,
2694  typename A9, typename A10>
2695  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
2696  A7 a7, A8 a8, A9 a9, A10 a10)
2697  {
2698  return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
2699  }
2700 }; // class CallableHelper
2701 
2702 // An INTERNAL macro for extracting the type of a tuple field. It's
2703 // subject to change without notice - DO NOT USE IN USER CODE!
2704 #define GMOCK_FIELD_(Tuple, N) \
2705  typename ::std::tr1::tuple_element<N, Tuple>::type
2706 
2707 // SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the
2708 // type of an n-ary function whose i-th (1-based) argument type is the
2709 // k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
2710 // type, and whose return type is Result. For example,
2711 // SelectArgs<int, ::std::tr1::tuple<bool, char, double, long>, 0, 3>::type
2712 // is int(bool, long).
2713 //
2714 // SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
2715 // returns the selected fields (k1, k2, ..., k_n) of args as a tuple.
2716 // For example,
2717 // SelectArgs<int, ::std::tr1::tuple<bool, char, double>, 2, 0>::Select(
2718 // ::std::tr1::make_tuple(true, 'a', 2.5))
2719 // returns ::std::tr1::tuple (2.5, true).
2720 //
2721 // The numbers in list k1, k2, ..., k_n must be >= 0, where n can be
2722 // in the range [0, 10]. Duplicates are allowed and they don't have
2723 // to be in an ascending or descending order.
2724 
2725 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
2726  int k4, int k5, int k6, int k7, int k8, int k9, int k10>
2728 {
2729 public:
2730  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
2731  GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
2732  GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
2733  GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
2734  GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9),
2735  GMOCK_FIELD_(ArgumentTuple, k10));
2737  static SelectedArgs Select(const ArgumentTuple & args)
2738  {
2740  return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
2741  get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
2742  get<k8>(args), get<k9>(args), get<k10>(args));
2743  }
2744 };
2745 
2746 template <typename Result, typename ArgumentTuple>
2747 class SelectArgs < Result, ArgumentTuple,
2748  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 >
2749 {
2750 public:
2751  typedef Result type();
2753  static SelectedArgs Select(const ArgumentTuple & /* args */)
2754  {
2756  return SelectedArgs();
2757  }
2758 };
2759 
2760 template <typename Result, typename ArgumentTuple, int k1>
2761 class SelectArgs < Result, ArgumentTuple,
2762  k1, -1, -1, -1, -1, -1, -1, -1, -1, -1 >
2763 {
2764 public:
2765  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1));
2767  static SelectedArgs Select(const ArgumentTuple & args)
2768  {
2770  return SelectedArgs(get<k1>(args));
2771  }
2772 };
2773 
2774 template <typename Result, typename ArgumentTuple, int k1, int k2>
2775 class SelectArgs < Result, ArgumentTuple,
2776  k1, k2, -1, -1, -1, -1, -1, -1, -1, -1 >
2777 {
2778 public:
2779  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
2780  GMOCK_FIELD_(ArgumentTuple, k2));
2782  static SelectedArgs Select(const ArgumentTuple & args)
2783  {
2785  return SelectedArgs(get<k1>(args), get<k2>(args));
2786  }
2787 };
2788 
2789 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3>
2790 class SelectArgs < Result, ArgumentTuple,
2791  k1, k2, k3, -1, -1, -1, -1, -1, -1, -1 >
2792 {
2793 public:
2794  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
2795  GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3));
2797  static SelectedArgs Select(const ArgumentTuple & args)
2798  {
2800  return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args));
2801  }
2802 };
2803 
2804 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
2805  int k4>
2806 class SelectArgs < Result, ArgumentTuple,
2807  k1, k2, k3, k4, -1, -1, -1, -1, -1, -1 >
2808 {
2809 public:
2810  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
2811  GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
2812  GMOCK_FIELD_(ArgumentTuple, k4));
2814  static SelectedArgs Select(const ArgumentTuple & args)
2815  {
2817  return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
2818  get<k4>(args));
2819  }
2820 };
2821 
2822 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
2823  int k4, int k5>
2824 class SelectArgs < Result, ArgumentTuple,
2825  k1, k2, k3, k4, k5, -1, -1, -1, -1, -1 >
2826 {
2827 public:
2828  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
2829  GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
2830  GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5));
2832  static SelectedArgs Select(const ArgumentTuple & args)
2833  {
2835  return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
2836  get<k4>(args), get<k5>(args));
2837  }
2838 };
2839 
2840 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
2841  int k4, int k5, int k6>
2842 class SelectArgs < Result, ArgumentTuple,
2843  k1, k2, k3, k4, k5, k6, -1, -1, -1, -1 >
2844 {
2845 public:
2846  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
2847  GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
2848  GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
2849  GMOCK_FIELD_(ArgumentTuple, k6));
2851  static SelectedArgs Select(const ArgumentTuple & args)
2852  {
2854  return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
2855  get<k4>(args), get<k5>(args), get<k6>(args));
2856  }
2857 };
2858 
2859 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
2860  int k4, int k5, int k6, int k7>
2861 class SelectArgs < Result, ArgumentTuple,
2862  k1, k2, k3, k4, k5, k6, k7, -1, -1, -1 >
2863 {
2864 public:
2865  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
2866  GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
2867  GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
2868  GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7));
2870  static SelectedArgs Select(const ArgumentTuple & args)
2871  {
2873  return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
2874  get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args));
2875  }
2876 };
2877 
2878 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
2879  int k4, int k5, int k6, int k7, int k8>
2880 class SelectArgs < Result, ArgumentTuple,
2881  k1, k2, k3, k4, k5, k6, k7, k8, -1, -1 >
2882 {
2883 public:
2884  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
2885  GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
2886  GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
2887  GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
2888  GMOCK_FIELD_(ArgumentTuple, k8));
2890  static SelectedArgs Select(const ArgumentTuple & args)
2891  {
2893  return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
2894  get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
2895  get<k8>(args));
2896  }
2897 };
2898 
2899 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
2900  int k4, int k5, int k6, int k7, int k8, int k9>
2901 class SelectArgs < Result, ArgumentTuple,
2902  k1, k2, k3, k4, k5, k6, k7, k8, k9, -1 >
2903 {
2904 public:
2905  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
2906  GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
2907  GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
2908  GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
2909  GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9));
2911  static SelectedArgs Select(const ArgumentTuple & args)
2912  {
2914  return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
2915  get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
2916  get<k8>(args), get<k9>(args));
2917  }
2918 };
2919 
2920 #undef GMOCK_FIELD_
2921 
2922 // Implements the WithArgs action.
2923 template < typename InnerAction, int k1 = -1, int k2 = -1, int k3 = -1,
2924  int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
2925  int k9 = -1, int k10 = -1 >
2927 {
2928 public:
2929  explicit WithArgsAction(const InnerAction & action) : action_(action) {}
2930 
2931  template <typename F>
2932  operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }
2933 
2934 private:
2935  template <typename F>
2936  class Impl : public ActionInterface<F>
2937  {
2938  public:
2939  typedef typename Function<F>::Result Result;
2941 
2942  explicit Impl(const InnerAction & action) : action_(action) {}
2943 
2944  virtual Result Perform(const ArgumentTuple & args)
2945  {
2946  return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, k4,
2947  k5, k6, k7, k8, k9, k10>::Select(args));
2948  }
2949 
2950  private:
2951  typedef typename SelectArgs<Result, ArgumentTuple,
2952  k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType;
2953 
2955  };
2956 
2957  const InnerAction action_;
2958 
2960 };
2961 
2962 // A macro from the ACTION* family (defined later in this file)
2963 // defines an action that can be used in a mock function. Typically,
2964 // these actions only care about a subset of the arguments of the mock
2965 // function. For example, if such an action only uses the second
2966 // argument, it can be used in any mock function that takes >= 2
2967 // arguments where the type of the second argument is compatible.
2968 //
2969 // Therefore, the action implementation must be prepared to take more
2970 // arguments than it needs. The ExcessiveArg type is used to
2971 // represent those excessive arguments. In order to keep the compiler
2972 // error messages tractable, we define it in the testing namespace
2973 // instead of testing::internal. However, this is an INTERNAL TYPE
2974 // and subject to change without notice, so a user MUST NOT USE THIS
2975 // TYPE DIRECTLY.
2976 struct ExcessiveArg {};
2977 
2978 // A helper class needed for implementing the ACTION* macros.
2979 template <typename Result, class Impl>
2981 {
2982 public:
2983  static Result Perform(Impl * impl, const ::std::tr1::tuple<> & args)
2984  {
2986  return impl->template gmock_PerformImpl<>(args, ExcessiveArg(),
2989  ExcessiveArg());
2990  }
2991 
2992  template <typename A0>
2993  static Result Perform(Impl * impl, const ::std::tr1::tuple<A0> & args)
2994  {
2996  return impl->template gmock_PerformImpl<A0>(args, get<0>(args),
2999  ExcessiveArg());
3000  }
3001 
3002  template <typename A0, typename A1>
3003  static Result Perform(Impl * impl, const ::std::tr1::tuple<A0, A1> & args)
3004  {
3006  return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args),
3007  get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
3009  ExcessiveArg());
3010  }
3011 
3012  template <typename A0, typename A1, typename A2>
3013  static Result Perform(Impl * impl, const ::std::tr1::tuple<A0, A1, A2> & args)
3014  {
3016  return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args),
3017  get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(),
3019  ExcessiveArg());
3020  }
3021 
3022  template <typename A0, typename A1, typename A2, typename A3>
3023  static Result Perform(Impl * impl, const ::std::tr1::tuple<A0, A1, A2,
3024  A3> & args)
3025  {
3027  return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(args),
3028  get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(),
3030  ExcessiveArg());
3031  }
3032 
3033  template <typename A0, typename A1, typename A2, typename A3, typename A4>
3034  static Result Perform(Impl * impl, const ::std::tr1::tuple<A0, A1, A2, A3,
3035  A4> & args)
3036  {
3038  return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args,
3039  get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
3041  ExcessiveArg());
3042  }
3043 
3044  template <typename A0, typename A1, typename A2, typename A3, typename A4,
3045  typename A5>
3046  static Result Perform(Impl * impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
3047  A5> & args)
3048  {
3050  return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args,
3051  get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
3052  get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
3053  ExcessiveArg());
3054  }
3055 
3056  template <typename A0, typename A1, typename A2, typename A3, typename A4,
3057  typename A5, typename A6>
3058  static Result Perform(Impl * impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
3059  A5, A6> & args)
3060  {
3062  return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args,
3063  get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
3064  get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(),
3065  ExcessiveArg());
3066  }
3067 
3068  template <typename A0, typename A1, typename A2, typename A3, typename A4,
3069  typename A5, typename A6, typename A7>
3070  static Result Perform(Impl * impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
3071  A5, A6, A7> & args)
3072  {
3074  return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6,
3075  A7>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
3076  get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(),
3077  ExcessiveArg());
3078  }
3079 
3080  template <typename A0, typename A1, typename A2, typename A3, typename A4,
3081  typename A5, typename A6, typename A7, typename A8>
3082  static Result Perform(Impl * impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
3083  A5, A6, A7, A8> & args)
3084  {
3086  return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7,
3087  A8>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
3088  get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
3089  ExcessiveArg());
3090  }
3091 
3092  template <typename A0, typename A1, typename A2, typename A3, typename A4,
3093  typename A5, typename A6, typename A7, typename A8, typename A9>
3094  static Result Perform(Impl * impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
3095  A5, A6, A7, A8, A9> & args)
3096  {
3098  return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8,
3099  A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
3100  get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
3101  get<9>(args));
3102  }
3103 };
3104 
3105 } // namespace internal
3106 
3107 // Various overloads for Invoke().
3108 
3109 // WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes
3110 // the selected arguments of the mock function to an_action and
3111 // performs it. It serves as an adaptor between actions with
3112 // different argument lists. C++ doesn't support default arguments for
3113 // function templates, so we have to overload it.
3114 template <int k1, typename InnerAction>
3116 WithArgs(const InnerAction & action)
3117 {
3119 }
3120 
3121 template <int k1, int k2, typename InnerAction>
3123 WithArgs(const InnerAction & action)
3124 {
3126 }
3127 
3128 template <int k1, int k2, int k3, typename InnerAction>
3130 WithArgs(const InnerAction & action)
3131 {
3133 }
3134 
3135 template <int k1, int k2, int k3, int k4, typename InnerAction>
3137 WithArgs(const InnerAction & action)
3138 {
3140 }
3141 
3142 template <int k1, int k2, int k3, int k4, int k5, typename InnerAction>
3144 WithArgs(const InnerAction & action)
3145 {
3147 }
3148 
3149 template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerAction>
3151 WithArgs(const InnerAction & action)
3152 {
3154 }
3155 
3156 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
3157  typename InnerAction>
3159 WithArgs(const InnerAction & action)
3160 {
3161  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6,
3162  k7>(action);
3163 }
3164 
3165 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
3166  typename InnerAction>
3168 WithArgs(const InnerAction & action)
3169 {
3170  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7,
3171  k8>(action);
3172 }
3173 
3174 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
3175  int k9, typename InnerAction>
3177 WithArgs(const InnerAction & action)
3178 {
3179  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
3180  k9>(action);
3181 }
3182 
3183 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
3184  int k9, int k10, typename InnerAction>
3185 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
3186  k9, k10>
3187  WithArgs(const InnerAction & action)
3188 {
3189  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
3190  k9, k10>(action);
3191 }
3192 
3193 // Creates an action that does actions a1, a2, ..., sequentially in
3194 // each invocation.
3195 template <typename Action1, typename Action2>
3197 DoAll(Action1 a1, Action2 a2)
3198 {
3200 }
3201 
3202 template <typename Action1, typename Action2, typename Action3>
3203 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
3204  Action3> >
3205  DoAll(Action1 a1, Action2 a2, Action3 a3)
3206 {
3207  return DoAll(a1, DoAll(a2, a3));
3208 }
3209 
3210 template <typename Action1, typename Action2, typename Action3,
3211  typename Action4>
3212 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
3214  DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4)
3215 {
3216  return DoAll(a1, DoAll(a2, a3, a4));
3217 }
3218 
3219 template <typename Action1, typename Action2, typename Action3,
3220  typename Action4, typename Action5>
3221 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
3223  Action5> > > >
3224  DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5)
3225 {
3226  return DoAll(a1, DoAll(a2, a3, a4, a5));
3227 }
3228 
3229 template <typename Action1, typename Action2, typename Action3,
3230  typename Action4, typename Action5, typename Action6>
3231 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
3234  DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6)
3235 {
3236  return DoAll(a1, DoAll(a2, a3, a4, a5, a6));
3237 }
3238 
3239 template <typename Action1, typename Action2, typename Action3,
3240  typename Action4, typename Action5, typename Action6, typename Action7>
3241 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
3244  Action7> > > > > >
3245  DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
3246  Action7 a7)
3247 {
3248  return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7));
3249 }
3250 
3251 template <typename Action1, typename Action2, typename Action3,
3252  typename Action4, typename Action5, typename Action6, typename Action7,
3253  typename Action8>
3254 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
3258  DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
3259  Action7 a7, Action8 a8)
3260 {
3261  return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8));
3262 }
3263 
3264 template <typename Action1, typename Action2, typename Action3,
3265  typename Action4, typename Action5, typename Action6, typename Action7,
3266  typename Action8, typename Action9>
3267 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
3271  Action9> > > > > > > >
3272  DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
3273  Action7 a7, Action8 a8, Action9 a9)
3274 {
3275  return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9));
3276 }
3277 
3278 template <typename Action1, typename Action2, typename Action3,
3279  typename Action4, typename Action5, typename Action6, typename Action7,
3280  typename Action8, typename Action9, typename Action10>
3281 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
3286  DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
3287  Action7 a7, Action8 a8, Action9 a9, Action10 a10)
3288 {
3289  return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10));
3290 }
3291 
3292 } // namespace testing
3293 
3294 // The ACTION* family of macros can be used in a namespace scope to
3295 // define custom actions easily. The syntax:
3296 //
3297 // ACTION(name) { statements; }
3298 //
3299 // will define an action with the given name that executes the
3300 // statements. The value returned by the statements will be used as
3301 // the return value of the action. Inside the statements, you can
3302 // refer to the K-th (0-based) argument of the mock function by
3303 // 'argK', and refer to its type by 'argK_type'. For example:
3304 //
3305 // ACTION(IncrementArg1) {
3306 // arg1_type temp = arg1;
3307 // return ++(*temp);
3308 // }
3309 //
3310 // allows you to write
3311 //
3312 // ...WillOnce(IncrementArg1());
3313 //
3314 // You can also refer to the entire argument tuple and its type by
3315 // 'args' and 'args_type', and refer to the mock function type and its
3316 // return type by 'function_type' and 'return_type'.
3317 //
3318 // Note that you don't need to specify the types of the mock function
3319 // arguments. However rest assured that your code is still type-safe:
3320 // you'll get a compiler error if *arg1 doesn't support the ++
3321 // operator, or if the type of ++(*arg1) isn't compatible with the
3322 // mock function's return type, for example.
3323 //
3324 // Sometimes you'll want to parameterize the action. For that you can use
3325 // another macro:
3326 //
3327 // ACTION_P(name, param_name) { statements; }
3328 //
3329 // For example:
3330 //
3331 // ACTION_P(Add, n) { return arg0 + n; }
3332 //
3333 // will allow you to write:
3334 //
3335 // ...WillOnce(Add(5));
3336 //
3337 // Note that you don't need to provide the type of the parameter
3338 // either. If you need to reference the type of a parameter named
3339 // 'foo', you can write 'foo_type'. For example, in the body of
3340 // ACTION_P(Add, n) above, you can write 'n_type' to refer to the type
3341 // of 'n'.
3342 //
3343 // We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support
3344 // multi-parameter actions.
3345 //
3346 // For the purpose of typing, you can view
3347 //
3348 // ACTION_Pk(Foo, p1, ..., pk) { ... }
3349 //
3350 // as shorthand for
3351 //
3352 // template <typename p1_type, ..., typename pk_type>
3353 // FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... }
3354 //
3355 // In particular, you can provide the template type arguments
3356 // explicitly when invoking Foo(), as in Foo<long, bool>(5, false);
3357 // although usually you can rely on the compiler to infer the types
3358 // for you automatically. You can assign the result of expression
3359 // Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ...,
3360 // pk_type>. This can be useful when composing actions.
3361 //
3362 // You can also overload actions with different numbers of parameters:
3363 //
3364 // ACTION_P(Plus, a) { ... }
3365 // ACTION_P2(Plus, a, b) { ... }
3366 //
3367 // While it's tempting to always use the ACTION* macros when defining
3368 // a new action, you should also consider implementing ActionInterface
3369 // or using MakePolymorphicAction() instead, especially if you need to
3370 // use the action a lot. While these approaches require more work,
3371 // they give you more control on the types of the mock function
3372 // arguments and the action parameters, which in general leads to
3373 // better compiler error messages that pay off in the long run. They
3374 // also allow overloading actions based on parameter types (as opposed
3375 // to just based on the number of parameters).
3376 //
3377 // CAVEAT:
3378 //
3379 // ACTION*() can only be used in a namespace scope. The reason is
3380 // that C++ doesn't yet allow function-local types to be used to
3381 // instantiate templates. The up-coming C++0x standard will fix this.
3382 // Once that's done, we'll consider supporting using ACTION*() inside
3383 // a function.
3384 //
3385 // MORE INFORMATION:
3386 //
3387 // To learn more about using these macros, please search for 'ACTION'
3388 // on http://code.google.com/p/googlemock/wiki/CookBook.
3389 
3390 // An internal macro needed for implementing ACTION*().
3391 #define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
3392  const args_type& args GTEST_ATTRIBUTE_UNUSED_, \
3393  arg0_type arg0 GTEST_ATTRIBUTE_UNUSED_, \
3394  arg1_type arg1 GTEST_ATTRIBUTE_UNUSED_, \
3395  arg2_type arg2 GTEST_ATTRIBUTE_UNUSED_, \
3396  arg3_type arg3 GTEST_ATTRIBUTE_UNUSED_, \
3397  arg4_type arg4 GTEST_ATTRIBUTE_UNUSED_, \
3398  arg5_type arg5 GTEST_ATTRIBUTE_UNUSED_, \
3399  arg6_type arg6 GTEST_ATTRIBUTE_UNUSED_, \
3400  arg7_type arg7 GTEST_ATTRIBUTE_UNUSED_, \
3401  arg8_type arg8 GTEST_ATTRIBUTE_UNUSED_, \
3402  arg9_type arg9 GTEST_ATTRIBUTE_UNUSED_
3403 
3404 // Sometimes you want to give an action explicit template parameters
3405 // that cannot be inferred from its value parameters. ACTION() and
3406 // ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that
3407 // and can be viewed as an extension to ACTION() and ACTION_P*().
3408 //
3409 // The syntax:
3410 //
3411 // ACTION_TEMPLATE(ActionName,
3412 // HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),
3413 // AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }
3414 //
3415 // defines an action template that takes m explicit template
3416 // parameters and n value parameters. name_i is the name of the i-th
3417 // template parameter, and kind_i specifies whether it's a typename,
3418 // an integral constant, or a template. p_i is the name of the i-th
3419 // value parameter.
3420 //
3421 // Example:
3422 //
3423 // // DuplicateArg<k, T>(output) converts the k-th argument of the mock
3424 // // function to type T and copies it to *output.
3425 // ACTION_TEMPLATE(DuplicateArg,
3426 // HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
3427 // AND_1_VALUE_PARAMS(output)) {
3428 // *output = T(std::tr1::get<k>(args));
3429 // }
3430 // ...
3431 // int n;
3432 // EXPECT_CALL(mock, Foo(_, _))
3433 // .WillOnce(DuplicateArg<1, unsigned char>(&n));
3434 //
3435 // To create an instance of an action template, write:
3436 //
3437 // ActionName<t1, ..., t_m>(v1, ..., v_n)
3438 //
3439 // where the ts are the template arguments and the vs are the value
3440 // arguments. The value argument types are inferred by the compiler.
3441 // If you want to explicitly specify the value argument types, you can
3442 // provide additional template arguments:
3443 //
3444 // ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)
3445 //
3446 // where u_i is the desired type of v_i.
3447 //
3448 // ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the
3449 // number of value parameters, but not on the number of template
3450 // parameters. Without the restriction, the meaning of the following
3451 // is unclear:
3452 //
3453 // OverloadedAction<int, bool>(x);
3454 //
3455 // Are we using a single-template-parameter action where 'bool' refers
3456 // to the type of x, or are we using a two-template-parameter action
3457 // where the compiler is asked to infer the type of x?
3458 //
3459 // Implementation notes:
3460 //
3461 // GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and
3462 // GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for
3463 // implementing ACTION_TEMPLATE. The main trick we use is to create
3464 // new macro invocations when expanding a macro. For example, we have
3465 //
3466 // #define ACTION_TEMPLATE(name, template_params, value_params)
3467 // ... GMOCK_INTERNAL_DECL_##template_params ...
3468 //
3469 // which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)
3470 // to expand to
3471 //
3472 // ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...
3473 //
3474 // Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the
3475 // preprocessor will continue to expand it to
3476 //
3477 // ... typename T ...
3478 //
3479 // This technique conforms to the C++ standard and is portable. It
3480 // allows us to implement action templates using O(N) code, where N is
3481 // the maximum number of template/value parameters supported. Without
3482 // using it, we'd have to devote O(N^2) amount of code to implement all
3483 // combinations of m and n.
3484 
3485 // Declares the template parameters.
3486 #define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0
3487 #define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
3488  name1) kind0 name0, kind1 name1
3489 #define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3490  kind2, name2) kind0 name0, kind1 name1, kind2 name2
3491 #define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3492  kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \
3493  kind3 name3
3494 #define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3495  kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \
3496  kind2 name2, kind3 name3, kind4 name4
3497 #define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3498  kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \
3499  kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
3500 #define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3501  kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
3502  name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
3503  kind5 name5, kind6 name6
3504 #define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3505  kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
3506  kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \
3507  kind4 name4, kind5 name5, kind6 name6, kind7 name7
3508 #define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3509  kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
3510  kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \
3511  kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \
3512  kind8 name8
3513 #define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
3514  name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
3515  name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \
3516  kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \
3517  kind6 name6, kind7 name7, kind8 name8, kind9 name9
3518 
3519 // Lists the template parameters.
3520 #define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0
3521 #define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
3522  name1) name0, name1
3523 #define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3524  kind2, name2) name0, name1, name2
3525 #define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3526  kind2, name2, kind3, name3) name0, name1, name2, name3
3527 #define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3528  kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \
3529  name4
3530 #define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3531  kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \
3532  name2, name3, name4, name5
3533 #define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3534  kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
3535  name6) name0, name1, name2, name3, name4, name5, name6
3536 #define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3537  kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
3538  kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7
3539 #define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
3540  kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
3541  kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \
3542  name6, name7, name8
3543 #define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
3544  name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
3545  name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \
3546  name3, name4, name5, name6, name7, name8, name9
3547 
3548 // Declares the types of value parameters.
3549 #define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()
3550 #define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type
3551 #define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \
3552  typename p0##_type, typename p1##_type
3553 #define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \
3554  typename p0##_type, typename p1##_type, typename p2##_type
3555 #define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
3556  typename p0##_type, typename p1##_type, typename p2##_type, \
3557  typename p3##_type
3558 #define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
3559  typename p0##_type, typename p1##_type, typename p2##_type, \
3560  typename p3##_type, typename p4##_type
3561 #define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
3562  typename p0##_type, typename p1##_type, typename p2##_type, \
3563  typename p3##_type, typename p4##_type, typename p5##_type
3564 #define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
3565  p6) , typename p0##_type, typename p1##_type, typename p2##_type, \
3566  typename p3##_type, typename p4##_type, typename p5##_type, \
3567  typename p6##_type
3568 #define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
3569  p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \
3570  typename p3##_type, typename p4##_type, typename p5##_type, \
3571  typename p6##_type, typename p7##_type
3572 #define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
3573  p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \
3574  typename p3##_type, typename p4##_type, typename p5##_type, \
3575  typename p6##_type, typename p7##_type, typename p8##_type
3576 #define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
3577  p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \
3578  typename p2##_type, typename p3##_type, typename p4##_type, \
3579  typename p5##_type, typename p6##_type, typename p7##_type, \
3580  typename p8##_type, typename p9##_type
3581 
3582 // Initializes the value parameters.
3583 #define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\
3584  ()
3585 #define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\
3586  (p0##_type gmock_p0) : p0(gmock_p0)
3587 #define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\
3588  (p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), p1(gmock_p1)
3589 #define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\
3590  (p0##_type gmock_p0, p1##_type gmock_p1, \
3591  p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2)
3592 #define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\
3593  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
3594  p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
3595  p3(gmock_p3)
3596 #define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\
3597  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
3598  p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), \
3599  p2(gmock_p2), p3(gmock_p3), p4(gmock_p4)
3600 #define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\
3601  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
3602  p3##_type gmock_p3, p4##_type gmock_p4, \
3603  p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
3604  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5)
3605 #define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\
3606  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
3607  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
3608  p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
3609  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6)
3610 #define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\
3611  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
3612  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
3613  p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), \
3614  p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
3615  p7(gmock_p7)
3616 #define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3617  p7, p8)\
3618  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
3619  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
3620  p6##_type gmock_p6, p7##_type gmock_p7, \
3621  p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
3622  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
3623  p8(gmock_p8)
3624 #define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3625  p7, p8, p9)\
3626  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
3627  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
3628  p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
3629  p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
3630  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
3631  p8(gmock_p8), p9(gmock_p9)
3632 
3633 // Declares the fields for storing the value parameters.
3634 #define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()
3635 #define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;
3636 #define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \
3637  p1##_type p1;
3638 #define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \
3639  p1##_type p1; p2##_type p2;
3640 #define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \
3641  p1##_type p1; p2##_type p2; p3##_type p3;
3642 #define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
3643  p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4;
3644 #define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
3645  p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
3646  p5##_type p5;
3647 #define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
3648  p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
3649  p5##_type p5; p6##_type p6;
3650 #define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3651  p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
3652  p5##_type p5; p6##_type p6; p7##_type p7;
3653 #define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3654  p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
3655  p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8;
3656 #define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3657  p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
3658  p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \
3659  p9##_type p9;
3660 
3661 // Lists the value parameters.
3662 #define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()
3663 #define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0
3664 #define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1
3665 #define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2
3666 #define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3
3667 #define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \
3668  p2, p3, p4
3669 #define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \
3670  p1, p2, p3, p4, p5
3671 #define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
3672  p6) p0, p1, p2, p3, p4, p5, p6
3673 #define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3674  p7) p0, p1, p2, p3, p4, p5, p6, p7
3675 #define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3676  p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8
3677 #define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3678  p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
3679 
3680 // Lists the value parameter types.
3681 #define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()
3682 #define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type
3683 #define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \
3684  p1##_type
3685 #define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \
3686  p1##_type, p2##_type
3687 #define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
3688  p0##_type, p1##_type, p2##_type, p3##_type
3689 #define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
3690  p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
3691 #define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
3692  p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
3693 #define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
3694  p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
3695  p6##_type
3696 #define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
3697  p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
3698  p5##_type, p6##_type, p7##_type
3699 #define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
3700  p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
3701  p5##_type, p6##_type, p7##_type, p8##_type
3702 #define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
3703  p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
3704  p5##_type, p6##_type, p7##_type, p8##_type, p9##_type
3705 
3706 // Declares the value parameters.
3707 #define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()
3708 #define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0
3709 #define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \
3710  p1##_type p1
3711 #define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \
3712  p1##_type p1, p2##_type p2
3713 #define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \
3714  p1##_type p1, p2##_type p2, p3##_type p3
3715 #define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
3716  p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4
3717 #define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
3718  p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
3719  p5##_type p5
3720 #define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
3721  p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
3722  p5##_type p5, p6##_type p6
3723 #define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3724  p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
3725  p5##_type p5, p6##_type p6, p7##_type p7
3726 #define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3727  p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
3728  p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8
3729 #define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3730  p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
3731  p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
3732  p9##_type p9
3733 
3734 // The suffix of the class template implementing the action template.
3735 #define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()
3736 #define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P
3737 #define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2
3738 #define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3
3739 #define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4
3740 #define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5
3741 #define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6
3742 #define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7
3743 #define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3744  p7) P8
3745 #define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3746  p7, p8) P9
3747 #define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
3748  p7, p8, p9) P10
3749 
3750 // The name of the class template implementing the action template.
3751 #define GMOCK_ACTION_CLASS_(name, value_params)\
3752  GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
3753 
3754 #define ACTION_TEMPLATE(name, template_params, value_params)\
3755  template <GMOCK_INTERNAL_DECL_##template_params\
3756  GMOCK_INTERNAL_DECL_TYPE_##value_params>\
3757  class GMOCK_ACTION_CLASS_(name, value_params) {\
3758  public:\
3759  GMOCK_ACTION_CLASS_(name, value_params)\
3760  GMOCK_INTERNAL_INIT_##value_params {}\
3761  template <typename F>\
3762  class gmock_Impl : public ::testing::ActionInterface<F> {\
3763  public:\
3764  typedef F function_type;\
3765  typedef typename ::testing::internal::Function<F>::Result return_type;\
3766  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
3767  args_type;\
3768  explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\
3769  virtual return_type Perform(const args_type& args) {\
3770  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
3771  Perform(this, args);\
3772  }\
3773  template <typename arg0_type, typename arg1_type, typename arg2_type, \
3774  typename arg3_type, typename arg4_type, typename arg5_type, \
3775  typename arg6_type, typename arg7_type, typename arg8_type, \
3776  typename arg9_type>\
3777  return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
3778  arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
3779  arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
3780  arg9_type arg9) const;\
3781  GMOCK_INTERNAL_DEFN_##value_params\
3782  private:\
3783  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
3784  };\
3785  template <typename F> operator ::testing::Action<F>() const {\
3786  return ::testing::Action<F>(\
3787  new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
3788  }\
3789  GMOCK_INTERNAL_DEFN_##value_params\
3790  private:\
3791  GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
3792  };\
3793  template <GMOCK_INTERNAL_DECL_##template_params\
3794  GMOCK_INTERNAL_DECL_TYPE_##value_params>\
3795  inline GMOCK_ACTION_CLASS_(name, value_params)<\
3796  GMOCK_INTERNAL_LIST_##template_params\
3797  GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\
3798  GMOCK_INTERNAL_DECL_##value_params) {\
3799  return GMOCK_ACTION_CLASS_(name, value_params)<\
3800  GMOCK_INTERNAL_LIST_##template_params\
3801  GMOCK_INTERNAL_LIST_TYPE_##value_params>(\
3802  GMOCK_INTERNAL_LIST_##value_params);\
3803  }\
3804  template <GMOCK_INTERNAL_DECL_##template_params\
3805  GMOCK_INTERNAL_DECL_TYPE_##value_params>\
3806  template <typename F>\
3807  template <typename arg0_type, typename arg1_type, typename arg2_type, \
3808  typename arg3_type, typename arg4_type, typename arg5_type, \
3809  typename arg6_type, typename arg7_type, typename arg8_type, \
3810  typename arg9_type>\
3811  typename ::testing::internal::Function<F>::Result\
3812  GMOCK_ACTION_CLASS_(name, value_params)<\
3813  GMOCK_INTERNAL_LIST_##template_params\
3814  GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\
3815  gmock_PerformImpl(\
3816  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
3817 
3818 #define ACTION(name)\
3819  class name##Action {\
3820  public:\
3821  name##Action() {}\
3822  template <typename F>\
3823  class gmock_Impl : public ::testing::ActionInterface<F> {\
3824  public:\
3825  typedef F function_type;\
3826  typedef typename ::testing::internal::Function<F>::Result return_type;\
3827  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
3828  args_type;\
3829  gmock_Impl() {}\
3830  virtual return_type Perform(const args_type& args) {\
3831  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
3832  Perform(this, args);\
3833  }\
3834  template <typename arg0_type, typename arg1_type, typename arg2_type, \
3835  typename arg3_type, typename arg4_type, typename arg5_type, \
3836  typename arg6_type, typename arg7_type, typename arg8_type, \
3837  typename arg9_type>\
3838  return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
3839  arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
3840  arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
3841  arg9_type arg9) const;\
3842  private:\
3843  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
3844  };\
3845  template <typename F> operator ::testing::Action<F>() const {\
3846  return ::testing::Action<F>(new gmock_Impl<F>());\
3847  }\
3848  private:\
3849  GTEST_DISALLOW_ASSIGN_(name##Action);\
3850  };\
3851  inline name##Action name() {\
3852  return name##Action();\
3853  }\
3854  template <typename F>\
3855  template <typename arg0_type, typename arg1_type, typename arg2_type, \
3856  typename arg3_type, typename arg4_type, typename arg5_type, \
3857  typename arg6_type, typename arg7_type, typename arg8_type, \
3858  typename arg9_type>\
3859  typename ::testing::internal::Function<F>::Result\
3860  name##Action::gmock_Impl<F>::gmock_PerformImpl(\
3861  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
3862 
3863 #define ACTION_P(name, p0)\
3864  template <typename p0##_type>\
3865  class name##ActionP {\
3866  public:\
3867  name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\
3868  template <typename F>\
3869  class gmock_Impl : public ::testing::ActionInterface<F> {\
3870  public:\
3871  typedef F function_type;\
3872  typedef typename ::testing::internal::Function<F>::Result return_type;\
3873  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
3874  args_type;\
3875  explicit gmock_Impl(p0##_type gmock_p0) : p0(gmock_p0) {}\
3876  virtual return_type Perform(const args_type& args) {\
3877  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
3878  Perform(this, args);\
3879  }\
3880  template <typename arg0_type, typename arg1_type, typename arg2_type, \
3881  typename arg3_type, typename arg4_type, typename arg5_type, \
3882  typename arg6_type, typename arg7_type, typename arg8_type, \
3883  typename arg9_type>\
3884  return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
3885  arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
3886  arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
3887  arg9_type arg9) const;\
3888  p0##_type p0;\
3889  private:\
3890  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
3891  };\
3892  template <typename F> operator ::testing::Action<F>() const {\
3893  return ::testing::Action<F>(new gmock_Impl<F>(p0));\
3894  }\
3895  p0##_type p0;\
3896  private:\
3897  GTEST_DISALLOW_ASSIGN_(name##ActionP);\
3898  };\
3899  template <typename p0##_type>\
3900  inline name##ActionP<p0##_type> name(p0##_type p0) {\
3901  return name##ActionP<p0##_type>(p0);\
3902  }\
3903  template <typename p0##_type>\
3904  template <typename F>\
3905  template <typename arg0_type, typename arg1_type, typename arg2_type, \
3906  typename arg3_type, typename arg4_type, typename arg5_type, \
3907  typename arg6_type, typename arg7_type, typename arg8_type, \
3908  typename arg9_type>\
3909  typename ::testing::internal::Function<F>::Result\
3910  name##ActionP<p0##_type>::gmock_Impl<F>::gmock_PerformImpl(\
3911  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
3912 
3913 #define ACTION_P2(name, p0, p1)\
3914  template <typename p0##_type, typename p1##_type>\
3915  class name##ActionP2 {\
3916  public:\
3917  name##ActionP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
3918  p1(gmock_p1) {}\
3919  template <typename F>\
3920  class gmock_Impl : public ::testing::ActionInterface<F> {\
3921  public:\
3922  typedef F function_type;\
3923  typedef typename ::testing::internal::Function<F>::Result return_type;\
3924  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
3925  args_type;\
3926  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
3927  p1(gmock_p1) {}\
3928  virtual return_type Perform(const args_type& args) {\
3929  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
3930  Perform(this, args);\
3931  }\
3932  template <typename arg0_type, typename arg1_type, typename arg2_type, \
3933  typename arg3_type, typename arg4_type, typename arg5_type, \
3934  typename arg6_type, typename arg7_type, typename arg8_type, \
3935  typename arg9_type>\
3936  return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
3937  arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
3938  arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
3939  arg9_type arg9) const;\
3940  p0##_type p0;\
3941  p1##_type p1;\
3942  private:\
3943  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
3944  };\
3945  template <typename F> operator ::testing::Action<F>() const {\
3946  return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\
3947  }\
3948  p0##_type p0;\
3949  p1##_type p1;\
3950  private:\
3951  GTEST_DISALLOW_ASSIGN_(name##ActionP2);\
3952  };\
3953  template <typename p0##_type, typename p1##_type>\
3954  inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \
3955  p1##_type p1) {\
3956  return name##ActionP2<p0##_type, p1##_type>(p0, p1);\
3957  }\
3958  template <typename p0##_type, typename p1##_type>\
3959  template <typename F>\
3960  template <typename arg0_type, typename arg1_type, typename arg2_type, \
3961  typename arg3_type, typename arg4_type, typename arg5_type, \
3962  typename arg6_type, typename arg7_type, typename arg8_type, \
3963  typename arg9_type>\
3964  typename ::testing::internal::Function<F>::Result\
3965  name##ActionP2<p0##_type, p1##_type>::gmock_Impl<F>::gmock_PerformImpl(\
3966  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
3967 
3968 #define ACTION_P3(name, p0, p1, p2)\
3969  template <typename p0##_type, typename p1##_type, typename p2##_type>\
3970  class name##ActionP3 {\
3971  public:\
3972  name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \
3973  p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
3974  template <typename F>\
3975  class gmock_Impl : public ::testing::ActionInterface<F> {\
3976  public:\
3977  typedef F function_type;\
3978  typedef typename ::testing::internal::Function<F>::Result return_type;\
3979  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
3980  args_type;\
3981  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \
3982  p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
3983  virtual return_type Perform(const args_type& args) {\
3984  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
3985  Perform(this, args);\
3986  }\
3987  template <typename arg0_type, typename arg1_type, typename arg2_type, \
3988  typename arg3_type, typename arg4_type, typename arg5_type, \
3989  typename arg6_type, typename arg7_type, typename arg8_type, \
3990  typename arg9_type>\
3991  return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
3992  arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
3993  arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
3994  arg9_type arg9) const;\
3995  p0##_type p0;\
3996  p1##_type p1;\
3997  p2##_type p2;\
3998  private:\
3999  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
4000  };\
4001  template <typename F> operator ::testing::Action<F>() const {\
4002  return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\
4003  }\
4004  p0##_type p0;\
4005  p1##_type p1;\
4006  p2##_type p2;\
4007  private:\
4008  GTEST_DISALLOW_ASSIGN_(name##ActionP3);\
4009  };\
4010  template <typename p0##_type, typename p1##_type, typename p2##_type>\
4011  inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
4012  p1##_type p1, p2##_type p2) {\
4013  return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
4014  }\
4015  template <typename p0##_type, typename p1##_type, typename p2##_type>\
4016  template <typename F>\
4017  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4018  typename arg3_type, typename arg4_type, typename arg5_type, \
4019  typename arg6_type, typename arg7_type, typename arg8_type, \
4020  typename arg9_type>\
4021  typename ::testing::internal::Function<F>::Result\
4022  name##ActionP3<p0##_type, p1##_type, \
4023  p2##_type>::gmock_Impl<F>::gmock_PerformImpl(\
4024  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
4025 
4026 #define ACTION_P4(name, p0, p1, p2, p3)\
4027  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4028  typename p3##_type>\
4029  class name##ActionP4 {\
4030  public:\
4031  name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \
4032  p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
4033  p2(gmock_p2), p3(gmock_p3) {}\
4034  template <typename F>\
4035  class gmock_Impl : public ::testing::ActionInterface<F> {\
4036  public:\
4037  typedef F function_type;\
4038  typedef typename ::testing::internal::Function<F>::Result return_type;\
4039  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
4040  args_type;\
4041  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
4042  p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
4043  p3(gmock_p3) {}\
4044  virtual return_type Perform(const args_type& args) {\
4045  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
4046  Perform(this, args);\
4047  }\
4048  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4049  typename arg3_type, typename arg4_type, typename arg5_type, \
4050  typename arg6_type, typename arg7_type, typename arg8_type, \
4051  typename arg9_type>\
4052  return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
4053  arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
4054  arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
4055  arg9_type arg9) const;\
4056  p0##_type p0;\
4057  p1##_type p1;\
4058  p2##_type p2;\
4059  p3##_type p3;\
4060  private:\
4061  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
4062  };\
4063  template <typename F> operator ::testing::Action<F>() const {\
4064  return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\
4065  }\
4066  p0##_type p0;\
4067  p1##_type p1;\
4068  p2##_type p2;\
4069  p3##_type p3;\
4070  private:\
4071  GTEST_DISALLOW_ASSIGN_(name##ActionP4);\
4072  };\
4073  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4074  typename p3##_type>\
4075  inline name##ActionP4<p0##_type, p1##_type, p2##_type, \
4076  p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
4077  p3##_type p3) {\
4078  return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p1, \
4079  p2, p3);\
4080  }\
4081  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4082  typename p3##_type>\
4083  template <typename F>\
4084  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4085  typename arg3_type, typename arg4_type, typename arg5_type, \
4086  typename arg6_type, typename arg7_type, typename arg8_type, \
4087  typename arg9_type>\
4088  typename ::testing::internal::Function<F>::Result\
4089  name##ActionP4<p0##_type, p1##_type, p2##_type, \
4090  p3##_type>::gmock_Impl<F>::gmock_PerformImpl(\
4091  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
4092 
4093 #define ACTION_P5(name, p0, p1, p2, p3, p4)\
4094  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4095  typename p3##_type, typename p4##_type>\
4096  class name##ActionP5 {\
4097  public:\
4098  name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \
4099  p2##_type gmock_p2, p3##_type gmock_p3, \
4100  p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
4101  p3(gmock_p3), p4(gmock_p4) {}\
4102  template <typename F>\
4103  class gmock_Impl : public ::testing::ActionInterface<F> {\
4104  public:\
4105  typedef F function_type;\
4106  typedef typename ::testing::internal::Function<F>::Result return_type;\
4107  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
4108  args_type;\
4109  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
4110  p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), \
4111  p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4) {}\
4112  virtual return_type Perform(const args_type& args) {\
4113  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
4114  Perform(this, args);\
4115  }\
4116  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4117  typename arg3_type, typename arg4_type, typename arg5_type, \
4118  typename arg6_type, typename arg7_type, typename arg8_type, \
4119  typename arg9_type>\
4120  return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
4121  arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
4122  arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
4123  arg9_type arg9) const;\
4124  p0##_type p0;\
4125  p1##_type p1;\
4126  p2##_type p2;\
4127  p3##_type p3;\
4128  p4##_type p4;\
4129  private:\
4130  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
4131  };\
4132  template <typename F> operator ::testing::Action<F>() const {\
4133  return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\
4134  }\
4135  p0##_type p0;\
4136  p1##_type p1;\
4137  p2##_type p2;\
4138  p3##_type p3;\
4139  p4##_type p4;\
4140  private:\
4141  GTEST_DISALLOW_ASSIGN_(name##ActionP5);\
4142  };\
4143  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4144  typename p3##_type, typename p4##_type>\
4145  inline name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
4146  p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
4147  p4##_type p4) {\
4148  return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
4149  p4##_type>(p0, p1, p2, p3, p4);\
4150  }\
4151  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4152  typename p3##_type, typename p4##_type>\
4153  template <typename F>\
4154  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4155  typename arg3_type, typename arg4_type, typename arg5_type, \
4156  typename arg6_type, typename arg7_type, typename arg8_type, \
4157  typename arg9_type>\
4158  typename ::testing::internal::Function<F>::Result\
4159  name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
4160  p4##_type>::gmock_Impl<F>::gmock_PerformImpl(\
4161  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
4162 
4163 #define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\
4164  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4165  typename p3##_type, typename p4##_type, typename p5##_type>\
4166  class name##ActionP6 {\
4167  public:\
4168  name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \
4169  p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
4170  p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
4171  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
4172  template <typename F>\
4173  class gmock_Impl : public ::testing::ActionInterface<F> {\
4174  public:\
4175  typedef F function_type;\
4176  typedef typename ::testing::internal::Function<F>::Result return_type;\
4177  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
4178  args_type;\
4179  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
4180  p3##_type gmock_p3, p4##_type gmock_p4, \
4181  p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
4182  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
4183  virtual return_type Perform(const args_type& args) {\
4184  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
4185  Perform(this, args);\
4186  }\
4187  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4188  typename arg3_type, typename arg4_type, typename arg5_type, \
4189  typename arg6_type, typename arg7_type, typename arg8_type, \
4190  typename arg9_type>\
4191  return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
4192  arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
4193  arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
4194  arg9_type arg9) const;\
4195  p0##_type p0;\
4196  p1##_type p1;\
4197  p2##_type p2;\
4198  p3##_type p3;\
4199  p4##_type p4;\
4200  p5##_type p5;\
4201  private:\
4202  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
4203  };\
4204  template <typename F> operator ::testing::Action<F>() const {\
4205  return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5));\
4206  }\
4207  p0##_type p0;\
4208  p1##_type p1;\
4209  p2##_type p2;\
4210  p3##_type p3;\
4211  p4##_type p4;\
4212  p5##_type p5;\
4213  private:\
4214  GTEST_DISALLOW_ASSIGN_(name##ActionP6);\
4215  };\
4216  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4217  typename p3##_type, typename p4##_type, typename p5##_type>\
4218  inline name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
4219  p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
4220  p3##_type p3, p4##_type p4, p5##_type p5) {\
4221  return name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
4222  p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
4223  }\
4224  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4225  typename p3##_type, typename p4##_type, typename p5##_type>\
4226  template <typename F>\
4227  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4228  typename arg3_type, typename arg4_type, typename arg5_type, \
4229  typename arg6_type, typename arg7_type, typename arg8_type, \
4230  typename arg9_type>\
4231  typename ::testing::internal::Function<F>::Result\
4232  name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
4233  p5##_type>::gmock_Impl<F>::gmock_PerformImpl(\
4234  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
4235 
4236 #define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\
4237  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4238  typename p3##_type, typename p4##_type, typename p5##_type, \
4239  typename p6##_type>\
4240  class name##ActionP7 {\
4241  public:\
4242  name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \
4243  p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
4244  p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
4245  p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
4246  p6(gmock_p6) {}\
4247  template <typename F>\
4248  class gmock_Impl : public ::testing::ActionInterface<F> {\
4249  public:\
4250  typedef F function_type;\
4251  typedef typename ::testing::internal::Function<F>::Result return_type;\
4252  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
4253  args_type;\
4254  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
4255  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
4256  p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
4257  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
4258  virtual return_type Perform(const args_type& args) {\
4259  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
4260  Perform(this, args);\
4261  }\
4262  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4263  typename arg3_type, typename arg4_type, typename arg5_type, \
4264  typename arg6_type, typename arg7_type, typename arg8_type, \
4265  typename arg9_type>\
4266  return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
4267  arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
4268  arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
4269  arg9_type arg9) const;\
4270  p0##_type p0;\
4271  p1##_type p1;\
4272  p2##_type p2;\
4273  p3##_type p3;\
4274  p4##_type p4;\
4275  p5##_type p5;\
4276  p6##_type p6;\
4277  private:\
4278  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
4279  };\
4280  template <typename F> operator ::testing::Action<F>() const {\
4281  return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
4282  p6));\
4283  }\
4284  p0##_type p0;\
4285  p1##_type p1;\
4286  p2##_type p2;\
4287  p3##_type p3;\
4288  p4##_type p4;\
4289  p5##_type p5;\
4290  p6##_type p6;\
4291  private:\
4292  GTEST_DISALLOW_ASSIGN_(name##ActionP7);\
4293  };\
4294  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4295  typename p3##_type, typename p4##_type, typename p5##_type, \
4296  typename p6##_type>\
4297  inline name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
4298  p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
4299  p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
4300  p6##_type p6) {\
4301  return name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
4302  p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
4303  }\
4304  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4305  typename p3##_type, typename p4##_type, typename p5##_type, \
4306  typename p6##_type>\
4307  template <typename F>\
4308  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4309  typename arg3_type, typename arg4_type, typename arg5_type, \
4310  typename arg6_type, typename arg7_type, typename arg8_type, \
4311  typename arg9_type>\
4312  typename ::testing::internal::Function<F>::Result\
4313  name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
4314  p5##_type, p6##_type>::gmock_Impl<F>::gmock_PerformImpl(\
4315  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
4316 
4317 #define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\
4318  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4319  typename p3##_type, typename p4##_type, typename p5##_type, \
4320  typename p6##_type, typename p7##_type>\
4321  class name##ActionP8 {\
4322  public:\
4323  name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \
4324  p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
4325  p5##_type gmock_p5, p6##_type gmock_p6, \
4326  p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
4327  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
4328  p7(gmock_p7) {}\
4329  template <typename F>\
4330  class gmock_Impl : public ::testing::ActionInterface<F> {\
4331  public:\
4332  typedef F function_type;\
4333  typedef typename ::testing::internal::Function<F>::Result return_type;\
4334  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
4335  args_type;\
4336  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
4337  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
4338  p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), \
4339  p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), \
4340  p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
4341  virtual return_type Perform(const args_type& args) {\
4342  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
4343  Perform(this, args);\
4344  }\
4345  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4346  typename arg3_type, typename arg4_type, typename arg5_type, \
4347  typename arg6_type, typename arg7_type, typename arg8_type, \
4348  typename arg9_type>\
4349  return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
4350  arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
4351  arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
4352  arg9_type arg9) const;\
4353  p0##_type p0;\
4354  p1##_type p1;\
4355  p2##_type p2;\
4356  p3##_type p3;\
4357  p4##_type p4;\
4358  p5##_type p5;\
4359  p6##_type p6;\
4360  p7##_type p7;\
4361  private:\
4362  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
4363  };\
4364  template <typename F> operator ::testing::Action<F>() const {\
4365  return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
4366  p6, p7));\
4367  }\
4368  p0##_type p0;\
4369  p1##_type p1;\
4370  p2##_type p2;\
4371  p3##_type p3;\
4372  p4##_type p4;\
4373  p5##_type p5;\
4374  p6##_type p6;\
4375  p7##_type p7;\
4376  private:\
4377  GTEST_DISALLOW_ASSIGN_(name##ActionP8);\
4378  };\
4379  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4380  typename p3##_type, typename p4##_type, typename p5##_type, \
4381  typename p6##_type, typename p7##_type>\
4382  inline name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
4383  p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
4384  p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
4385  p6##_type p6, p7##_type p7) {\
4386  return name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
4387  p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
4388  p6, p7);\
4389  }\
4390  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4391  typename p3##_type, typename p4##_type, typename p5##_type, \
4392  typename p6##_type, typename p7##_type>\
4393  template <typename F>\
4394  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4395  typename arg3_type, typename arg4_type, typename arg5_type, \
4396  typename arg6_type, typename arg7_type, typename arg8_type, \
4397  typename arg9_type>\
4398  typename ::testing::internal::Function<F>::Result\
4399  name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
4400  p5##_type, p6##_type, \
4401  p7##_type>::gmock_Impl<F>::gmock_PerformImpl(\
4402  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
4403 
4404 #define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\
4405  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4406  typename p3##_type, typename p4##_type, typename p5##_type, \
4407  typename p6##_type, typename p7##_type, typename p8##_type>\
4408  class name##ActionP9 {\
4409  public:\
4410  name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \
4411  p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
4412  p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
4413  p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
4414  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
4415  p8(gmock_p8) {}\
4416  template <typename F>\
4417  class gmock_Impl : public ::testing::ActionInterface<F> {\
4418  public:\
4419  typedef F function_type;\
4420  typedef typename ::testing::internal::Function<F>::Result return_type;\
4421  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
4422  args_type;\
4423  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
4424  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
4425  p6##_type gmock_p6, p7##_type gmock_p7, \
4426  p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
4427  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
4428  p7(gmock_p7), p8(gmock_p8) {}\
4429  virtual return_type Perform(const args_type& args) {\
4430  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
4431  Perform(this, args);\
4432  }\
4433  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4434  typename arg3_type, typename arg4_type, typename arg5_type, \
4435  typename arg6_type, typename arg7_type, typename arg8_type, \
4436  typename arg9_type>\
4437  return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
4438  arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
4439  arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
4440  arg9_type arg9) const;\
4441  p0##_type p0;\
4442  p1##_type p1;\
4443  p2##_type p2;\
4444  p3##_type p3;\
4445  p4##_type p4;\
4446  p5##_type p5;\
4447  p6##_type p6;\
4448  p7##_type p7;\
4449  p8##_type p8;\
4450  private:\
4451  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
4452  };\
4453  template <typename F> operator ::testing::Action<F>() const {\
4454  return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
4455  p6, p7, p8));\
4456  }\
4457  p0##_type p0;\
4458  p1##_type p1;\
4459  p2##_type p2;\
4460  p3##_type p3;\
4461  p4##_type p4;\
4462  p5##_type p5;\
4463  p6##_type p6;\
4464  p7##_type p7;\
4465  p8##_type p8;\
4466  private:\
4467  GTEST_DISALLOW_ASSIGN_(name##ActionP9);\
4468  };\
4469  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4470  typename p3##_type, typename p4##_type, typename p5##_type, \
4471  typename p6##_type, typename p7##_type, typename p8##_type>\
4472  inline name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
4473  p4##_type, p5##_type, p6##_type, p7##_type, \
4474  p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
4475  p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
4476  p8##_type p8) {\
4477  return name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
4478  p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
4479  p3, p4, p5, p6, p7, p8);\
4480  }\
4481  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4482  typename p3##_type, typename p4##_type, typename p5##_type, \
4483  typename p6##_type, typename p7##_type, typename p8##_type>\
4484  template <typename F>\
4485  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4486  typename arg3_type, typename arg4_type, typename arg5_type, \
4487  typename arg6_type, typename arg7_type, typename arg8_type, \
4488  typename arg9_type>\
4489  typename ::testing::internal::Function<F>::Result\
4490  name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
4491  p5##_type, p6##_type, p7##_type, \
4492  p8##_type>::gmock_Impl<F>::gmock_PerformImpl(\
4493  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
4494 
4495 #define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\
4496  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4497  typename p3##_type, typename p4##_type, typename p5##_type, \
4498  typename p6##_type, typename p7##_type, typename p8##_type, \
4499  typename p9##_type>\
4500  class name##ActionP10 {\
4501  public:\
4502  name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \
4503  p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
4504  p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
4505  p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
4506  p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
4507  p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
4508  template <typename F>\
4509  class gmock_Impl : public ::testing::ActionInterface<F> {\
4510  public:\
4511  typedef F function_type;\
4512  typedef typename ::testing::internal::Function<F>::Result return_type;\
4513  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
4514  args_type;\
4515  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
4516  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
4517  p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
4518  p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
4519  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
4520  p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
4521  virtual return_type Perform(const args_type& args) {\
4522  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
4523  Perform(this, args);\
4524  }\
4525  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4526  typename arg3_type, typename arg4_type, typename arg5_type, \
4527  typename arg6_type, typename arg7_type, typename arg8_type, \
4528  typename arg9_type>\
4529  return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
4530  arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
4531  arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
4532  arg9_type arg9) const;\
4533  p0##_type p0;\
4534  p1##_type p1;\
4535  p2##_type p2;\
4536  p3##_type p3;\
4537  p4##_type p4;\
4538  p5##_type p5;\
4539  p6##_type p6;\
4540  p7##_type p7;\
4541  p8##_type p8;\
4542  p9##_type p9;\
4543  private:\
4544  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
4545  };\
4546  template <typename F> operator ::testing::Action<F>() const {\
4547  return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
4548  p6, p7, p8, p9));\
4549  }\
4550  p0##_type p0;\
4551  p1##_type p1;\
4552  p2##_type p2;\
4553  p3##_type p3;\
4554  p4##_type p4;\
4555  p5##_type p5;\
4556  p6##_type p6;\
4557  p7##_type p7;\
4558  p8##_type p8;\
4559  p9##_type p9;\
4560  private:\
4561  GTEST_DISALLOW_ASSIGN_(name##ActionP10);\
4562  };\
4563  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4564  typename p3##_type, typename p4##_type, typename p5##_type, \
4565  typename p6##_type, typename p7##_type, typename p8##_type, \
4566  typename p9##_type>\
4567  inline name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
4568  p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
4569  p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
4570  p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
4571  p9##_type p9) {\
4572  return name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
4573  p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
4574  p1, p2, p3, p4, p5, p6, p7, p8, p9);\
4575  }\
4576  template <typename p0##_type, typename p1##_type, typename p2##_type, \
4577  typename p3##_type, typename p4##_type, typename p5##_type, \
4578  typename p6##_type, typename p7##_type, typename p8##_type, \
4579  typename p9##_type>\
4580  template <typename F>\
4581  template <typename arg0_type, typename arg1_type, typename arg2_type, \
4582  typename arg3_type, typename arg4_type, typename arg5_type, \
4583  typename arg6_type, typename arg7_type, typename arg8_type, \
4584  typename arg9_type>\
4585  typename ::testing::internal::Function<F>::Result\
4586  name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
4587  p5##_type, p6##_type, p7##_type, p8##_type, \
4588  p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\
4589  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
4590 
4591 namespace testing
4592 {
4593 
4594 // The ACTION*() macros trigger warning C4100 (unreferenced formal
4595 // parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
4596 // the macro definition, as the warnings are generated when the macro
4597 // is expanded and macro expansion cannot contain #pragma. Therefore
4598 // we suppress them here.
4599 #ifdef _MSC_VER
4600 # pragma warning(push)
4601 # pragma warning(disable:4100)
4602 #endif
4603 
4604 // Various overloads for InvokeArgument<N>().
4605 //
4606 // The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
4607 // (0-based) argument, which must be a k-ary callable, of the mock
4608 // function, with arguments a1, a2, ..., a_k.
4609 //
4610 // Notes:
4611 //
4612 // 1. The arguments are passed by value by default. If you need to
4613 // pass an argument by reference, wrap it inside ByRef(). For
4614 // example,
4615 //
4616 // InvokeArgument<1>(5, string("Hello"), ByRef(foo))
4617 //
4618 // passes 5 and string("Hello") by value, and passes foo by
4619 // reference.
4620 //
4621 // 2. If the callable takes an argument by reference but ByRef() is
4622 // not used, it will receive the reference to a copy of the value,
4623 // instead of the original value. For example, when the 0-th
4624 // argument of the mock function takes a const string&, the action
4625 //
4626 // InvokeArgument<0>(string("Hello"))
4627 //
4628 // makes a copy of the temporary string("Hello") object and passes a
4629 // reference of the copy, instead of the original temporary object,
4630 // to the callable. This makes it easy for a user to define an
4631 // InvokeArgument action from temporary values and have it performed
4632 // later.
4633 
4634 ACTION_TEMPLATE(InvokeArgument,
4635  HAS_1_TEMPLATE_PARAMS(int, k),
4636  AND_0_VALUE_PARAMS())
4637 {
4639  ::std::tr1::get<k>(args));
4640 }
4641 
4642 ACTION_TEMPLATE(InvokeArgument,
4643  HAS_1_TEMPLATE_PARAMS(int, k),
4644  AND_1_VALUE_PARAMS(p0))
4645 {
4647  ::std::tr1::get<k>(args), p0);
4648 }
4649 
4650 ACTION_TEMPLATE(InvokeArgument,
4651  HAS_1_TEMPLATE_PARAMS(int, k),
4652  AND_2_VALUE_PARAMS(p0, p1))
4653 {
4655  ::std::tr1::get<k>(args), p0, p1);
4656 }
4657 
4658 ACTION_TEMPLATE(InvokeArgument,
4659  HAS_1_TEMPLATE_PARAMS(int, k),
4660  AND_3_VALUE_PARAMS(p0, p1, p2))
4661 {
4663  ::std::tr1::get<k>(args), p0, p1, p2);
4664 }
4665 
4666 ACTION_TEMPLATE(InvokeArgument,
4667  HAS_1_TEMPLATE_PARAMS(int, k),
4668  AND_4_VALUE_PARAMS(p0, p1, p2, p3))
4669 {
4671  ::std::tr1::get<k>(args), p0, p1, p2, p3);
4672 }
4673 
4674 ACTION_TEMPLATE(InvokeArgument,
4675  HAS_1_TEMPLATE_PARAMS(int, k),
4676  AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4))
4677 {
4679  ::std::tr1::get<k>(args), p0, p1, p2, p3, p4);
4680 }
4681 
4682 ACTION_TEMPLATE(InvokeArgument,
4683  HAS_1_TEMPLATE_PARAMS(int, k),
4684  AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5))
4685 {
4687  ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5);
4688 }
4689 
4690 ACTION_TEMPLATE(InvokeArgument,
4691  HAS_1_TEMPLATE_PARAMS(int, k),
4692  AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6))
4693 {
4695  ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
4696 }
4697 
4698 ACTION_TEMPLATE(InvokeArgument,
4699  HAS_1_TEMPLATE_PARAMS(int, k),
4700  AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7))
4701 {
4703  ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
4704 }
4705 
4706 ACTION_TEMPLATE(InvokeArgument,
4707  HAS_1_TEMPLATE_PARAMS(int, k),
4708  AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8))
4709 {
4711  ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);
4712 }
4713 
4714 ACTION_TEMPLATE(InvokeArgument,
4715  HAS_1_TEMPLATE_PARAMS(int, k),
4716  AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9))
4717 {
4719  ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
4720 }
4721 
4722 // Various overloads for ReturnNew<T>().
4723 //
4724 // The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new
4725 // instance of type T, constructed on the heap with constructor arguments
4726 // a1, a2, ..., and a_k. The caller assumes ownership of the returned value.
4728  HAS_1_TEMPLATE_PARAMS(typename, T),
4729  AND_0_VALUE_PARAMS())
4730 {
4731  return new T();
4732 }
4733 
4735  HAS_1_TEMPLATE_PARAMS(typename, T),
4736  AND_1_VALUE_PARAMS(p0))
4737 {
4738  return new T(p0);
4739 }
4740 
4742  HAS_1_TEMPLATE_PARAMS(typename, T),
4743  AND_2_VALUE_PARAMS(p0, p1))
4744 {
4745  return new T(p0, p1);
4746 }
4747 
4749  HAS_1_TEMPLATE_PARAMS(typename, T),
4750  AND_3_VALUE_PARAMS(p0, p1, p2))
4751 {
4752  return new T(p0, p1, p2);
4753 }
4754 
4756  HAS_1_TEMPLATE_PARAMS(typename, T),
4757  AND_4_VALUE_PARAMS(p0, p1, p2, p3))
4758 {
4759  return new T(p0, p1, p2, p3);
4760 }
4761 
4763  HAS_1_TEMPLATE_PARAMS(typename, T),
4764  AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4))
4765 {
4766  return new T(p0, p1, p2, p3, p4);
4767 }
4768 
4770  HAS_1_TEMPLATE_PARAMS(typename, T),
4771  AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5))
4772 {
4773  return new T(p0, p1, p2, p3, p4, p5);
4774 }
4775 
4777  HAS_1_TEMPLATE_PARAMS(typename, T),
4778  AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6))
4779 {
4780  return new T(p0, p1, p2, p3, p4, p5, p6);
4781 }
4782 
4784  HAS_1_TEMPLATE_PARAMS(typename, T),
4785  AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7))
4786 {
4787  return new T(p0, p1, p2, p3, p4, p5, p6, p7);
4788 }
4789 
4791  HAS_1_TEMPLATE_PARAMS(typename, T),
4792  AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8))
4793 {
4794  return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8);
4795 }
4796 
4798  HAS_1_TEMPLATE_PARAMS(typename, T),
4799  AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9))
4800 {
4801  return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
4802 }
4803 
4804 #ifdef _MSC_VER
4805 # pragma warning(pop)
4806 #endif
4807 
4808 } // namespace testing
4809 
4810 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
4811 // This file was GENERATED by command:
4812 // pump.py gmock-generated-function-mockers.h.pump
4813 // DO NOT EDIT BY HAND!!!
4814 
4815 // Copyright 2007, Google Inc.
4816 // All rights reserved.
4817 //
4818 // Redistribution and use in source and binary forms, with or without
4819 // modification, are permitted provided that the following conditions are
4820 // met:
4821 //
4822 // * Redistributions of source code must retain the above copyright
4823 // notice, this list of conditions and the following disclaimer.
4824 // * Redistributions in binary form must reproduce the above
4825 // copyright notice, this list of conditions and the following disclaimer
4826 // in the documentation and/or other materials provided with the
4827 // distribution.
4828 // * Neither the name of Google Inc. nor the names of its
4829 // contributors may be used to endorse or promote products derived from
4830 // this software without specific prior written permission.
4831 //
4832 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4833 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4834 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4835 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4836 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4837 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4838 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4839 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4840 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4841 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4842 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4843 //
4844 // Author: wan@google.com (Zhanyong Wan)
4845 
4846 // Google Mock - a framework for writing C++ mock classes.
4847 //
4848 // This file implements function mockers of various arities.
4849 
4850 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
4851 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
4852 
4853 // Copyright 2007, Google Inc.
4854 // All rights reserved.
4855 //
4856 // Redistribution and use in source and binary forms, with or without
4857 // modification, are permitted provided that the following conditions are
4858 // met:
4859 //
4860 // * Redistributions of source code must retain the above copyright
4861 // notice, this list of conditions and the following disclaimer.
4862 // * Redistributions in binary form must reproduce the above
4863 // copyright notice, this list of conditions and the following disclaimer
4864 // in the documentation and/or other materials provided with the
4865 // distribution.
4866 // * Neither the name of Google Inc. nor the names of its
4867 // contributors may be used to endorse or promote products derived from
4868 // this software without specific prior written permission.
4869 //
4870 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4871 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4872 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4873 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4874 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4875 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4876 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4877 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4878 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4879 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4880 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4881 //
4882 // Author: wan@google.com (Zhanyong Wan)
4883 
4884 // Google Mock - a framework for writing C++ mock classes.
4885 //
4886 // This file implements the ON_CALL() and EXPECT_CALL() macros.
4887 //
4888 // A user can use the ON_CALL() macro to specify the default action of
4889 // a mock method. The syntax is:
4890 //
4891 // ON_CALL(mock_object, Method(argument-matchers))
4892 // .With(multi-argument-matcher)
4893 // .WillByDefault(action);
4894 //
4895 // where the .With() clause is optional.
4896 //
4897 // A user can use the EXPECT_CALL() macro to specify an expectation on
4898 // a mock method. The syntax is:
4899 //
4900 // EXPECT_CALL(mock_object, Method(argument-matchers))
4901 // .With(multi-argument-matchers)
4902 // .Times(cardinality)
4903 // .InSequence(sequences)
4904 // .After(expectations)
4905 // .WillOnce(action)
4906 // .WillRepeatedly(action)
4907 // .RetiresOnSaturation();
4908 //
4909 // where all clauses are optional, and .InSequence()/.After()/
4910 // .WillOnce() can appear any number of times.
4911 
4912 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
4913 #define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
4914 
4915 #include <map>
4916 #include <set>
4917 #include <sstream>
4918 #include <string>
4919 #include <vector>
4920 
4921 #if GTEST_HAS_EXCEPTIONS
4922 # include <stdexcept> // NOLINT
4923 #endif
4924 
4925 // Copyright 2007, Google Inc.
4926 // All rights reserved.
4927 //
4928 // Redistribution and use in source and binary forms, with or without
4929 // modification, are permitted provided that the following conditions are
4930 // met:
4931 //
4932 // * Redistributions of source code must retain the above copyright
4933 // notice, this list of conditions and the following disclaimer.
4934 // * Redistributions in binary form must reproduce the above
4935 // copyright notice, this list of conditions and the following disclaimer
4936 // in the documentation and/or other materials provided with the
4937 // distribution.
4938 // * Neither the name of Google Inc. nor the names of its
4939 // contributors may be used to endorse or promote products derived from
4940 // this software without specific prior written permission.
4941 //
4942 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4943 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4944 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4945 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4946 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4947 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4948 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4949 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4950 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4951 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4952 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4953 //
4954 // Author: wan@google.com (Zhanyong Wan)
4955 
4956 // Google Mock - a framework for writing C++ mock classes.
4957 //
4958 // This file implements some commonly used argument matchers. More
4959 // matchers can be defined by the user implementing the
4960 // MatcherInterface<T> interface if necessary.
4961 
4962 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
4963 #define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
4964 
4965 #include <math.h>
4966 #include <algorithm>
4967 #include <iterator>
4968 #include <limits>
4969 #include <ostream> // NOLINT
4970 #include <sstream>
4971 #include <string>
4972 #include <utility>
4973 #include <vector>
4974 
4975 
4976 #if GTEST_LANG_CXX11
4977 #include <initializer_list> // NOLINT -- must be after gtest.h
4978 #endif
4979 
4980 namespace testing
4981 {
4982 
4983 // To implement a matcher Foo for type T, define:
4984 // 1. a class FooMatcherImpl that implements the
4985 // MatcherInterface<T> interface, and
4986 // 2. a factory function that creates a Matcher<T> object from a
4987 // FooMatcherImpl*.
4988 //
4989 // The two-level delegation design makes it possible to allow a user
4990 // to write "v" instead of "Eq(v)" where a Matcher is expected, which
4991 // is impossible if we pass matchers by pointers. It also eases
4992 // ownership management as Matcher objects can now be copied like
4993 // plain values.
4994 
4995 // MatchResultListener is an abstract class. Its << operator can be
4996 // used by a matcher to explain why a value matches or doesn't match.
4997 //
4998 // TODO(wan@google.com): add method
4999 // bool InterestedInWhy(bool result) const;
5000 // to indicate whether the listener is interested in why the match
5001 // result is 'result'.
5003 {
5004 public:
5005  // Creates a listener object with the given underlying ostream. The
5006  // listener does not own the ostream, and does not dereference it
5007  // in the constructor or destructor.
5008  explicit MatchResultListener(::std::ostream * os) : stream_(os) {}
5009  virtual ~MatchResultListener() = 0; // Makes this class abstract.
5010 
5011  // Streams x to the underlying ostream; does nothing if the ostream
5012  // is NULL.
5013  template <typename T>
5015  {
5016  if (stream_ != NULL)
5017  { *stream_ << x; }
5018 
5019  return *this;
5020  }
5021 
5022  // Returns the underlying ostream.
5023  ::std::ostream * stream() { return stream_; }
5024 
5025  // Returns true iff the listener is interested in an explanation of
5026  // the match result. A matcher's MatchAndExplain() method can use
5027  // this information to avoid generating the explanation when no one
5028  // intends to hear it.
5029  bool IsInterested() const { return stream_ != NULL; }
5030 
5031 private:
5032  ::std::ostream * const stream_;
5033 
5035 };
5036 
5038 {
5039 }
5040 
5041 // An instance of a subclass of this knows how to describe itself as a
5042 // matcher.
5044 {
5045 public:
5047 
5048  // Describes this matcher to an ostream. The function should print
5049  // a verb phrase that describes the property a value matching this
5050  // matcher should have. The subject of the verb phrase is the value
5051  // being matched. For example, the DescribeTo() method of the Gt(7)
5052  // matcher prints "is greater than 7".
5053  virtual void DescribeTo(::std::ostream * os) const = 0;
5054 
5055  // Describes the negation of this matcher to an ostream. For
5056  // example, if the description of this matcher is "is greater than
5057  // 7", the negated description could be "is not greater than 7".
5058  // You are not required to override this when implementing
5059  // MatcherInterface, but it is highly advised so that your matcher
5060  // can produce good error messages.
5061  virtual void DescribeNegationTo(::std::ostream * os) const
5062  {
5063  *os << "not (";
5064  DescribeTo(os);
5065  *os << ")";
5066  }
5067 };
5068 
5069 // The implementation of a matcher.
5070 template <typename T>
5072 {
5073 public:
5074  // Returns true iff the matcher matches x; also explains the match
5075  // result to 'listener' if necessary (see the next paragraph), in
5076  // the form of a non-restrictive relative clause ("which ...",
5077  // "whose ...", etc) that describes x. For example, the
5078  // MatchAndExplain() method of the Pointee(...) matcher should
5079  // generate an explanation like "which points to ...".
5080  //
5081  // Implementations of MatchAndExplain() should add an explanation of
5082  // the match result *if and only if* they can provide additional
5083  // information that's not already present (or not obvious) in the
5084  // print-out of x and the matcher's description. Whether the match
5085  // succeeds is not a factor in deciding whether an explanation is
5086  // needed, as sometimes the caller needs to print a failure message
5087  // when the match succeeds (e.g. when the matcher is used inside
5088  // Not()).
5089  //
5090  // For example, a "has at least 10 elements" matcher should explain
5091  // what the actual element count is, regardless of the match result,
5092  // as it is useful information to the reader; on the other hand, an
5093  // "is empty" matcher probably only needs to explain what the actual
5094  // size is when the match fails, as it's redundant to say that the
5095  // size is 0 when the value is already known to be empty.
5096  //
5097  // You should override this method when defining a new matcher.
5098  //
5099  // It's the responsibility of the caller (Google Mock) to guarantee
5100  // that 'listener' is not NULL. This helps to simplify a matcher's
5101  // implementation when it doesn't care about the performance, as it
5102  // can talk to 'listener' without checking its validity first.
5103  // However, in order to implement dummy listeners efficiently,
5104  // listener->stream() may be NULL.
5105  virtual bool MatchAndExplain(T x, MatchResultListener * listener) const = 0;
5106 
5107  // Inherits these methods from MatcherDescriberInterface:
5108  // virtual void DescribeTo(::std::ostream* os) const = 0;
5109  // virtual void DescribeNegationTo(::std::ostream* os) const;
5110 };
5111 
5112 // A match result listener that stores the explanation in a string.
5114 {
5115 public:
5117 
5118  // Returns the explanation accumulated so far.
5119  internal::string str() const { return ss_.str(); }
5120 
5121  // Clears the explanation accumulated so far.
5122  void Clear() { ss_.str(""); }
5123 
5124 private:
5125  ::std::stringstream ss_;
5126 
5128 };
5129 
5130 namespace internal
5131 {
5132 
5133 // A match result listener that ignores the explanation.
5135 {
5136 public:
5138 
5139 private:
5141 };
5142 
5143 // A match result listener that forwards the explanation to a given
5144 // ostream. The difference between this and MatchResultListener is
5145 // that the former is concrete.
5147 {
5148 public:
5149  explicit StreamMatchResultListener(::std::ostream * os)
5150  : MatchResultListener(os) {}
5151 
5152 private:
5154 };
5155 
5156 // An internal class for implementing Matcher<T>, which will derive
5157 // from it. We put functionalities common to all Matcher<T>
5158 // specializations here to avoid code duplication.
5159 template <typename T>
5161 {
5162 public:
5163  // Returns true iff the matcher matches x; also explains the match
5164  // result to 'listener'.
5165  bool MatchAndExplain(T x, MatchResultListener * listener) const
5166  {
5167  return impl_->MatchAndExplain(x, listener);
5168  }
5169 
5170  // Returns true iff this matcher matches x.
5171  bool Matches(T x) const
5172  {
5174  return MatchAndExplain(x, &dummy);
5175  }
5176 
5177  // Describes this matcher to an ostream.
5178  void DescribeTo(::std::ostream * os) const { impl_->DescribeTo(os); }
5179 
5180  // Describes the negation of this matcher to an ostream.
5181  void DescribeNegationTo(::std::ostream * os) const
5182  {
5183  impl_->DescribeNegationTo(os);
5184  }
5185 
5186  // Explains why x matches, or doesn't match, the matcher.
5187  void ExplainMatchResultTo(T x, ::std::ostream * os) const
5188  {
5189  StreamMatchResultListener listener(os);
5190  MatchAndExplain(x, &listener);
5191  }
5192 
5193  // Returns the describer for this matcher object; retains ownership
5194  // of the describer, which is only guaranteed to be alive when
5195  // this matcher object is alive.
5197  {
5198  return impl_.get();
5199  }
5200 
5201 protected:
5203 
5204  // Constructs a matcher from its implementation.
5205  explicit MatcherBase(const MatcherInterface<T> * impl)
5206  : impl_(impl) {}
5207 
5208  virtual ~MatcherBase() {}
5209 
5210 private:
5211  // shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar
5212  // interfaces. The former dynamically allocates a chunk of memory
5213  // to hold the reference count, while the latter tracks all
5214  // references using a circular linked list without allocating
5215  // memory. It has been observed that linked_ptr performs better in
5216  // typical scenarios. However, shared_ptr can out-perform
5217  // linked_ptr when there are many more uses of the copy constructor
5218  // than the default constructor.
5219  //
5220  // If performance becomes a problem, we should see if using
5221  // shared_ptr helps.
5223 };
5224 
5225 } // namespace internal
5226 
5227 // A Matcher<T> is a copyable and IMMUTABLE (except by assignment)
5228 // object that can check whether a value of type T matches. The
5229 // implementation of Matcher<T> is just a linked_ptr to const
5230 // MatcherInterface<T>, so copying is fairly cheap. Don't inherit
5231 // from Matcher!
5232 template <typename T>
5233 class Matcher : public internal::MatcherBase<T>
5234 {
5235 public:
5236  // Constructs a null matcher. Needed for storing Matcher objects in STL
5237  // containers. A default-constructed matcher is not yet initialized. You
5238  // cannot use it until a valid value has been assigned to it.
5239  Matcher() {}
5240 
5241  // Constructs a matcher from its implementation.
5242  explicit Matcher(const MatcherInterface<T> * impl)
5243  : internal::MatcherBase<T>(impl) {}
5244 
5245  // Implicit constructor here allows people to write
5246  // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes
5247  Matcher(T value); // NOLINT
5248 };
5249 
5250 // The following two specializations allow the user to write str
5251 // instead of Eq(str) and "foo" instead of Eq("foo") when a string
5252 // matcher is expected.
5253 template <>
5254 class GTEST_API_ Matcher<const internal::string &>
5255  : public internal::MatcherBase<const internal::string &>
5256 {
5257 public:
5258  Matcher() {}
5259 
5261  : internal::MatcherBase<const internal::string & >(impl) {}
5262 
5263  // Allows the user to write str instead of Eq(str) sometimes, where
5264  // str is a string object.
5265  Matcher(const internal::string & s); // NOLINT
5266 
5267  // Allows the user to write "foo" instead of Eq("foo") sometimes.
5268  Matcher(const char * s); // NOLINT
5269 };
5270 
5271 template <>
5272 class GTEST_API_ Matcher<internal::string>
5273  : public internal::MatcherBase<internal::string>
5274 {
5275 public:
5276  Matcher() {}
5277 
5279  : internal::MatcherBase<internal::string>(impl) {}
5280 
5281  // Allows the user to write str instead of Eq(str) sometimes, where
5282  // str is a string object.
5283  Matcher(const internal::string & s); // NOLINT
5284 
5285  // Allows the user to write "foo" instead of Eq("foo") sometimes.
5286  Matcher(const char * s); // NOLINT
5287 };
5288 
5289 #if GTEST_HAS_STRING_PIECE_
5290 // The following two specializations allow the user to write str
5291 // instead of Eq(str) and "foo" instead of Eq("foo") when a StringPiece
5292 // matcher is expected.
5293 template <>
5294 class GTEST_API_ Matcher<const StringPiece &>
5296 {
5297 public:
5298  Matcher() {}
5299 
5300  explicit Matcher(const MatcherInterface<const StringPiece &> * impl)
5302 
5303  // Allows the user to write str instead of Eq(str) sometimes, where
5304  // str is a string object.
5305  Matcher(const internal::string & s); // NOLINT
5306 
5307  // Allows the user to write "foo" instead of Eq("foo") sometimes.
5308  Matcher(const char * s); // NOLINT
5309 
5310  // Allows the user to pass StringPieces directly.
5311  Matcher(StringPiece s); // NOLINT
5312 };
5313 
5314 template <>
5315 class GTEST_API_ Matcher<StringPiece>
5316  : public internal::MatcherBase<StringPiece>
5317 {
5318 public:
5319  Matcher() {}
5320 
5321  explicit Matcher(const MatcherInterface<StringPiece> * impl)
5323 
5324  // Allows the user to write str instead of Eq(str) sometimes, where
5325  // str is a string object.
5326  Matcher(const internal::string & s); // NOLINT
5327 
5328  // Allows the user to write "foo" instead of Eq("foo") sometimes.
5329  Matcher(const char * s); // NOLINT
5330 
5331  // Allows the user to pass StringPieces directly.
5332  Matcher(StringPiece s); // NOLINT
5333 };
5334 #endif // GTEST_HAS_STRING_PIECE_
5335 
5336 // The PolymorphicMatcher class template makes it easy to implement a
5337 // polymorphic matcher (i.e. a matcher that can match values of more
5338 // than one type, e.g. Eq(n) and NotNull()).
5339 //
5340 // To define a polymorphic matcher, a user should provide an Impl
5341 // class that has a DescribeTo() method and a DescribeNegationTo()
5342 // method, and define a member function (or member function template)
5343 //
5344 // bool MatchAndExplain(const Value& value,
5345 // MatchResultListener* listener) const;
5346 //
5347 // See the definition of NotNull() for a complete example.
5348 template <class Impl>
5350 {
5351 public:
5352  explicit PolymorphicMatcher(const Impl & an_impl) : impl_(an_impl) {}
5353 
5354  // Returns a mutable reference to the underlying matcher
5355  // implementation object.
5356  Impl & mutable_impl() { return impl_; }
5357 
5358  // Returns an immutable reference to the underlying matcher
5359  // implementation object.
5360  const Impl & impl() const { return impl_; }
5361 
5362  template <typename T>
5363  operator Matcher<T>() const
5364  {
5365  return Matcher<T>(new MonomorphicImpl<T>(impl_));
5366  }
5367 
5368 private:
5369  template <typename T>
5371  {
5372  public:
5373  explicit MonomorphicImpl(const Impl & impl) : impl_(impl) {}
5374 
5375  virtual void DescribeTo(::std::ostream * os) const
5376  {
5377  impl_.DescribeTo(os);
5378  }
5379 
5380  virtual void DescribeNegationTo(::std::ostream * os) const
5381  {
5382  impl_.DescribeNegationTo(os);
5383  }
5384 
5385  virtual bool MatchAndExplain(T x, MatchResultListener * listener) const
5386  {
5387  return impl_.MatchAndExplain(x, listener);
5388  }
5389 
5390  private:
5391  const Impl impl_;
5392 
5394  };
5395 
5396  Impl impl_;
5397 
5399 };
5400 
5401 // Creates a matcher from its implementation. This is easier to use
5402 // than the Matcher<T> constructor as it doesn't require you to
5403 // explicitly write the template argument, e.g.
5404 //
5405 // MakeMatcher(foo);
5406 // vs
5407 // Matcher<const string&>(foo);
5408 template <typename T>
5410 {
5411  return Matcher<T>(impl);
5412 }
5413 
5414 // Creates a polymorphic matcher from its implementation. This is
5415 // easier to use than the PolymorphicMatcher<Impl> constructor as it
5416 // doesn't require you to explicitly write the template argument, e.g.
5417 //
5418 // MakePolymorphicMatcher(foo);
5419 // vs
5420 // PolymorphicMatcher<TypeOfFoo>(foo);
5421 template <class Impl>
5423 {
5424  return PolymorphicMatcher<Impl>(impl);
5425 }
5426 
5427 // Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
5428 // and MUST NOT BE USED IN USER CODE!!!
5429 namespace internal
5430 {
5431 
5432 // The MatcherCastImpl class template is a helper for implementing
5433 // MatcherCast(). We need this helper in order to partially
5434 // specialize the implementation of MatcherCast() (C++ allows
5435 // class/struct templates to be partially specialized, but not
5436 // function templates.).
5437 
5438 // This general version is used when MatcherCast()'s argument is a
5439 // polymorphic matcher (i.e. something that can be converted to a
5440 // Matcher but is not one yet; for example, Eq(value)) or a value (for
5441 // example, "hello").
5442 template <typename T, typename M>
5444 {
5445 public:
5446  static Matcher<T> Cast(M polymorphic_matcher_or_value)
5447  {
5448  // M can be a polymorhic matcher, in which case we want to use
5449  // its conversion operator to create Matcher<T>. Or it can be a value
5450  // that should be passed to the Matcher<T>'s constructor.
5451  //
5452  // We can't call Matcher<T>(polymorphic_matcher_or_value) when M is a
5453  // polymorphic matcher because it'll be ambiguous if T has an implicit
5454  // constructor from M (this usually happens when T has an implicit
5455  // constructor from any type).
5456  //
5457  // It won't work to unconditionally implict_cast
5458  // polymorphic_matcher_or_value to Matcher<T> because it won't trigger
5459  // a user-defined conversion from M to T if one exists (assuming M is
5460  // a value).
5461  return CastImpl(
5462  polymorphic_matcher_or_value,
5463  BooleanConstant <
5464  internal::ImplicitlyConvertible<M, Matcher<T> >::value > ());
5465  }
5466 
5467 private:
5469  {
5470  // M can't be implicitly converted to Matcher<T>, so M isn't a polymorphic
5471  // matcher. It must be a value then. Use direct initialization to create
5472  // a matcher.
5473  return Matcher<T>(ImplicitCast_<T>(value));
5474  }
5475 
5476  static Matcher<T> CastImpl(M polymorphic_matcher_or_value,
5478  {
5479  // M is implicitly convertible to Matcher<T>, which means that either
5480  // M is a polymorhpic matcher or Matcher<T> has an implicit constructor
5481  // from M. In both cases using the implicit conversion will produce a
5482  // matcher.
5483  //
5484  // Even if T has an implicit constructor from M, it won't be called because
5485  // creating Matcher<T> would require a chain of two user-defined conversions
5486  // (first to create T from M and then to create Matcher<T> from T).
5487  return polymorphic_matcher_or_value;
5488  }
5489 };
5490 
5491 // This more specialized version is used when MatcherCast()'s argument
5492 // is already a Matcher. This only compiles when type T can be
5493 // statically converted to type U.
5494 template <typename T, typename U>
5495 class MatcherCastImpl<T, Matcher<U> >
5496 {
5497 public:
5498  static Matcher<T> Cast(const Matcher<U> & source_matcher)
5499  {
5500  return Matcher<T>(new Impl(source_matcher));
5501  }
5502 
5503 private:
5504  class Impl : public MatcherInterface<T>
5505  {
5506  public:
5507  explicit Impl(const Matcher<U> & source_matcher)
5508  : source_matcher_(source_matcher) {}
5509 
5510  // We delegate the matching logic to the source matcher.
5511  virtual bool MatchAndExplain(T x, MatchResultListener * listener) const
5512  {
5513  return source_matcher_.MatchAndExplain(static_cast<U>(x), listener);
5514  }
5515 
5516  virtual void DescribeTo(::std::ostream * os) const
5517  {
5518  source_matcher_.DescribeTo(os);
5519  }
5520 
5521  virtual void DescribeNegationTo(::std::ostream * os) const
5522  {
5523  source_matcher_.DescribeNegationTo(os);
5524  }
5525 
5526  private:
5528 
5529  GTEST_DISALLOW_ASSIGN_(Impl);
5530  };
5531 };
5532 
5533 // This even more specialized version is used for efficiently casting
5534 // a matcher to its own type.
5535 template <typename T>
5536 class MatcherCastImpl<T, Matcher<T> >
5537 {
5538 public:
5539  static Matcher<T> Cast(const Matcher<T> & matcher) { return matcher; }
5540 };
5541 
5542 } // namespace internal
5543 
5544 // In order to be safe and clear, casting between different matcher
5545 // types is done explicitly via MatcherCast<T>(m), which takes a
5546 // matcher m and returns a Matcher<T>. It compiles only when T can be
5547 // statically converted to the argument type of m.
5548 template <typename T, typename M>
5549 inline Matcher<T> MatcherCast(M matcher)
5550 {
5551  return internal::MatcherCastImpl<T, M>::Cast(matcher);
5552 }
5553 
5554 // Implements SafeMatcherCast().
5555 //
5556 // We use an intermediate class to do the actual safe casting as Nokia's
5557 // Symbian compiler cannot decide between
5558 // template <T, M> ... (M) and
5559 // template <T, U> ... (const Matcher<U>&)
5560 // for function templates but can for member function templates.
5561 template <typename T>
5563 {
5564 public:
5565  // This overload handles polymorphic matchers and values only since
5566  // monomorphic matchers are handled by the next one.
5567  template <typename M>
5568  static inline Matcher<T> Cast(M polymorphic_matcher_or_value)
5569  {
5570  return internal::MatcherCastImpl<T, M>::Cast(polymorphic_matcher_or_value);
5571  }
5572 
5573  // This overload handles monomorphic matchers.
5574  //
5575  // In general, if type T can be implicitly converted to type U, we can
5576  // safely convert a Matcher<U> to a Matcher<T> (i.e. Matcher is
5577  // contravariant): just keep a copy of the original Matcher<U>, convert the
5578  // argument from type T to U, and then pass it to the underlying Matcher<U>.
5579  // The only exception is when U is a reference and T is not, as the
5580  // underlying Matcher<U> may be interested in the argument's address, which
5581  // is not preserved in the conversion from T to U.
5582  template <typename U>
5583  static inline Matcher<T> Cast(const Matcher<U> & matcher)
5584  {
5585  // Enforce that T can be implicitly converted to U.
5587  T_must_be_implicitly_convertible_to_U);
5588  // Enforce that we are not converting a non-reference type T to a reference
5589  // type U.
5592  cannot_convert_non_referentce_arg_to_reference);
5593  // In case both T and U are arithmetic types, enforce that the
5594  // conversion is not lossy.
5595  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(T) RawT;
5596  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(U) RawU;
5597  const bool kTIsOther = GMOCK_KIND_OF_(RawT) == internal::kOther;
5598  const bool kUIsOther = GMOCK_KIND_OF_(RawU) == internal::kOther;
5600  kTIsOther || kUIsOther ||
5601  (internal::LosslessArithmeticConvertible<RawT, RawU>::value),
5602  conversion_of_arithmetic_types_must_be_lossless);
5603  return MatcherCast<T>(matcher);
5604  }
5605 };
5606 
5607 template <typename T, typename M>
5608 inline Matcher<T> SafeMatcherCast(const M & polymorphic_matcher)
5609 {
5610  return SafeMatcherCastImpl<T>::Cast(polymorphic_matcher);
5611 }
5612 
5613 // A<T>() returns a matcher that matches any value of type T.
5614 template <typename T>
5615 Matcher<T> A();
5616 
5617 // Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
5618 // and MUST NOT BE USED IN USER CODE!!!
5619 namespace internal
5620 {
5621 
5622 // If the explanation is not empty, prints it to the ostream.
5623 inline void PrintIfNotEmpty(const internal::string & explanation,
5624  ::std::ostream * os)
5625 {
5626  if (explanation != "" && os != NULL)
5627  {
5628  *os << ", " << explanation;
5629  }
5630 }
5631 
5632 // Returns true if the given type name is easy to read by a human.
5633 // This is used to decide whether printing the type of a value might
5634 // be helpful.
5635 inline bool IsReadableTypeName(const string & type_name)
5636 {
5637  // We consider a type name readable if it's short or doesn't contain
5638  // a template or function type.
5639  return (type_name.length() <= 20 ||
5640  type_name.find_first_of("<(") == string::npos);
5641 }
5642 
5643 // Matches the value against the given matcher, prints the value and explains
5644 // the match result to the listener. Returns the match result.
5645 // 'listener' must not be NULL.
5646 // Value cannot be passed by const reference, because some matchers take a
5647 // non-const argument.
5648 template <typename Value, typename T>
5649 bool MatchPrintAndExplain(Value & value, const Matcher<T> & matcher,
5650  MatchResultListener * listener)
5651 {
5652  if (!listener->IsInterested())
5653  {
5654  // If the listener is not interested, we do not need to construct the
5655  // inner explanation.
5656  return matcher.Matches(value);
5657  }
5658 
5659  StringMatchResultListener inner_listener;
5660  const bool match = matcher.MatchAndExplain(value, &inner_listener);
5661 
5662  UniversalPrint(value, listener->stream());
5663 #if GTEST_HAS_RTTI
5664  const string & type_name = GetTypeName<Value>();
5665 
5666  if (IsReadableTypeName(type_name))
5667  { *listener->stream() << " (of type " << type_name << ")"; }
5668 
5669 #endif
5670  PrintIfNotEmpty(inner_listener.str(), listener->stream());
5671 
5672  return match;
5673 }
5674 
5675 // An internal helper class for doing compile-time loop on a tuple's
5676 // fields.
5677 template <size_t N>
5679 {
5680 public:
5681  // TuplePrefix<N>::Matches(matcher_tuple, value_tuple) returns true
5682  // iff the first N fields of matcher_tuple matches the first N
5683  // fields of value_tuple, respectively.
5684  template <typename MatcherTuple, typename ValueTuple>
5685  static bool Matches(const MatcherTuple & matcher_tuple,
5686  const ValueTuple & value_tuple)
5687  {
5689  return TuplePrefix < N - 1 >::Matches(matcher_tuple, value_tuple)
5690  && get < N - 1 > (matcher_tuple).Matches(get < N - 1 > (value_tuple));
5691  }
5692 
5693  // TuplePrefix<N>::ExplainMatchFailuresTo(matchers, values, os)
5694  // describes failures in matching the first N fields of matchers
5695  // against the first N fields of values. If there is no failure,
5696  // nothing will be streamed to os.
5697  template <typename MatcherTuple, typename ValueTuple>
5698  static void ExplainMatchFailuresTo(const MatcherTuple & matchers,
5699  const ValueTuple & values,
5700  ::std::ostream * os)
5701  {
5702  using ::std::tr1::tuple_element;
5704 
5705  // First, describes failures in the first N - 1 fields.
5706  TuplePrefix < N - 1 >::ExplainMatchFailuresTo(matchers, values, os);
5707 
5708  // Then describes the failure (if any) in the (N - 1)-th (0-based)
5709  // field.
5710  typename tuple_element < N - 1, MatcherTuple >::type matcher =
5711  get < N - 1 > (matchers);
5712  typedef typename tuple_element < N - 1, ValueTuple >::type Value;
5713  Value value = get < N - 1 > (values);
5714  StringMatchResultListener listener;
5715 
5716  if (!matcher.MatchAndExplain(value, &listener))
5717  {
5718  // TODO(wan): include in the message the name of the parameter
5719  // as used in MOCK_METHOD*() when possible.
5720  *os << " Expected arg #" << N - 1 << ": ";
5721  get < N - 1 > (matchers).DescribeTo(os);
5722  *os << "\n Actual: ";
5723  // We remove the reference in type Value to prevent the
5724  // universal printer from printing the address of value, which
5725  // isn't interesting to the user most of the time. The
5726  // matcher's MatchAndExplain() method handles the case when
5727  // the address is interesting.
5728  internal::UniversalPrint(value, os);
5729  PrintIfNotEmpty(listener.str(), os);
5730  *os << "\n";
5731  }
5732  }
5733 };
5734 
5735 // The base case.
5736 template <>
5737 class TuplePrefix<0>
5738 {
5739 public:
5740  template <typename MatcherTuple, typename ValueTuple>
5741  static bool Matches(const MatcherTuple & /* matcher_tuple */,
5742  const ValueTuple & /* value_tuple */)
5743  {
5744  return true;
5745  }
5746 
5747  template <typename MatcherTuple, typename ValueTuple>
5748  static void ExplainMatchFailuresTo(const MatcherTuple & /* matchers */,
5749  const ValueTuple & /* values */,
5750  ::std::ostream * /* os */) {}
5751 };
5752 
5753 // TupleMatches(matcher_tuple, value_tuple) returns true iff all
5754 // matchers in matcher_tuple match the corresponding fields in
5755 // value_tuple. It is a compiler error if matcher_tuple and
5756 // value_tuple have different number of fields or incompatible field
5757 // types.
5758 template <typename MatcherTuple, typename ValueTuple>
5759 bool TupleMatches(const MatcherTuple & matcher_tuple,
5760  const ValueTuple & value_tuple)
5761 {
5762  using ::std::tr1::tuple_size;
5763  // Makes sure that matcher_tuple and value_tuple have the same
5764  // number of fields.
5765  GTEST_COMPILE_ASSERT_(tuple_size<MatcherTuple>::value ==
5766  tuple_size<ValueTuple>::value,
5767  matcher_and_value_have_different_numbers_of_fields);
5769  Matches(matcher_tuple, value_tuple);
5770 }
5771 
5772 // Describes failures in matching matchers against values. If there
5773 // is no failure, nothing will be streamed to os.
5774 template <typename MatcherTuple, typename ValueTuple>
5776  const ValueTuple & values,
5777  ::std::ostream * os)
5778 {
5779  using ::std::tr1::tuple_size;
5780  TuplePrefix<tuple_size<MatcherTuple>::value>::ExplainMatchFailuresTo(
5781  matchers, values, os);
5782 }
5783 
5784 // TransformTupleValues and its helper.
5785 //
5786 // TransformTupleValuesHelper hides the internal machinery that
5787 // TransformTupleValues uses to implement a tuple traversal.
5788 template <typename Tuple, typename Func, typename OutIter>
5790 {
5791 private:
5792  typedef typename ::std::tr1::tuple_size<Tuple> TupleSize;
5793 
5794 public:
5795  // For each member of tuple 't', taken in order, evaluates '*out++ = f(t)'.
5796  // Returns the final value of 'out' in case the caller needs it.
5797  static OutIter Run(Func f, const Tuple & t, OutIter out)
5798  {
5799  return IterateOverTuple<Tuple, TupleSize::value>()(f, t, out);
5800  }
5801 
5802 private:
5803  template <typename Tup, size_t kRemainingSize>
5805  {
5806  OutIter operator()(Func f, const Tup & t, OutIter out) const
5807  {
5808  *out++ = f(::std::tr1::get < TupleSize::value - kRemainingSize > (t));
5809  return IterateOverTuple < Tup, kRemainingSize - 1 > ()(f, t, out);
5810  }
5811  };
5812  template <typename Tup>
5813  struct IterateOverTuple<Tup, 0>
5814  {
5815  OutIter operator()(Func /* f */, const Tup & /* t */, OutIter out) const
5816  {
5817  return out;
5818  }
5819  };
5820 };
5821 
5822 // Successively invokes 'f(element)' on each element of the tuple 't',
5823 // appending each result to the 'out' iterator. Returns the final value
5824 // of 'out'.
5825 template <typename Tuple, typename Func, typename OutIter>
5826 OutIter TransformTupleValues(Func f, const Tuple & t, OutIter out)
5827 {
5829 }
5830 
5831 // Implements A<T>().
5832 template <typename T>
5834 {
5835 public:
5836  virtual bool MatchAndExplain(
5837  T /* x */, MatchResultListener * /* listener */) const { return true; }
5838  virtual void DescribeTo(::std::ostream * os) const { *os << "is anything"; }
5839  virtual void DescribeNegationTo(::std::ostream * os) const
5840  {
5841  // This is mostly for completeness' safe, as it's not very useful
5842  // to write Not(A<bool>()). However we cannot completely rule out
5843  // such a possibility, and it doesn't hurt to be prepared.
5844  *os << "never matches";
5845  }
5846 };
5847 
5848 // Implements _, a matcher that matches any value of any
5849 // type. This is a polymorphic matcher, so we need a template type
5850 // conversion operator to make it appearing as a Matcher<T> for any
5851 // type T.
5853 {
5854 public:
5855  template <typename T>
5856  operator Matcher<T>() const { return A<T>(); }
5857 };
5858 
5859 // Implements a matcher that compares a given value with a
5860 // pre-supplied value using one of the ==, <=, <, etc, operators. The
5861 // two values being compared don't have to have the same type.
5862 //
5863 // The matcher defined here is polymorphic (for example, Eq(5) can be
5864 // used to match an int, a short, a double, etc). Therefore we use
5865 // a template type conversion operator in the implementation.
5866 //
5867 // We define this as a macro in order to eliminate duplicated source
5868 // code.
5869 //
5870 // The following template definition assumes that the Rhs parameter is
5871 // a "bare" type (i.e. neither 'const T' nor 'T&').
5872 #define GMOCK_IMPLEMENT_COMPARISON_MATCHER_( \
5873  name, op, relation, negated_relation) \
5874  template <typename Rhs> class name##Matcher { \
5875  public: \
5876  explicit name##Matcher(const Rhs& rhs) : rhs_(rhs) {} \
5877  template <typename Lhs> \
5878  operator Matcher<Lhs>() const { \
5879  return MakeMatcher(new Impl<Lhs>(rhs_)); \
5880  } \
5881  private: \
5882  template <typename Lhs> \
5883  class Impl : public MatcherInterface<Lhs> { \
5884  public: \
5885  explicit Impl(const Rhs& rhs) : rhs_(rhs) {} \
5886  virtual bool MatchAndExplain(\
5887  Lhs lhs, MatchResultListener* /* listener */) const { \
5888  return lhs op rhs_; \
5889  } \
5890  virtual void DescribeTo(::std::ostream* os) const { \
5891  *os << relation " "; \
5892  UniversalPrint(rhs_, os); \
5893  } \
5894  virtual void DescribeNegationTo(::std::ostream* os) const { \
5895  *os << negated_relation " "; \
5896  UniversalPrint(rhs_, os); \
5897  } \
5898  private: \
5899  Rhs rhs_; \
5900  GTEST_DISALLOW_ASSIGN_(Impl); \
5901  }; \
5902  Rhs rhs_; \
5903  GTEST_DISALLOW_ASSIGN_(name##Matcher); \
5904  }
5905 
5906 // Implements Eq(v), Ge(v), Gt(v), Le(v), Lt(v), and Ne(v)
5907 // respectively.
5908 GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Eq, ==, "is equal to", "isn't equal to");
5909 GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ge, >=, "is >=", "isn't >=");
5910 GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Gt, >, "is >", "isn't >");
5911 GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Le, <=, "is <=", "isn't <=");
5912 GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Lt, <, "is <", "isn't <");
5913 GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ne, !=, "isn't equal to", "is equal to");
5914 
5915 #undef GMOCK_IMPLEMENT_COMPARISON_MATCHER_
5916 
5917 // Implements the polymorphic IsNull() matcher, which matches any raw or smart
5918 // pointer that is NULL.
5920 {
5921 public:
5922  template <typename Pointer>
5923  bool MatchAndExplain(const Pointer & p,
5924  MatchResultListener * /* listener */) const
5925  {
5926  return GetRawPointer(p) == NULL;
5927  }
5928 
5929  void DescribeTo(::std::ostream * os) const { *os << "is NULL"; }
5930  void DescribeNegationTo(::std::ostream * os) const
5931  {
5932  *os << "isn't NULL";
5933  }
5934 };
5935 
5936 // Implements the polymorphic NotNull() matcher, which matches any raw or smart
5937 // pointer that is not NULL.
5939 {
5940 public:
5941  template <typename Pointer>
5942  bool MatchAndExplain(const Pointer & p,
5943  MatchResultListener * /* listener */) const
5944  {
5945  return GetRawPointer(p) != NULL;
5946  }
5947 
5948  void DescribeTo(::std::ostream * os) const { *os << "isn't NULL"; }
5949  void DescribeNegationTo(::std::ostream * os) const
5950  {
5951  *os << "is NULL";
5952  }
5953 };
5954 
5955 // Ref(variable) matches any argument that is a reference to
5956 // 'variable'. This matcher is polymorphic as it can match any
5957 // super type of the type of 'variable'.
5958 //
5959 // The RefMatcher template class implements Ref(variable). It can
5960 // only be instantiated with a reference type. This prevents a user
5961 // from mistakenly using Ref(x) to match a non-reference function
5962 // argument. For example, the following will righteously cause a
5963 // compiler error:
5964 //
5965 // int n;
5966 // Matcher<int> m1 = Ref(n); // This won't compile.
5967 // Matcher<int&> m2 = Ref(n); // This will compile.
5968 template <typename T>
5970 
5971 template <typename T>
5972 class RefMatcher<T &>
5973 {
5974  // Google Mock is a generic framework and thus needs to support
5975  // mocking any function types, including those that take non-const
5976  // reference arguments. Therefore the template parameter T (and
5977  // Super below) can be instantiated to either a const type or a
5978  // non-const type.
5979 public:
5980  // RefMatcher() takes a T& instead of const T&, as we want the
5981  // compiler to catch using Ref(const_value) as a matcher for a
5982  // non-const reference.
5983  explicit RefMatcher(T & x) : object_(x) {} // NOLINT
5984 
5985  template <typename Super>
5986  operator Matcher<Super &>() const
5987  {
5988  // By passing object_ (type T&) to Impl(), which expects a Super&,
5989  // we make sure that Super is a super type of T. In particular,
5990  // this catches using Ref(const_value) as a matcher for a
5991  // non-const reference, as you cannot implicitly convert a const
5992  // reference to a non-const reference.
5993  return MakeMatcher(new Impl<Super>(object_));
5994  }
5995 
5996 private:
5997  template <typename Super>
5998  class Impl : public MatcherInterface<Super &>
5999  {
6000  public:
6001  explicit Impl(Super & x) : object_(x) {} // NOLINT
6002 
6003  // MatchAndExplain() takes a Super& (as opposed to const Super&)
6004  // in order to match the interface MatcherInterface<Super&>.
6005  virtual bool MatchAndExplain(
6006  Super & x, MatchResultListener * listener) const
6007  {
6008  *listener << "which is located @" << static_cast<const void *>(&x);
6009  return &x == &object_;
6010  }
6011 
6012  virtual void DescribeTo(::std::ostream * os) const
6013  {
6014  *os << "references the variable ";
6015  UniversalPrinter<Super &>::Print(object_, os);
6016  }
6017 
6018  virtual void DescribeNegationTo(::std::ostream * os) const
6019  {
6020  *os << "does not reference the variable ";
6021  UniversalPrinter<Super &>::Print(object_, os);
6022  }
6023 
6024  private:
6025  const Super & object_;
6026 
6027  GTEST_DISALLOW_ASSIGN_(Impl);
6028  };
6029 
6030  T & object_;
6031 
6033 };
6034 
6035 // Polymorphic helper functions for narrow and wide string matchers.
6036 inline bool CaseInsensitiveCStringEquals(const char * lhs, const char * rhs)
6037 {
6038  return String::CaseInsensitiveCStringEquals(lhs, rhs);
6039 }
6040 
6041 inline bool CaseInsensitiveCStringEquals(const wchar_t * lhs,
6042  const wchar_t * rhs)
6043 {
6044  return String::CaseInsensitiveWideCStringEquals(lhs, rhs);
6045 }
6046 
6047 // String comparison for narrow or wide strings that can have embedded NUL
6048 // characters.
6049 template <typename StringType>
6050 bool CaseInsensitiveStringEquals(const StringType & s1,
6051  const StringType & s2)
6052 {
6053  // Are the heads equal?
6054  if (!CaseInsensitiveCStringEquals(s1.c_str(), s2.c_str()))
6055  {
6056  return false;
6057  }
6058 
6059  // Skip the equal heads.
6060  const typename StringType::value_type nul = 0;
6061  const size_t i1 = s1.find(nul), i2 = s2.find(nul);
6062 
6063  // Are we at the end of either s1 or s2?
6064  if (i1 == StringType::npos || i2 == StringType::npos)
6065  {
6066  return i1 == i2;
6067  }
6068 
6069  // Are the tails equal?
6070  return CaseInsensitiveStringEquals(s1.substr(i1 + 1), s2.substr(i2 + 1));
6071 }
6072 
6073 // String matchers.
6074 
6075 // Implements equality-based string matchers like StrEq, StrCaseNe, and etc.
6076 template <typename StringType>
6078 {
6079 public:
6080  StrEqualityMatcher(const StringType & str, bool expect_eq,
6081  bool case_sensitive)
6082  : string_(str), expect_eq_(expect_eq), case_sensitive_(case_sensitive) {}
6083 
6084  // Accepts pointer types, particularly:
6085  // const char*
6086  // char*
6087  // const wchar_t*
6088  // wchar_t*
6089  template <typename CharType>
6090  bool MatchAndExplain(CharType * s, MatchResultListener * listener) const
6091  {
6092  if (s == NULL)
6093  {
6094  return !expect_eq_;
6095  }
6096 
6097  return MatchAndExplain(StringType(s), listener);
6098  }
6099 
6100  // Matches anything that can convert to StringType.
6101  //
6102  // This is a template, not just a plain function with const StringType&,
6103  // because StringPiece has some interfering non-explicit constructors.
6104  template <typename MatcheeStringType>
6105  bool MatchAndExplain(const MatcheeStringType & s,
6106  MatchResultListener * /* listener */) const
6107  {
6108  const StringType & s2(s);
6109  const bool eq = case_sensitive_ ? s2 == string_ :
6110  CaseInsensitiveStringEquals(s2, string_);
6111  return expect_eq_ == eq;
6112  }
6113 
6114  void DescribeTo(::std::ostream * os) const
6115  {
6116  DescribeToHelper(expect_eq_, os);
6117  }
6118 
6119  void DescribeNegationTo(::std::ostream * os) const
6120  {
6121  DescribeToHelper(!expect_eq_, os);
6122  }
6123 
6124 private:
6125  void DescribeToHelper(bool expect_eq, ::std::ostream * os) const
6126  {
6127  *os << (expect_eq ? "is " : "isn't ");
6128  *os << "equal to ";
6129 
6130  if (!case_sensitive_)
6131  {
6132  *os << "(ignoring case) ";
6133  }
6134 
6135  UniversalPrint(string_, os);
6136  }
6137 
6138  const StringType string_;
6139  const bool expect_eq_;
6140  const bool case_sensitive_;
6141 
6143 };
6144 
6145 // Implements the polymorphic HasSubstr(substring) matcher, which
6146 // can be used as a Matcher<T> as long as T can be converted to a
6147 // string.
6148 template <typename StringType>
6150 {
6151 public:
6152  explicit HasSubstrMatcher(const StringType & substring)
6153  : substring_(substring) {}
6154 
6155  // Accepts pointer types, particularly:
6156  // const char*
6157  // char*
6158  // const wchar_t*
6159  // wchar_t*
6160  template <typename CharType>
6161  bool MatchAndExplain(CharType * s, MatchResultListener * listener) const
6162  {
6163  return s != NULL && MatchAndExplain(StringType(s), listener);
6164  }
6165 
6166  // Matches anything that can convert to StringType.
6167  //
6168  // This is a template, not just a plain function with const StringType&,
6169  // because StringPiece has some interfering non-explicit constructors.
6170  template <typename MatcheeStringType>
6171  bool MatchAndExplain(const MatcheeStringType & s,
6172  MatchResultListener * /* listener */) const
6173  {
6174  const StringType & s2(s);
6175  return s2.find(substring_) != StringType::npos;
6176  }
6177 
6178  // Describes what this matcher matches.
6179  void DescribeTo(::std::ostream * os) const
6180  {
6181  *os << "has substring ";
6182  UniversalPrint(substring_, os);
6183  }
6184 
6185  void DescribeNegationTo(::std::ostream * os) const
6186  {
6187  *os << "has no substring ";
6188  UniversalPrint(substring_, os);
6189  }
6190 
6191 private:
6192  const StringType substring_;
6193 
6195 };
6196 
6197 // Implements the polymorphic StartsWith(substring) matcher, which
6198 // can be used as a Matcher<T> as long as T can be converted to a
6199 // string.
6200 template <typename StringType>
6202 {
6203 public:
6204  explicit StartsWithMatcher(const StringType & prefix) : prefix_(prefix)
6205  {
6206  }
6207 
6208  // Accepts pointer types, particularly:
6209  // const char*
6210  // char*
6211  // const wchar_t*
6212  // wchar_t*
6213  template <typename CharType>
6214  bool MatchAndExplain(CharType * s, MatchResultListener * listener) const
6215  {
6216  return s != NULL && MatchAndExplain(StringType(s), listener);
6217  }
6218 
6219  // Matches anything that can convert to StringType.
6220  //
6221  // This is a template, not just a plain function with const StringType&,
6222  // because StringPiece has some interfering non-explicit constructors.
6223  template <typename MatcheeStringType>
6224  bool MatchAndExplain(const MatcheeStringType & s,
6225  MatchResultListener * /* listener */) const
6226  {
6227  const StringType & s2(s);
6228  return s2.length() >= prefix_.length() &&
6229  s2.substr(0, prefix_.length()) == prefix_;
6230  }
6231 
6232  void DescribeTo(::std::ostream * os) const
6233  {
6234  *os << "starts with ";
6235  UniversalPrint(prefix_, os);
6236  }
6237 
6238  void DescribeNegationTo(::std::ostream * os) const
6239  {
6240  *os << "doesn't start with ";
6241  UniversalPrint(prefix_, os);
6242  }
6243 
6244 private:
6245  const StringType prefix_;
6246 
6248 };
6249 
6250 // Implements the polymorphic EndsWith(substring) matcher, which
6251 // can be used as a Matcher<T> as long as T can be converted to a
6252 // string.
6253 template <typename StringType>
6255 {
6256 public:
6257  explicit EndsWithMatcher(const StringType & suffix) : suffix_(suffix) {}
6258 
6259  // Accepts pointer types, particularly:
6260  // const char*
6261  // char*
6262  // const wchar_t*
6263  // wchar_t*
6264  template <typename CharType>
6265  bool MatchAndExplain(CharType * s, MatchResultListener * listener) const
6266  {
6267  return s != NULL && MatchAndExplain(StringType(s), listener);
6268  }
6269 
6270  // Matches anything that can convert to StringType.
6271  //
6272  // This is a template, not just a plain function with const StringType&,
6273  // because StringPiece has some interfering non-explicit constructors.
6274  template <typename MatcheeStringType>
6275  bool MatchAndExplain(const MatcheeStringType & s,
6276  MatchResultListener * /* listener */) const
6277  {
6278  const StringType & s2(s);
6279  return s2.length() >= suffix_.length() &&
6280  s2.substr(s2.length() - suffix_.length()) == suffix_;
6281  }
6282 
6283  void DescribeTo(::std::ostream * os) const
6284  {
6285  *os << "ends with ";
6286  UniversalPrint(suffix_, os);
6287  }
6288 
6289  void DescribeNegationTo(::std::ostream * os) const
6290  {
6291  *os << "doesn't end with ";
6292  UniversalPrint(suffix_, os);
6293  }
6294 
6295 private:
6296  const StringType suffix_;
6297 
6299 };
6300 
6301 // Implements polymorphic matchers MatchesRegex(regex) and
6302 // ContainsRegex(regex), which can be used as a Matcher<T> as long as
6303 // T can be converted to a string.
6305 {
6306 public:
6307  MatchesRegexMatcher(const RE * regex, bool full_match)
6308  : regex_(regex), full_match_(full_match) {}
6309 
6310  // Accepts pointer types, particularly:
6311  // const char*
6312  // char*
6313  // const wchar_t*
6314  // wchar_t*
6315  template <typename CharType>
6316  bool MatchAndExplain(CharType * s, MatchResultListener * listener) const
6317  {
6318  return s != NULL && MatchAndExplain(internal::string(s), listener);
6319  }
6320 
6321  // Matches anything that can convert to internal::string.
6322  //
6323  // This is a template, not just a plain function with const internal::string&,
6324  // because StringPiece has some interfering non-explicit constructors.
6325  template <class MatcheeStringType>
6326  bool MatchAndExplain(const MatcheeStringType & s,
6327  MatchResultListener * /* listener */) const
6328  {
6329  const internal::string & s2(s);
6330  return full_match_ ? RE::FullMatch(s2, *regex_) :
6331  RE::PartialMatch(s2, *regex_);
6332  }
6333 
6334  void DescribeTo(::std::ostream * os) const
6335  {
6336  *os << (full_match_ ? "matches" : "contains")
6337  << " regular expression ";
6338  UniversalPrinter<internal::string>::Print(regex_->pattern(), os);
6339  }
6340 
6341  void DescribeNegationTo(::std::ostream * os) const
6342  {
6343  *os << "doesn't " << (full_match_ ? "match" : "contain")
6344  << " regular expression ";
6345  UniversalPrinter<internal::string>::Print(regex_->pattern(), os);
6346  }
6347 
6348 private:
6350  const bool full_match_;
6351 
6353 };
6354 
6355 // Implements a matcher that compares the two fields of a 2-tuple
6356 // using one of the ==, <=, <, etc, operators. The two fields being
6357 // compared don't have to have the same type.
6358 //
6359 // The matcher defined here is polymorphic (for example, Eq() can be
6360 // used to match a tuple<int, short>, a tuple<const long&, double>,
6361 // etc). Therefore we use a template type conversion operator in the
6362 // implementation.
6363 //
6364 // We define this as a macro in order to eliminate duplicated source
6365 // code.
6366 #define GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(name, op, relation) \
6367  class name##2Matcher { \
6368  public: \
6369  template <typename T1, typename T2> \
6370  operator Matcher< ::std::tr1::tuple<T1, T2> >() const { \
6371  return MakeMatcher(new Impl< ::std::tr1::tuple<T1, T2> >); \
6372  } \
6373  template <typename T1, typename T2> \
6374  operator Matcher<const ::std::tr1::tuple<T1, T2>&>() const { \
6375  return MakeMatcher(new Impl<const ::std::tr1::tuple<T1, T2>&>); \
6376  } \
6377  private: \
6378  template <typename Tuple> \
6379  class Impl : public MatcherInterface<Tuple> { \
6380  public: \
6381  virtual bool MatchAndExplain( \
6382  Tuple args, \
6383  MatchResultListener* /* listener */) const { \
6384  return ::std::tr1::get<0>(args) op ::std::tr1::get<1>(args); \
6385  } \
6386  virtual void DescribeTo(::std::ostream* os) const { \
6387  *os << "are " relation; \
6388  } \
6389  virtual void DescribeNegationTo(::std::ostream* os) const { \
6390  *os << "aren't " relation; \
6391  } \
6392  }; \
6393  }
6394 
6395 // Implements Eq(), Ge(), Gt(), Le(), Lt(), and Ne() respectively.
6396 GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Eq, ==, "an equal pair");
6398  Ge, >=, "a pair where the first >= the second");
6400  Gt, >, "a pair where the first > the second");
6402  Le, <=, "a pair where the first <= the second");
6404  Lt, <, "a pair where the first < the second");
6405 GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Ne, !=, "an unequal pair");
6406 
6407 #undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
6408 
6409 // Implements the Not(...) matcher for a particular argument type T.
6410 // We do not nest it inside the NotMatcher class template, as that
6411 // will prevent different instantiations of NotMatcher from sharing
6412 // the same NotMatcherImpl<T> class.
6413 template <typename T>
6415 {
6416 public:
6417  explicit NotMatcherImpl(const Matcher<T> & matcher)
6418  : matcher_(matcher) {}
6419 
6420  virtual bool MatchAndExplain(T x, MatchResultListener * listener) const
6421  {
6422  return !matcher_.MatchAndExplain(x, listener);
6423  }
6424 
6425  virtual void DescribeTo(::std::ostream * os) const
6426  {
6427  matcher_.DescribeNegationTo(os);
6428  }
6429 
6430  virtual void DescribeNegationTo(::std::ostream * os) const
6431  {
6432  matcher_.DescribeTo(os);
6433  }
6434 
6435 private:
6437 
6439 };
6440 
6441 // Implements the Not(m) matcher, which matches a value that doesn't
6442 // match matcher m.
6443 template <typename InnerMatcher>
6445 {
6446 public:
6447  explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {}
6448 
6449  // This template type conversion operator allows Not(m) to be used
6450  // to match any type m can match.
6451  template <typename T>
6452  operator Matcher<T>() const
6453  {
6454  return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_)));
6455  }
6456 
6457 private:
6458  InnerMatcher matcher_;
6459 
6461 };
6462 
6463 // Implements the AllOf(m1, m2) matcher for a particular argument type
6464 // T. We do not nest it inside the BothOfMatcher class template, as
6465 // that will prevent different instantiations of BothOfMatcher from
6466 // sharing the same BothOfMatcherImpl<T> class.
6467 template <typename T>
6469 {
6470 public:
6471  BothOfMatcherImpl(const Matcher<T> & matcher1, const Matcher<T> & matcher2)
6472  : matcher1_(matcher1), matcher2_(matcher2) {}
6473 
6474  virtual void DescribeTo(::std::ostream * os) const
6475  {
6476  *os << "(";
6477  matcher1_.DescribeTo(os);
6478  *os << ") and (";
6479  matcher2_.DescribeTo(os);
6480  *os << ")";
6481  }
6482 
6483  virtual void DescribeNegationTo(::std::ostream * os) const
6484  {
6485  *os << "(";
6486  matcher1_.DescribeNegationTo(os);
6487  *os << ") or (";
6488  matcher2_.DescribeNegationTo(os);
6489  *os << ")";
6490  }
6491 
6492  virtual bool MatchAndExplain(T x, MatchResultListener * listener) const
6493  {
6494  // If either matcher1_ or matcher2_ doesn't match x, we only need
6495  // to explain why one of them fails.
6496  StringMatchResultListener listener1;
6497 
6498  if (!matcher1_.MatchAndExplain(x, &listener1))
6499  {
6500  *listener << listener1.str();
6501  return false;
6502  }
6503 
6504  StringMatchResultListener listener2;
6505 
6506  if (!matcher2_.MatchAndExplain(x, &listener2))
6507  {
6508  *listener << listener2.str();
6509  return false;
6510  }
6511 
6512  // Otherwise we need to explain why *both* of them match.
6513  const internal::string s1 = listener1.str();
6514  const internal::string s2 = listener2.str();
6515 
6516  if (s1 == "")
6517  {
6518  *listener << s2;
6519  }
6520 
6521  else
6522  {
6523  *listener << s1;
6524 
6525  if (s2 != "")
6526  {
6527  *listener << ", and " << s2;
6528  }
6529  }
6530 
6531  return true;
6532  }
6533 
6534 private:
6537 
6539 };
6540 
6541 #if GTEST_LANG_CXX11
6542 // MatcherList provides mechanisms for storing a variable number of matchers in
6543 // a list structure (ListType) and creating a combining matcher from such a
6544 // list.
6545 // The template is defined recursively using the following template paramters:
6546 // * kSize is the length of the MatcherList.
6547 // * Head is the type of the first matcher of the list.
6548 // * Tail denotes the types of the remaining matchers of the list.
6549 template <int kSize, typename Head, typename... Tail>
6550 struct MatcherList
6551 {
6552  typedef MatcherList < kSize - 1, Tail... > MatcherListTail;
6553  typedef ::std::pair<Head, typename MatcherListTail::ListType> ListType;
6554 
6555  // BuildList stores variadic type values in a nested pair structure.
6556  // Example:
6557  // MatcherList<3, int, string, float>::BuildList(5, "foo", 2.0) will return
6558  // the corresponding result of type pair<int, pair<string, float>>.
6559  static ListType BuildList(const Head & matcher, const Tail & ... tail)
6560  {
6561  return ListType(matcher, MatcherListTail::BuildList(tail...));
6562  }
6563 
6564  // CreateMatcher<T> creates a Matcher<T> from a given list of matchers (built
6565  // by BuildList()). CombiningMatcher<T> is used to combine the matchers of the
6566  // list. CombiningMatcher<T> must implement MatcherInterface<T> and have a
6567  // constructor taking two Matcher<T>s as input.
6568  template <typename T, template <typename /* T */> class CombiningMatcher>
6569  static Matcher<T> CreateMatcher(const ListType & matchers)
6570  {
6571  return Matcher<T>(new CombiningMatcher<T>(
6572  SafeMatcherCast<T>(matchers.first),
6573  MatcherListTail::template CreateMatcher<T, CombiningMatcher>(
6574  matchers.second)));
6575  }
6576 };
6577 
6578 // The following defines the base case for the recursive definition of
6579 // MatcherList.
6580 template <typename Matcher1, typename Matcher2>
6581 struct MatcherList<2, Matcher1, Matcher2>
6582 {
6583  typedef ::std::pair<Matcher1, Matcher2> ListType;
6584 
6585  static ListType BuildList(const Matcher1 & matcher1,
6586  const Matcher2 & matcher2)
6587  {
6588  return ::std::pair<Matcher1, Matcher2>(matcher1, matcher2);
6589  }
6590 
6591  template <typename T, template <typename /* T */> class CombiningMatcher>
6592  static Matcher<T> CreateMatcher(const ListType & matchers)
6593  {
6594  return Matcher<T>(new CombiningMatcher<T>(
6595  SafeMatcherCast<T>(matchers.first),
6596  SafeMatcherCast<T>(matchers.second)));
6597  }
6598 };
6599 
6600 // VariadicMatcher is used for the variadic implementation of
6601 // AllOf(m_1, m_2, ...) and AnyOf(m_1, m_2, ...).
6602 // CombiningMatcher<T> is used to recursively combine the provided matchers
6603 // (of type Args...).
6604 template <template <typename T> class CombiningMatcher, typename... Args>
6605 class VariadicMatcher
6606 {
6607 public:
6608  VariadicMatcher(const Args & ... matchers) // NOLINT
6609  : matchers_(MatcherListType::BuildList(matchers...)) {}
6610 
6611  // This template type conversion operator allows an
6612  // VariadicMatcher<Matcher1, Matcher2...> object to match any type that
6613  // all of the provided matchers (Matcher1, Matcher2, ...) can match.
6614  template <typename T>
6615  operator Matcher<T>() const
6616  {
6617  return MatcherListType::template CreateMatcher<T, CombiningMatcher>(
6618  matchers_);
6619  }
6620 
6621 private:
6622  typedef MatcherList<sizeof...(Args), Args...> MatcherListType;
6623 
6624  const typename MatcherListType::ListType matchers_;
6625 
6626  GTEST_DISALLOW_ASSIGN_(VariadicMatcher);
6627 };
6628 
6629 template <typename... Args>
6630 using AllOfMatcher = VariadicMatcher<BothOfMatcherImpl, Args...>;
6631 
6632 #endif // GTEST_LANG_CXX11
6633 
6634 // Used for implementing the AllOf(m_1, ..., m_n) matcher, which
6635 // matches a value that matches all of the matchers m_1, ..., and m_n.
6636 template <typename Matcher1, typename Matcher2>
6638 {
6639 public:
6640  BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
6641  : matcher1_(matcher1), matcher2_(matcher2) {}
6642 
6643  // This template type conversion operator allows a
6644  // BothOfMatcher<Matcher1, Matcher2> object to match any type that
6645  // both Matcher1 and Matcher2 can match.
6646  template <typename T>
6647  operator Matcher<T>() const
6648  {
6649  return Matcher<T>(new BothOfMatcherImpl<T>(SafeMatcherCast<T>(matcher1_),
6650  SafeMatcherCast<T>(matcher2_)));
6651  }
6652 
6653 private:
6654  Matcher1 matcher1_;
6655  Matcher2 matcher2_;
6656 
6658 };
6659 
6660 // Implements the AnyOf(m1, m2) matcher for a particular argument type
6661 // T. We do not nest it inside the AnyOfMatcher class template, as
6662 // that will prevent different instantiations of AnyOfMatcher from
6663 // sharing the same EitherOfMatcherImpl<T> class.
6664 template <typename T>
6666 {
6667 public:
6668  EitherOfMatcherImpl(const Matcher<T> & matcher1, const Matcher<T> & matcher2)
6669  : matcher1_(matcher1), matcher2_(matcher2) {}
6670 
6671  virtual void DescribeTo(::std::ostream * os) const
6672  {
6673  *os << "(";
6674  matcher1_.DescribeTo(os);
6675  *os << ") or (";
6676  matcher2_.DescribeTo(os);
6677  *os << ")";
6678  }
6679 
6680  virtual void DescribeNegationTo(::std::ostream * os) const
6681  {
6682  *os << "(";
6683  matcher1_.DescribeNegationTo(os);
6684  *os << ") and (";
6685  matcher2_.DescribeNegationTo(os);
6686  *os << ")";
6687  }
6688 
6689  virtual bool MatchAndExplain(T x, MatchResultListener * listener) const
6690  {
6691  // If either matcher1_ or matcher2_ matches x, we just need to
6692  // explain why *one* of them matches.
6693  StringMatchResultListener listener1;
6694 
6695  if (matcher1_.MatchAndExplain(x, &listener1))
6696  {
6697  *listener << listener1.str();
6698  return true;
6699  }
6700 
6701  StringMatchResultListener listener2;
6702 
6703  if (matcher2_.MatchAndExplain(x, &listener2))
6704  {
6705  *listener << listener2.str();
6706  return true;
6707  }
6708 
6709  // Otherwise we need to explain why *both* of them fail.
6710  const internal::string s1 = listener1.str();
6711  const internal::string s2 = listener2.str();
6712 
6713  if (s1 == "")
6714  {
6715  *listener << s2;
6716  }
6717 
6718  else
6719  {
6720  *listener << s1;
6721 
6722  if (s2 != "")
6723  {
6724  *listener << ", and " << s2;
6725  }
6726  }
6727 
6728  return false;
6729  }
6730 
6731 private:
6734 
6736 };
6737 
6738 #if GTEST_LANG_CXX11
6739 // AnyOfMatcher is used for the variadic implementation of AnyOf(m_1, m_2, ...).
6740 template <typename... Args>
6741 using AnyOfMatcher = VariadicMatcher<EitherOfMatcherImpl, Args...>;
6742 
6743 #endif // GTEST_LANG_CXX11
6744 
6745 // Used for implementing the AnyOf(m_1, ..., m_n) matcher, which
6746 // matches a value that matches at least one of the matchers m_1, ...,
6747 // and m_n.
6748 template <typename Matcher1, typename Matcher2>
6750 {
6751 public:
6752  EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
6753  : matcher1_(matcher1), matcher2_(matcher2) {}
6754 
6755  // This template type conversion operator allows a
6756  // EitherOfMatcher<Matcher1, Matcher2> object to match any type that
6757  // both Matcher1 and Matcher2 can match.
6758  template <typename T>
6759  operator Matcher<T>() const
6760  {
6762  SafeMatcherCast<T>(matcher1_), SafeMatcherCast<T>(matcher2_)));
6763  }
6764 
6765 private:
6766  Matcher1 matcher1_;
6767  Matcher2 matcher2_;
6768 
6770 };
6771 
6772 // Used for implementing Truly(pred), which turns a predicate into a
6773 // matcher.
6774 template <typename Predicate>
6776 {
6777 public:
6778  explicit TrulyMatcher(Predicate pred) : predicate_(pred) {}
6779 
6780  // This method template allows Truly(pred) to be used as a matcher
6781  // for type T where T is the argument type of predicate 'pred'. The
6782  // argument is passed by reference as the predicate may be
6783  // interested in the address of the argument.
6784  template <typename T>
6785  bool MatchAndExplain(T & x, // NOLINT
6786  MatchResultListener * /* listener */) const
6787  {
6788  // Without the if-statement, MSVC sometimes warns about converting
6789  // a value to bool (warning 4800).
6790  //
6791  // We cannot write 'return !!predicate_(x);' as that doesn't work
6792  // when predicate_(x) returns a class convertible to bool but
6793  // having no operator!().
6794  if (predicate_(x))
6795  { return true; }
6796 
6797  return false;
6798  }
6799 
6800  void DescribeTo(::std::ostream * os) const
6801  {
6802  *os << "satisfies the given predicate";
6803  }
6804 
6805  void DescribeNegationTo(::std::ostream * os) const
6806  {
6807  *os << "doesn't satisfy the given predicate";
6808  }
6809 
6810 private:
6811  Predicate predicate_;
6812 
6814 };
6815 
6816 // Used for implementing Matches(matcher), which turns a matcher into
6817 // a predicate.
6818 template <typename M>
6820 {
6821 public:
6822  explicit MatcherAsPredicate(M matcher) : matcher_(matcher) {}
6823 
6824  // This template operator() allows Matches(m) to be used as a
6825  // predicate on type T where m is a matcher on type T.
6826  //
6827  // The argument x is passed by reference instead of by value, as
6828  // some matcher may be interested in its address (e.g. as in
6829  // Matches(Ref(n))(x)).
6830  template <typename T>
6831  bool operator()(const T & x) const
6832  {
6833  // We let matcher_ commit to a particular type here instead of
6834  // when the MatcherAsPredicate object was constructed. This
6835  // allows us to write Matches(m) where m is a polymorphic matcher
6836  // (e.g. Eq(5)).
6837  //
6838  // If we write Matcher<T>(matcher_).Matches(x) here, it won't
6839  // compile when matcher_ has type Matcher<const T&>; if we write
6840  // Matcher<const T&>(matcher_).Matches(x) here, it won't compile
6841  // when matcher_ has type Matcher<T>; if we just write
6842  // matcher_.Matches(x), it won't compile when matcher_ is
6843  // polymorphic, e.g. Eq(5).
6844  //
6845  // MatcherCast<const T&>() is necessary for making the code work
6846  // in all of the above situations.
6847  return MatcherCast<const T &>(matcher_).Matches(x);
6848  }
6849 
6850 private:
6852 
6854 };
6855 
6856 // For implementing ASSERT_THAT() and EXPECT_THAT(). The template
6857 // argument M must be a type that can be converted to a matcher.
6858 template <typename M>
6860 {
6861 public:
6862  explicit PredicateFormatterFromMatcher(const M & m) : matcher_(m) {}
6863 
6864  // This template () operator allows a PredicateFormatterFromMatcher
6865  // object to act as a predicate-formatter suitable for using with
6866  // Google Test's EXPECT_PRED_FORMAT1() macro.
6867  template <typename T>
6868  AssertionResult operator()(const char * value_text, const T & x) const
6869  {
6870  // We convert matcher_ to a Matcher<const T&> *now* instead of
6871  // when the PredicateFormatterFromMatcher object was constructed,
6872  // as matcher_ may be polymorphic (e.g. NotNull()) and we won't
6873  // know which type to instantiate it to until we actually see the
6874  // type of x here.
6875  //
6876  // We write SafeMatcherCast<const T&>(matcher_) instead of
6877  // Matcher<const T&>(matcher_), as the latter won't compile when
6878  // matcher_ has type Matcher<T> (e.g. An<int>()).
6879  // We don't write MatcherCast<const T&> either, as that allows
6880  // potentially unsafe downcasting of the matcher argument.
6881  const Matcher<const T &> matcher = SafeMatcherCast<const T &>(matcher_);
6882  StringMatchResultListener listener;
6883 
6884  if (MatchPrintAndExplain(x, matcher, &listener))
6885  { return AssertionSuccess(); }
6886 
6887  ::std::stringstream ss;
6888  ss << "Value of: " << value_text << "\n"
6889  << "Expected: ";
6890  matcher.DescribeTo(&ss);
6891  ss << "\n Actual: " << listener.str();
6892  return AssertionFailure() << ss.str();
6893  }
6894 
6895 private:
6896  const M matcher_;
6897 
6899 };
6900 
6901 // A helper function for converting a matcher to a predicate-formatter
6902 // without the user needing to explicitly write the type. This is
6903 // used for implementing ASSERT_THAT() and EXPECT_THAT().
6904 template <typename M>
6907 {
6908  return PredicateFormatterFromMatcher<M>(matcher);
6909 }
6910 
6911 // Implements the polymorphic floating point equality matcher, which matches
6912 // two float values using ULP-based approximation or, optionally, a
6913 // user-specified epsilon. The template is meant to be instantiated with
6914 // FloatType being either float or double.
6915 template <typename FloatType>
6917 {
6918 public:
6919  // Constructor for FloatingEqMatcher.
6920  // The matcher's input will be compared with rhs. The matcher treats two
6921  // NANs as equal if nan_eq_nan is true. Otherwise, under IEEE standards,
6922  // equality comparisons between NANs will always return false. We specify a
6923  // negative max_abs_error_ term to indicate that ULP-based approximation will
6924  // be used for comparison.
6925  FloatingEqMatcher(FloatType rhs, bool nan_eq_nan) :
6926  rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(-1)
6927  {
6928  }
6929 
6930  // Constructor that supports a user-specified max_abs_error that will be used
6931  // for comparison instead of ULP-based approximation. The max absolute
6932  // should be non-negative.
6933  FloatingEqMatcher(FloatType rhs, bool nan_eq_nan, FloatType max_abs_error) :
6934  rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(max_abs_error)
6935  {
6936  GTEST_CHECK_(max_abs_error >= 0)
6937  << ", where max_abs_error is" << max_abs_error;
6938  }
6939 
6940  // Implements floating point equality matcher as a Matcher<T>.
6941  template <typename T>
6942  class Impl : public MatcherInterface<T>
6943  {
6944  public:
6945  Impl(FloatType rhs, bool nan_eq_nan, FloatType max_abs_error) :
6946  rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(max_abs_error) {}
6947 
6948  virtual bool MatchAndExplain(T value,
6949  MatchResultListener * /* listener */) const
6950  {
6951  const FloatingPoint<FloatType> lhs(value), rhs(rhs_);
6952 
6953  // Compares NaNs first, if nan_eq_nan_ is true.
6954  if (lhs.is_nan() || rhs.is_nan())
6955  {
6956  if (lhs.is_nan() && rhs.is_nan())
6957  {
6958  return nan_eq_nan_;
6959  }
6960 
6961  // One is nan; the other is not nan.
6962  return false;
6963  }
6964 
6965  if (HasMaxAbsError())
6966  {
6967  // We perform an equality check so that inf will match inf, regardless
6968  // of error bounds. If the result of value - rhs_ would result in
6969  // overflow or if either value is inf, the default result is infinity,
6970  // which should only match if max_abs_error_ is also infinity.
6971  return value == rhs_ || fabs(value - rhs_) <= max_abs_error_;
6972  }
6973 
6974  else
6975  {
6976  return lhs.AlmostEquals(rhs);
6977  }
6978  }
6979 
6980  virtual void DescribeTo(::std::ostream * os) const
6981  {
6982  // os->precision() returns the previously set precision, which we
6983  // store to restore the ostream to its original configuration
6984  // after outputting.
6985  const ::std::streamsize old_precision = os->precision(
6986  ::std::numeric_limits<FloatType>::digits10 + 2);
6987 
6988  if (FloatingPoint<FloatType>(rhs_).is_nan())
6989  {
6990  if (nan_eq_nan_)
6991  {
6992  *os << "is NaN";
6993  }
6994 
6995  else
6996  {
6997  *os << "never matches";
6998  }
6999  }
7000 
7001  else
7002  {
7003  *os << "is approximately " << rhs_;
7004 
7005  if (HasMaxAbsError())
7006  {
7007  *os << " (absolute error <= " << max_abs_error_ << ")";
7008  }
7009  }
7010 
7011  os->precision(old_precision);
7012  }
7013 
7014  virtual void DescribeNegationTo(::std::ostream * os) const
7015  {
7016  // As before, get original precision.
7017  const ::std::streamsize old_precision = os->precision(
7018  ::std::numeric_limits<FloatType>::digits10 + 2);
7019 
7020  if (FloatingPoint<FloatType>(rhs_).is_nan())
7021  {
7022  if (nan_eq_nan_)
7023  {
7024  *os << "isn't NaN";
7025  }
7026 
7027  else
7028  {
7029  *os << "is anything";
7030  }
7031  }
7032 
7033  else
7034  {
7035  *os << "isn't approximately " << rhs_;
7036 
7037  if (HasMaxAbsError())
7038  {
7039  *os << " (absolute error > " << max_abs_error_ << ")";
7040  }
7041  }
7042 
7043  // Restore original precision.
7044  os->precision(old_precision);
7045  }
7046 
7047  private:
7048  bool HasMaxAbsError() const
7049  {
7050  return max_abs_error_ >= 0;
7051  }
7052 
7053  const FloatType rhs_;
7054  const bool nan_eq_nan_;
7055  // max_abs_error will be used for value comparison when >= 0.
7056  const FloatType max_abs_error_;
7057 
7059  };
7060 
7061  // The following 3 type conversion operators allow FloatEq(rhs) and
7062  // NanSensitiveFloatEq(rhs) to be used as a Matcher<float>, a
7063  // Matcher<const float&>, or a Matcher<float&>, but nothing else.
7064  // (While Google's C++ coding style doesn't allow arguments passed
7065  // by non-const reference, we may see them in code not conforming to
7066  // the style. Therefore Google Mock needs to support them.)
7067  operator Matcher<FloatType>() const
7068  {
7069  return MakeMatcher(new Impl<FloatType>(rhs_, nan_eq_nan_, max_abs_error_));
7070  }
7071 
7073  {
7074  return MakeMatcher(
7075  new Impl<const FloatType &>(rhs_, nan_eq_nan_, max_abs_error_));
7076  }
7077 
7078  operator Matcher<FloatType &>() const
7079  {
7080  return MakeMatcher(new Impl<FloatType &>(rhs_, nan_eq_nan_, max_abs_error_));
7081  }
7082 
7083 private:
7084  const FloatType rhs_;
7085  const bool nan_eq_nan_;
7086  // max_abs_error will be used for value comparison when >= 0.
7087  const FloatType max_abs_error_;
7088 
7090 };
7091 
7092 // Implements the Pointee(m) matcher for matching a pointer whose
7093 // pointee matches matcher m. The pointer can be either raw or smart.
7094 template <typename InnerMatcher>
7096 {
7097 public:
7098  explicit PointeeMatcher(const InnerMatcher & matcher) : matcher_(matcher) {}
7099 
7100  // This type conversion operator template allows Pointee(m) to be
7101  // used as a matcher for any pointer type whose pointee type is
7102  // compatible with the inner matcher, where type Pointer can be
7103  // either a raw pointer or a smart pointer.
7104  //
7105  // The reason we do this instead of relying on
7106  // MakePolymorphicMatcher() is that the latter is not flexible
7107  // enough for implementing the DescribeTo() method of Pointee().
7108  template <typename Pointer>
7109  operator Matcher<Pointer>() const
7110  {
7111  return MakeMatcher(new Impl<Pointer>(matcher_));
7112  }
7113 
7114 private:
7115  // The monomorphic implementation that works for a particular pointer type.
7116  template <typename Pointer>
7117  class Impl : public MatcherInterface<Pointer>
7118  {
7119  public:
7120  typedef typename PointeeOf<GTEST_REMOVE_CONST_( // NOLINT
7122 
7123  explicit Impl(const InnerMatcher & matcher)
7124  : matcher_(MatcherCast<const Pointee & >(matcher)) {}
7125 
7126  virtual void DescribeTo(::std::ostream * os) const
7127  {
7128  *os << "points to a value that ";
7129  matcher_.DescribeTo(os);
7130  }
7131 
7132  virtual void DescribeNegationTo(::std::ostream * os) const
7133  {
7134  *os << "does not point to a value that ";
7135  matcher_.DescribeTo(os);
7136  }
7137 
7138  virtual bool MatchAndExplain(Pointer pointer,
7139  MatchResultListener * listener) const
7140  {
7141  if (GetRawPointer(pointer) == NULL)
7142  { return false; }
7143 
7144  *listener << "which points to ";
7145  return MatchPrintAndExplain(*pointer, matcher_, listener);
7146  }
7147 
7148  private:
7150 
7152  };
7153 
7154  const InnerMatcher matcher_;
7155 
7157 };
7158 
7159 // Implements the Field() matcher for matching a field (i.e. member
7160 // variable) of an object.
7161 template <typename Class, typename FieldType>
7163 {
7164 public:
7165  FieldMatcher(FieldType Class::*field,
7166  const Matcher<const FieldType &> & matcher)
7167  : field_(field), matcher_(matcher) {}
7168 
7169  void DescribeTo(::std::ostream * os) const
7170  {
7171  *os << "is an object whose given field ";
7172  matcher_.DescribeTo(os);
7173  }
7174 
7175  void DescribeNegationTo(::std::ostream * os) const
7176  {
7177  *os << "is an object whose given field ";
7178  matcher_.DescribeNegationTo(os);
7179  }
7180 
7181  template <typename T>
7182  bool MatchAndExplain(const T & value, MatchResultListener * listener) const
7183  {
7184  return MatchAndExplainImpl(
7185  typename ::testing::internal::
7186  is_pointer<GTEST_REMOVE_CONST_(T)>::type(),
7187  value, listener);
7188  }
7189 
7190 private:
7191  // The first argument of MatchAndExplainImpl() is needed to help
7192  // Symbian's C++ compiler choose which overload to use. Its type is
7193  // true_type iff the Field() matcher is used to match a pointer.
7194  bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class & obj,
7195  MatchResultListener * listener) const
7196  {
7197  *listener << "whose given field is ";
7198  return MatchPrintAndExplain(obj.*field_, matcher_, listener);
7199  }
7200 
7201  bool MatchAndExplainImpl(true_type /* is_pointer */, const Class * p,
7202  MatchResultListener * listener) const
7203  {
7204  if (p == NULL)
7205  { return false; }
7206 
7207  *listener << "which points to an object ";
7208  // Since *p has a field, it must be a class/struct/union type and
7209  // thus cannot be a pointer. Therefore we pass false_type() as
7210  // the first argument.
7211  return MatchAndExplainImpl(false_type(), *p, listener);
7212  }
7213 
7214  const FieldType Class::* field_;
7216 
7218 };
7219 
7220 // Implements the Property() matcher for matching a property
7221 // (i.e. return value of a getter method) of an object.
7222 template <typename Class, typename PropertyType>
7224 {
7225 public:
7226  // The property may have a reference type, so 'const PropertyType&'
7227  // may cause double references and fail to compile. That's why we
7228  // need GTEST_REFERENCE_TO_CONST, which works regardless of
7229  // PropertyType being a reference or not.
7230  typedef GTEST_REFERENCE_TO_CONST_(PropertyType) RefToConstProperty;
7231 
7232  PropertyMatcher(PropertyType(Class::*property)() const,
7233  const Matcher<RefToConstProperty> & matcher)
7234  : property_(property), matcher_(matcher) {}
7235 
7236  void DescribeTo(::std::ostream * os) const
7237  {
7238  *os << "is an object whose given property ";
7239  matcher_.DescribeTo(os);
7240  }
7241 
7242  void DescribeNegationTo(::std::ostream * os) const
7243  {
7244  *os << "is an object whose given property ";
7245  matcher_.DescribeNegationTo(os);
7246  }
7247 
7248  template <typename T>
7249  bool MatchAndExplain(const T & value, MatchResultListener * listener) const
7250  {
7251  return MatchAndExplainImpl(
7252  typename ::testing::internal::
7253  is_pointer<GTEST_REMOVE_CONST_(T)>::type(),
7254  value, listener);
7255  }
7256 
7257 private:
7258  // The first argument of MatchAndExplainImpl() is needed to help
7259  // Symbian's C++ compiler choose which overload to use. Its type is
7260  // true_type iff the Property() matcher is used to match a pointer.
7261  bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class & obj,
7262  MatchResultListener * listener) const
7263  {
7264  *listener << "whose given property is ";
7265  // Cannot pass the return value (for example, int) to MatchPrintAndExplain,
7266  // which takes a non-const reference as argument.
7267  RefToConstProperty result = (obj.*property_)();
7268  return MatchPrintAndExplain(result, matcher_, listener);
7269  }
7270 
7271  bool MatchAndExplainImpl(true_type /* is_pointer */, const Class * p,
7272  MatchResultListener * listener) const
7273  {
7274  if (p == NULL)
7275  { return false; }
7276 
7277  *listener << "which points to an object ";
7278  // Since *p has a property method, it must be a class/struct/union
7279  // type and thus cannot be a pointer. Therefore we pass
7280  // false_type() as the first argument.
7281  return MatchAndExplainImpl(false_type(), *p, listener);
7282  }
7283 
7284  PropertyType(Class::*property_)() const;
7286 
7288 };
7289 
7290 // Type traits specifying various features of different functors for ResultOf.
7291 // The default template specifies features for functor objects.
7292 // Functor classes have to typedef argument_type and result_type
7293 // to be compatible with ResultOf.
7294 template <typename Functor>
7296 {
7297  typedef typename Functor::result_type ResultType;
7298  typedef Functor StorageType;
7299 
7300  static void CheckIsValid(Functor /* functor */) {}
7301  template <typename T>
7302  static ResultType Invoke(Functor f, T arg) { return f(arg); }
7303 };
7304 
7305 // Specialization for function pointers.
7306 template <typename ArgType, typename ResType>
7307 struct CallableTraits<ResType(*)(ArgType)>
7308 {
7309  typedef ResType ResultType;
7310  typedef ResType(*StorageType)(ArgType);
7311 
7312  static void CheckIsValid(ResType(*f)(ArgType))
7313 {
7314  GTEST_CHECK_(f != NULL)
7315  << "NULL function pointer is passed into ResultOf().";
7316 }
7317 template <typename T>
7318 static ResType Invoke(ResType(*f)(ArgType), T arg)
7319 {
7320  return (*f)(arg);
7321 }
7322  };
7323 
7324 // Implements the ResultOf() matcher for matching a return value of a
7325 // unary function of an object.
7326 template <typename Callable>
7328 {
7329 public:
7331 
7332  ResultOfMatcher(Callable callable, const Matcher<ResultType> & matcher)
7333  : callable_(callable), matcher_(matcher)
7334  {
7336  }
7337 
7338  template <typename T>
7339  operator Matcher<T>() const
7340  {
7341  return Matcher<T>(new Impl<T>(callable_, matcher_));
7342  }
7343 
7344 private:
7346 
7347  template <typename T>
7348  class Impl : public MatcherInterface<T>
7349  {
7350  public:
7351  Impl(CallableStorageType callable, const Matcher<ResultType> & matcher)
7352  : callable_(callable), matcher_(matcher) {}
7353 
7354  virtual void DescribeTo(::std::ostream * os) const
7355  {
7356  *os << "is mapped by the given callable to a value that ";
7357  matcher_.DescribeTo(os);
7358  }
7359 
7360  virtual void DescribeNegationTo(::std::ostream * os) const
7361  {
7362  *os << "is mapped by the given callable to a value that ";
7363  matcher_.DescribeNegationTo(os);
7364  }
7365 
7366  virtual bool MatchAndExplain(T obj, MatchResultListener * listener) const
7367  {
7368  *listener << "which is mapped by the given callable to ";
7369  // Cannot pass the return value (for example, int) to
7370  // MatchPrintAndExplain, which takes a non-const reference as argument.
7371  ResultType result =
7372  CallableTraits<Callable>::template Invoke<T>(callable_, obj);
7373  return MatchPrintAndExplain(result, matcher_, listener);
7374  }
7375 
7376  private:
7377  // Functors often define operator() as non-const method even though
7378  // they are actualy stateless. But we need to use them even when
7379  // 'this' is a const pointer. It's the user's responsibility not to
7380  // use stateful callables with ResultOf(), which does't guarantee
7381  // how many times the callable will be invoked.
7382  mutable CallableStorageType callable_;
7384 
7386  }; // class Impl
7387 
7388  const CallableStorageType callable_;
7390 
7392 };
7393 
7394 // Implements a matcher that checks the size of an STL-style container.
7395 template <typename SizeMatcher>
7397 {
7398 public:
7399  explicit SizeIsMatcher(const SizeMatcher & size_matcher)
7400  : size_matcher_(size_matcher)
7401  {
7402  }
7403 
7404  template <typename Container>
7405  operator Matcher<Container>() const
7406  {
7407  return MakeMatcher(new Impl<Container>(size_matcher_));
7408  }
7409 
7410  template <typename Container>
7411  class Impl : public MatcherInterface<Container>
7412  {
7413  public:
7414  typedef internal::StlContainerView <
7416  typedef typename ContainerView::type::size_type SizeType;
7417  explicit Impl(const SizeMatcher & size_matcher)
7418  : size_matcher_(MatcherCast<SizeType>(size_matcher)) {}
7419 
7420  virtual void DescribeTo(::std::ostream * os) const
7421  {
7422  *os << "size ";
7423  size_matcher_.DescribeTo(os);
7424  }
7425  virtual void DescribeNegationTo(::std::ostream * os) const
7426  {
7427  *os << "size ";
7428  size_matcher_.DescribeNegationTo(os);
7429  }
7430 
7431  virtual bool MatchAndExplain(Container container,
7432  MatchResultListener * listener) const
7433  {
7434  SizeType size = container.size();
7435  StringMatchResultListener size_listener;
7436  const bool result = size_matcher_.MatchAndExplain(size, &size_listener);
7437  *listener
7438  << "whose size " << size << (result ? " matches" : " doesn't match");
7439  PrintIfNotEmpty(size_listener.str(), listener->stream());
7440  return result;
7441  }
7442 
7443  private:
7446  };
7447 
7448 private:
7449  const SizeMatcher size_matcher_;
7451 };
7452 
7453 // Implements an equality matcher for any STL-style container whose elements
7454 // support ==. This matcher is like Eq(), but its failure explanations provide
7455 // more detailed information that is useful when the container is used as a set.
7456 // The failure message reports elements that are in one of the operands but not
7457 // the other. The failure messages do not report duplicate or out-of-order
7458 // elements in the containers (which don't properly matter to sets, but can
7459 // occur if the containers are vectors or lists, for example).
7460 //
7461 // Uses the container's const_iterator, value_type, operator ==,
7462 // begin(), and end().
7463 template <typename Container>
7465 {
7466 public:
7468  typedef typename View::type StlContainer;
7470 
7471  // We make a copy of rhs in case the elements in it are modified
7472  // after this matcher is created.
7473  explicit ContainerEqMatcher(const Container & rhs) : rhs_(View::Copy(rhs))
7474  {
7475  // Makes sure the user doesn't instantiate this class template
7476  // with a const or reference type.
7477  (void)testing::StaticAssertTypeEq<Container,
7478  GTEST_REMOVE_REFERENCE_AND_CONST_(Container)>();
7479  }
7480 
7481  void DescribeTo(::std::ostream * os) const
7482  {
7483  *os << "equals ";
7484  UniversalPrint(rhs_, os);
7485  }
7486  void DescribeNegationTo(::std::ostream * os) const
7487  {
7488  *os << "does not equal ";
7489  UniversalPrint(rhs_, os);
7490  }
7491 
7492  template <typename LhsContainer>
7493  bool MatchAndExplain(const LhsContainer & lhs,
7494  MatchResultListener * listener) const
7495  {
7496  // GTEST_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug
7497  // that causes LhsContainer to be a const type sometimes.
7499  LhsView;
7500  typedef typename LhsView::type LhsStlContainer;
7501  StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
7502 
7503  if (lhs_stl_container == rhs_)
7504  { return true; }
7505 
7506  ::std::ostream * const os = listener->stream();
7507 
7508  if (os != NULL)
7509  {
7510  // Something is different. Check for extra values first.
7511  bool printed_header = false;
7512 
7513  for (typename LhsStlContainer::const_iterator it =
7514  lhs_stl_container.begin();
7515  it != lhs_stl_container.end(); ++it)
7516  {
7517  if (internal::ArrayAwareFind(rhs_.begin(), rhs_.end(), *it) ==
7518  rhs_.end())
7519  {
7520  if (printed_header)
7521  {
7522  *os << ", ";
7523  }
7524 
7525  else
7526  {
7527  *os << "which has these unexpected elements: ";
7528  printed_header = true;
7529  }
7530 
7531  UniversalPrint(*it, os);
7532  }
7533  }
7534 
7535  // Now check for missing values.
7536  bool printed_header2 = false;
7537 
7538  for (typename StlContainer::const_iterator it = rhs_.begin();
7539  it != rhs_.end(); ++it)
7540  {
7542  lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
7543  lhs_stl_container.end())
7544  {
7545  if (printed_header2)
7546  {
7547  *os << ", ";
7548  }
7549 
7550  else
7551  {
7552  *os << (printed_header ? ",\nand" : "which")
7553  << " doesn't have these expected elements: ";
7554  printed_header2 = true;
7555  }
7556 
7557  UniversalPrint(*it, os);
7558  }
7559  }
7560  }
7561 
7562  return false;
7563  }
7564 
7565 private:
7566  const StlContainer rhs_;
7567 
7569 };
7570 
7571 // A comparator functor that uses the < operator to compare two values.
7573 {
7574  template <typename T, typename U>
7575  bool operator()(const T & lhs, const U & rhs) const { return lhs < rhs; }
7576 };
7577 
7578 // Implements WhenSortedBy(comparator, container_matcher).
7579 template <typename Comparator, typename ContainerMatcher>
7581 {
7582 public:
7583  WhenSortedByMatcher(const Comparator & comparator,
7584  const ContainerMatcher & matcher)
7585  : comparator_(comparator), matcher_(matcher) {}
7586 
7587  template <typename LhsContainer>
7588  operator Matcher<LhsContainer>() const
7589  {
7590  return MakeMatcher(new Impl<LhsContainer>(comparator_, matcher_));
7591  }
7592 
7593  template <typename LhsContainer>
7594  class Impl : public MatcherInterface<LhsContainer>
7595  {
7596  public:
7597  typedef internal::StlContainerView <
7599  typedef typename LhsView::type LhsStlContainer;
7601  // Transforms std::pair<const Key, Value> into std::pair<Key, Value>
7602  // so that we can match associative containers.
7603  typedef typename RemoveConstFromKey <
7604  typename LhsStlContainer::value_type >::type LhsValue;
7605 
7606  Impl(const Comparator & comparator, const ContainerMatcher & matcher)
7607  : comparator_(comparator), matcher_(matcher) {}
7608 
7609  virtual void DescribeTo(::std::ostream * os) const
7610  {
7611  *os << "(when sorted) ";
7612  matcher_.DescribeTo(os);
7613  }
7614 
7615  virtual void DescribeNegationTo(::std::ostream * os) const
7616  {
7617  *os << "(when sorted) ";
7618  matcher_.DescribeNegationTo(os);
7619  }
7620 
7621  virtual bool MatchAndExplain(LhsContainer lhs,
7622  MatchResultListener * listener) const
7623  {
7624  LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
7625  ::std::vector<LhsValue> sorted_container(lhs_stl_container.begin(),
7626  lhs_stl_container.end());
7627  ::std::sort(
7628  sorted_container.begin(), sorted_container.end(), comparator_);
7629 
7630  if (!listener->IsInterested())
7631  {
7632  // If the listener is not interested, we do not need to
7633  // construct the inner explanation.
7634  return matcher_.Matches(sorted_container);
7635  }
7636 
7637  *listener << "which is ";
7638  UniversalPrint(sorted_container, listener->stream());
7639  *listener << " when sorted";
7640 
7641  StringMatchResultListener inner_listener;
7642  const bool match = matcher_.MatchAndExplain(sorted_container,
7643  &inner_listener);
7644  PrintIfNotEmpty(inner_listener.str(), listener->stream());
7645  return match;
7646  }
7647 
7648  private:
7649  const Comparator comparator_;
7651 
7653  };
7654 
7655 private:
7656  const Comparator comparator_;
7657  const ContainerMatcher matcher_;
7658 
7660 };
7661 
7662 // Implements Pointwise(tuple_matcher, rhs_container). tuple_matcher
7663 // must be able to be safely cast to Matcher<tuple<const T1&, const
7664 // T2&> >, where T1 and T2 are the types of elements in the LHS
7665 // container and the RHS container respectively.
7666 template <typename TupleMatcher, typename RhsContainer>
7668 {
7669 public:
7671  typedef typename RhsView::type RhsStlContainer;
7672  typedef typename RhsStlContainer::value_type RhsValue;
7673 
7674  // Like ContainerEq, we make a copy of rhs in case the elements in
7675  // it are modified after this matcher is created.
7676  PointwiseMatcher(const TupleMatcher & tuple_matcher, const RhsContainer & rhs)
7677  : tuple_matcher_(tuple_matcher), rhs_(RhsView::Copy(rhs))
7678  {
7679  // Makes sure the user doesn't instantiate this class template
7680  // with a const or reference type.
7681  (void)testing::StaticAssertTypeEq<RhsContainer,
7682  GTEST_REMOVE_REFERENCE_AND_CONST_(RhsContainer)>();
7683  }
7684 
7685  template <typename LhsContainer>
7686  operator Matcher<LhsContainer>() const
7687  {
7688  return MakeMatcher(new Impl<LhsContainer>(tuple_matcher_, rhs_));
7689  }
7690 
7691  template <typename LhsContainer>
7692  class Impl : public MatcherInterface<LhsContainer>
7693  {
7694  public:
7695  typedef internal::StlContainerView <
7697  typedef typename LhsView::type LhsStlContainer;
7699  typedef typename LhsStlContainer::value_type LhsValue;
7700  // We pass the LHS value and the RHS value to the inner matcher by
7701  // reference, as they may be expensive to copy. We must use tuple
7702  // instead of pair here, as a pair cannot hold references (C++ 98,
7703  // 20.2.2 [lib.pairs]).
7704  typedef ::std::tr1::tuple<const LhsValue &, const RhsValue &> InnerMatcherArg;
7705 
7706  Impl(const TupleMatcher & tuple_matcher, const RhsStlContainer & rhs)
7707  // mono_tuple_matcher_ holds a monomorphic version of the tuple matcher.
7708  : mono_tuple_matcher_(SafeMatcherCast<InnerMatcherArg>(tuple_matcher)),
7709  rhs_(rhs) {}
7710 
7711  virtual void DescribeTo(::std::ostream * os) const
7712  {
7713  *os << "contains " << rhs_.size()
7714  << " values, where each value and its corresponding value in ";
7716  *os << " ";
7717  mono_tuple_matcher_.DescribeTo(os);
7718  }
7719  virtual void DescribeNegationTo(::std::ostream * os) const
7720  {
7721  *os << "doesn't contain exactly " << rhs_.size()
7722  << " values, or contains a value x at some index i"
7723  << " where x and the i-th value of ";
7724  UniversalPrint(rhs_, os);
7725  *os << " ";
7726  mono_tuple_matcher_.DescribeNegationTo(os);
7727  }
7728 
7729  virtual bool MatchAndExplain(LhsContainer lhs,
7730  MatchResultListener * listener) const
7731  {
7732  LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
7733  const size_t actual_size = lhs_stl_container.size();
7734 
7735  if (actual_size != rhs_.size())
7736  {
7737  *listener << "which contains " << actual_size << " values";
7738  return false;
7739  }
7740 
7741  typename LhsStlContainer::const_iterator left = lhs_stl_container.begin();
7742  typename RhsStlContainer::const_iterator right = rhs_.begin();
7743 
7744  for (size_t i = 0; i != actual_size; ++i, ++left, ++right)
7745  {
7746  const InnerMatcherArg value_pair(*left, *right);
7747 
7748  if (listener->IsInterested())
7749  {
7750  StringMatchResultListener inner_listener;
7751 
7752  if (!mono_tuple_matcher_.MatchAndExplain(
7753  value_pair, &inner_listener))
7754  {
7755  *listener << "where the value pair (";
7756  UniversalPrint(*left, listener->stream());
7757  *listener << ", ";
7758  UniversalPrint(*right, listener->stream());
7759  *listener << ") at index #" << i << " don't match";
7760  PrintIfNotEmpty(inner_listener.str(), listener->stream());
7761  return false;
7762  }
7763  }
7764 
7765  else
7766  {
7767  if (!mono_tuple_matcher_.Matches(value_pair))
7768  { return false; }
7769  }
7770  }
7771 
7772  return true;
7773  }
7774 
7775  private:
7777  const RhsStlContainer rhs_;
7778 
7780  };
7781 
7782 private:
7783  const TupleMatcher tuple_matcher_;
7784  const RhsStlContainer rhs_;
7785 
7787 };
7788 
7789 // Holds the logic common to ContainsMatcherImpl and EachMatcherImpl.
7790 template <typename Container>
7791 class QuantifierMatcherImpl : public MatcherInterface<Container>
7792 {
7793 public:
7794  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
7796  typedef typename View::type StlContainer;
7798  typedef typename StlContainer::value_type Element;
7799 
7800  template <typename InnerMatcher>
7801  explicit QuantifierMatcherImpl(InnerMatcher inner_matcher)
7802  : inner_matcher_(
7803  testing::SafeMatcherCast<const Element & >(inner_matcher)) {}
7804 
7805  // Checks whether:
7806  // * All elements in the container match, if all_elements_should_match.
7807  // * Any element in the container matches, if !all_elements_should_match.
7808  bool MatchAndExplainImpl(bool all_elements_should_match,
7809  Container container,
7810  MatchResultListener * listener) const
7811  {
7812  StlContainerReference stl_container = View::ConstReference(container);
7813  size_t i = 0;
7814 
7815  for (typename StlContainer::const_iterator it = stl_container.begin();
7816  it != stl_container.end(); ++it, ++i)
7817  {
7818  StringMatchResultListener inner_listener;
7819  const bool matches = inner_matcher_.MatchAndExplain(*it, &inner_listener);
7820 
7821  if (matches != all_elements_should_match)
7822  {
7823  *listener << "whose element #" << i
7824  << (matches ? " matches" : " doesn't match");
7825  PrintIfNotEmpty(inner_listener.str(), listener->stream());
7826  return !all_elements_should_match;
7827  }
7828  }
7829 
7830  return all_elements_should_match;
7831  }
7832 
7833 protected:
7835 
7837 };
7838 
7839 // Implements Contains(element_matcher) for the given argument type Container.
7840 // Symmetric to EachMatcherImpl.
7841 template <typename Container>
7843 {
7844 public:
7845  template <typename InnerMatcher>
7846  explicit ContainsMatcherImpl(InnerMatcher inner_matcher)
7847  : QuantifierMatcherImpl<Container>(inner_matcher) {}
7848 
7849  // Describes what this matcher does.
7850  virtual void DescribeTo(::std::ostream * os) const
7851  {
7852  *os << "contains at least one element that ";
7853  this->inner_matcher_.DescribeTo(os);
7854  }
7855 
7856  virtual void DescribeNegationTo(::std::ostream * os) const
7857  {
7858  *os << "doesn't contain any element that ";
7859  this->inner_matcher_.DescribeTo(os);
7860  }
7861 
7862  virtual bool MatchAndExplain(Container container,
7863  MatchResultListener * listener) const
7864  {
7865  return this->MatchAndExplainImpl(false, container, listener);
7866  }
7867 
7868 private:
7870 };
7871 
7872 // Implements Each(element_matcher) for the given argument type Container.
7873 // Symmetric to ContainsMatcherImpl.
7874 template <typename Container>
7875 class EachMatcherImpl : public QuantifierMatcherImpl<Container>
7876 {
7877 public:
7878  template <typename InnerMatcher>
7879  explicit EachMatcherImpl(InnerMatcher inner_matcher)
7880  : QuantifierMatcherImpl<Container>(inner_matcher) {}
7881 
7882  // Describes what this matcher does.
7883  virtual void DescribeTo(::std::ostream * os) const
7884  {
7885  *os << "only contains elements that ";
7886  this->inner_matcher_.DescribeTo(os);
7887  }
7888 
7889  virtual void DescribeNegationTo(::std::ostream * os) const
7890  {
7891  *os << "contains some element that ";
7892  this->inner_matcher_.DescribeNegationTo(os);
7893  }
7894 
7895  virtual bool MatchAndExplain(Container container,
7896  MatchResultListener * listener) const
7897  {
7898  return this->MatchAndExplainImpl(true, container, listener);
7899  }
7900 
7901 private:
7903 };
7904 
7905 // Implements polymorphic Contains(element_matcher).
7906 template <typename M>
7908 {
7909 public:
7910  explicit ContainsMatcher(M m) : inner_matcher_(m) {}
7911 
7912  template <typename Container>
7913  operator Matcher<Container>() const
7914  {
7915  return MakeMatcher(new ContainsMatcherImpl<Container>(inner_matcher_));
7916  }
7917 
7918 private:
7920 
7922 };
7923 
7924 // Implements polymorphic Each(element_matcher).
7925 template <typename M>
7927 {
7928 public:
7929  explicit EachMatcher(M m) : inner_matcher_(m) {}
7930 
7931  template <typename Container>
7932  operator Matcher<Container>() const
7933  {
7934  return MakeMatcher(new EachMatcherImpl<Container>(inner_matcher_));
7935  }
7936 
7937 private:
7939 
7941 };
7942 
7943 // Implements Key(inner_matcher) for the given argument pair type.
7944 // Key(inner_matcher) matches an std::pair whose 'first' field matches
7945 // inner_matcher. For example, Contains(Key(Ge(5))) can be used to match an
7946 // std::map that contains at least one element whose key is >= 5.
7947 template <typename PairType>
7948 class KeyMatcherImpl : public MatcherInterface<PairType>
7949 {
7950 public:
7951  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;
7952  typedef typename RawPairType::first_type KeyType;
7953 
7954  template <typename InnerMatcher>
7955  explicit KeyMatcherImpl(InnerMatcher inner_matcher)
7956  : inner_matcher_(
7957  testing::SafeMatcherCast<const KeyType & >(inner_matcher))
7958  {
7959  }
7960 
7961  // Returns true iff 'key_value.first' (the key) matches the inner matcher.
7962  virtual bool MatchAndExplain(PairType key_value,
7963  MatchResultListener * listener) const
7964  {
7965  StringMatchResultListener inner_listener;
7966  const bool match = inner_matcher_.MatchAndExplain(key_value.first,
7967  &inner_listener);
7968  const internal::string explanation = inner_listener.str();
7969 
7970  if (explanation != "")
7971  {
7972  *listener << "whose first field is a value " << explanation;
7973  }
7974 
7975  return match;
7976  }
7977 
7978  // Describes what this matcher does.
7979  virtual void DescribeTo(::std::ostream * os) const
7980  {
7981  *os << "has a key that ";
7982  inner_matcher_.DescribeTo(os);
7983  }
7984 
7985  // Describes what the negation of this matcher does.
7986  virtual void DescribeNegationTo(::std::ostream * os) const
7987  {
7988  *os << "doesn't have a key that ";
7989  inner_matcher_.DescribeTo(os);
7990  }
7991 
7992 private:
7994 
7996 };
7997 
7998 // Implements polymorphic Key(matcher_for_key).
7999 template <typename M>
8001 {
8002 public:
8003  explicit KeyMatcher(M m) : matcher_for_key_(m) {}
8004 
8005  template <typename PairType>
8006  operator Matcher<PairType>() const
8007  {
8008  return MakeMatcher(new KeyMatcherImpl<PairType>(matcher_for_key_));
8009  }
8010 
8011 private:
8013 
8015 };
8016 
8017 // Implements Pair(first_matcher, second_matcher) for the given argument pair
8018 // type with its two matchers. See Pair() function below.
8019 template <typename PairType>
8020 class PairMatcherImpl : public MatcherInterface<PairType>
8021 {
8022 public:
8023  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;
8024  typedef typename RawPairType::first_type FirstType;
8025  typedef typename RawPairType::second_type SecondType;
8026 
8027  template <typename FirstMatcher, typename SecondMatcher>
8028  PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher)
8029  : first_matcher_(
8030  testing::SafeMatcherCast<const FirstType & >(first_matcher)),
8031  second_matcher_(
8032  testing::SafeMatcherCast<const SecondType & >(second_matcher))
8033  {
8034  }
8035 
8036  // Describes what this matcher does.
8037  virtual void DescribeTo(::std::ostream * os) const
8038  {
8039  *os << "has a first field that ";
8040  first_matcher_.DescribeTo(os);
8041  *os << ", and has a second field that ";
8042  second_matcher_.DescribeTo(os);
8043  }
8044 
8045  // Describes what the negation of this matcher does.
8046  virtual void DescribeNegationTo(::std::ostream * os) const
8047  {
8048  *os << "has a first field that ";
8049  first_matcher_.DescribeNegationTo(os);
8050  *os << ", or has a second field that ";
8051  second_matcher_.DescribeNegationTo(os);
8052  }
8053 
8054  // Returns true iff 'a_pair.first' matches first_matcher and 'a_pair.second'
8055  // matches second_matcher.
8056  virtual bool MatchAndExplain(PairType a_pair,
8057  MatchResultListener * listener) const
8058  {
8059  if (!listener->IsInterested())
8060  {
8061  // If the listener is not interested, we don't need to construct the
8062  // explanation.
8063  return first_matcher_.Matches(a_pair.first) &&
8064  second_matcher_.Matches(a_pair.second);
8065  }
8066 
8067  StringMatchResultListener first_inner_listener;
8068 
8069  if (!first_matcher_.MatchAndExplain(a_pair.first,
8070  &first_inner_listener))
8071  {
8072  *listener << "whose first field does not match";
8073  PrintIfNotEmpty(first_inner_listener.str(), listener->stream());
8074  return false;
8075  }
8076 
8077  StringMatchResultListener second_inner_listener;
8078 
8079  if (!second_matcher_.MatchAndExplain(a_pair.second,
8080  &second_inner_listener))
8081  {
8082  *listener << "whose second field does not match";
8083  PrintIfNotEmpty(second_inner_listener.str(), listener->stream());
8084  return false;
8085  }
8086 
8087  ExplainSuccess(first_inner_listener.str(), second_inner_listener.str(),
8088  listener);
8089  return true;
8090  }
8091 
8092 private:
8093  void ExplainSuccess(const internal::string & first_explanation,
8094  const internal::string & second_explanation,
8095  MatchResultListener * listener) const
8096  {
8097  *listener << "whose both fields match";
8098 
8099  if (first_explanation != "")
8100  {
8101  *listener << ", where the first field is a value " << first_explanation;
8102  }
8103 
8104  if (second_explanation != "")
8105  {
8106  *listener << ", ";
8107 
8108  if (first_explanation != "")
8109  {
8110  *listener << "and ";
8111  }
8112 
8113  else
8114  {
8115  *listener << "where ";
8116  }
8117 
8118  *listener << "the second field is a value " << second_explanation;
8119  }
8120  }
8121 
8124 
8126 };
8127 
8128 // Implements polymorphic Pair(first_matcher, second_matcher).
8129 template <typename FirstMatcher, typename SecondMatcher>
8131 {
8132 public:
8133  PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher)
8134  : first_matcher_(first_matcher), second_matcher_(second_matcher) {}
8135 
8136  template <typename PairType>
8137  operator Matcher<PairType> () const
8138  {
8139  return MakeMatcher(
8141  first_matcher_, second_matcher_));
8142  }
8143 
8144 private:
8145  const FirstMatcher first_matcher_;
8146  const SecondMatcher second_matcher_;
8147 
8149 };
8150 
8151 // Implements ElementsAre() and ElementsAreArray().
8152 template <typename Container>
8153 class ElementsAreMatcherImpl : public MatcherInterface<Container>
8154 {
8155 public:
8156  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
8158  typedef typename View::type StlContainer;
8160  typedef typename StlContainer::value_type Element;
8161 
8162  // Constructs the matcher from a sequence of element values or
8163  // element matchers.
8164  template <typename InputIter>
8165  ElementsAreMatcherImpl(InputIter first, InputIter last)
8166  {
8167  while (first != last)
8168  {
8169  matchers_.push_back(MatcherCast<const Element &>(*first++));
8170  }
8171  }
8172 
8173  // Describes what this matcher does.
8174  virtual void DescribeTo(::std::ostream * os) const
8175  {
8176  if (count() == 0)
8177  {
8178  *os << "is empty";
8179  }
8180 
8181  else if (count() == 1)
8182  {
8183  *os << "has 1 element that ";
8184  matchers_[0].DescribeTo(os);
8185  }
8186 
8187  else
8188  {
8189  *os << "has " << Elements(count()) << " where\n";
8190 
8191  for (size_t i = 0; i != count(); ++i)
8192  {
8193  *os << "element #" << i << " ";
8194  matchers_[i].DescribeTo(os);
8195 
8196  if (i + 1 < count())
8197  {
8198  *os << ",\n";
8199  }
8200  }
8201  }
8202  }
8203 
8204  // Describes what the negation of this matcher does.
8205  virtual void DescribeNegationTo(::std::ostream * os) const
8206  {
8207  if (count() == 0)
8208  {
8209  *os << "isn't empty";
8210  return;
8211  }
8212 
8213  *os << "doesn't have " << Elements(count()) << ", or\n";
8214 
8215  for (size_t i = 0; i != count(); ++i)
8216  {
8217  *os << "element #" << i << " ";
8218  matchers_[i].DescribeNegationTo(os);
8219 
8220  if (i + 1 < count())
8221  {
8222  *os << ", or\n";
8223  }
8224  }
8225  }
8226 
8227  virtual bool MatchAndExplain(Container container,
8228  MatchResultListener * listener) const
8229  {
8230  // To work with stream-like "containers", we must only walk
8231  // through the elements in one pass.
8232 
8233  const bool listener_interested = listener->IsInterested();
8234 
8235  // explanations[i] is the explanation of the element at index i.
8236  ::std::vector<internal::string> explanations(count());
8237  StlContainerReference stl_container = View::ConstReference(container);
8238  typename StlContainer::const_iterator it = stl_container.begin();
8239  size_t exam_pos = 0;
8240  bool mismatch_found = false; // Have we found a mismatched element yet?
8241 
8242  // Go through the elements and matchers in pairs, until we reach
8243  // the end of either the elements or the matchers, or until we find a
8244  // mismatch.
8245  for (; it != stl_container.end() && exam_pos != count(); ++it, ++exam_pos)
8246  {
8247  bool match; // Does the current element match the current matcher?
8248 
8249  if (listener_interested)
8250  {
8252  match = matchers_[exam_pos].MatchAndExplain(*it, &s);
8253  explanations[exam_pos] = s.str();
8254  }
8255 
8256  else
8257  {
8258  match = matchers_[exam_pos].Matches(*it);
8259  }
8260 
8261  if (!match)
8262  {
8263  mismatch_found = true;
8264  break;
8265  }
8266  }
8267 
8268  // If mismatch_found is true, 'exam_pos' is the index of the mismatch.
8269 
8270  // Find how many elements the actual container has. We avoid
8271  // calling size() s.t. this code works for stream-like "containers"
8272  // that don't define size().
8273  size_t actual_count = exam_pos;
8274 
8275  for (; it != stl_container.end(); ++it)
8276  {
8277  ++actual_count;
8278  }
8279 
8280  if (actual_count != count())
8281  {
8282  // The element count doesn't match. If the container is empty,
8283  // there's no need to explain anything as Google Mock already
8284  // prints the empty container. Otherwise we just need to show
8285  // how many elements there actually are.
8286  if (listener_interested && (actual_count != 0))
8287  {
8288  *listener << "which has " << Elements(actual_count);
8289  }
8290 
8291  return false;
8292  }
8293 
8294  if (mismatch_found)
8295  {
8296  // The element count matches, but the exam_pos-th element doesn't match.
8297  if (listener_interested)
8298  {
8299  *listener << "whose element #" << exam_pos << " doesn't match";
8300  PrintIfNotEmpty(explanations[exam_pos], listener->stream());
8301  }
8302 
8303  return false;
8304  }
8305 
8306  // Every element matches its expectation. We need to explain why
8307  // (the obvious ones can be skipped).
8308  if (listener_interested)
8309  {
8310  bool reason_printed = false;
8311 
8312  for (size_t i = 0; i != count(); ++i)
8313  {
8314  const internal::string & s = explanations[i];
8315 
8316  if (!s.empty())
8317  {
8318  if (reason_printed)
8319  {
8320  *listener << ",\nand ";
8321  }
8322 
8323  *listener << "whose element #" << i << " matches, " << s;
8324  reason_printed = true;
8325  }
8326  }
8327  }
8328 
8329  return true;
8330  }
8331 
8332 private:
8333  static Message Elements(size_t count)
8334  {
8335  return Message() << count << (count == 1 ? " element" : " elements");
8336  }
8337 
8338  size_t count() const { return matchers_.size(); }
8339 
8340  ::std::vector<Matcher<const Element &> > matchers_;
8341 
8343 };
8344 
8345 // Connectivity matrix of (elements X matchers), in element-major order.
8346 // Initially, there are no edges.
8347 // Use NextGraph() to iterate over all possible edge configurations.
8348 // Use Randomize() to generate a random edge configuration.
8350 {
8351 public:
8352  MatchMatrix(size_t num_elements, size_t num_matchers)
8353  : num_elements_(num_elements),
8354  num_matchers_(num_matchers),
8355  matched_(num_elements_ * num_matchers_, 0)
8356  {
8357  }
8358 
8359  size_t LhsSize() const { return num_elements_; }
8360  size_t RhsSize() const { return num_matchers_; }
8361  bool HasEdge(size_t ilhs, size_t irhs) const
8362  {
8363  return matched_[SpaceIndex(ilhs, irhs)] == 1;
8364  }
8365  void SetEdge(size_t ilhs, size_t irhs, bool b)
8366  {
8367  matched_[SpaceIndex(ilhs, irhs)] = b ? 1 : 0;
8368  }
8369 
8370  // Treating the connectivity matrix as a (LhsSize()*RhsSize())-bit number,
8371  // adds 1 to that number; returns false if incrementing the graph left it
8372  // empty.
8373  bool NextGraph();
8374 
8375  void Randomize();
8376 
8377  string DebugString() const;
8378 
8379 private:
8380  size_t SpaceIndex(size_t ilhs, size_t irhs) const
8381  {
8382  return ilhs * num_matchers_ + irhs;
8383  }
8384 
8387 
8388  // Each element is a char interpreted as bool. They are stored as a
8389  // flattened array in lhs-major order, use 'SpaceIndex()' to translate
8390  // a (ilhs, irhs) matrix coordinate into an offset.
8391  ::std::vector<char> matched_;
8392 };
8393 
8394 typedef ::std::pair<size_t, size_t> ElementMatcherPair;
8395 typedef ::std::vector<ElementMatcherPair> ElementMatcherPairs;
8396 
8397 // Returns a maximum bipartite matching for the specified graph 'g'.
8398 // The matching is represented as a vector of {element, matcher} pairs.
8399 GTEST_API_ ElementMatcherPairs
8401 
8402 GTEST_API_ bool FindPairing(const MatchMatrix & matrix,
8403  MatchResultListener * listener);
8404 
8405 // Untyped base class for implementing UnorderedElementsAre. By
8406 // putting logic that's not specific to the element type here, we
8407 // reduce binary bloat and increase compilation speed.
8409 {
8410 protected:
8411  // A vector of matcher describers, one for each element matcher.
8412  // Does not own the describers (and thus can be used only when the
8413  // element matchers are alive).
8414  typedef ::std::vector<const MatcherDescriberInterface *> MatcherDescriberVec;
8415 
8416  // Describes this UnorderedElementsAre matcher.
8417  void DescribeToImpl(::std::ostream * os) const;
8418 
8419  // Describes the negation of this UnorderedElementsAre matcher.
8420  void DescribeNegationToImpl(::std::ostream * os) const;
8421 
8422  bool VerifyAllElementsAndMatchersAreMatched(
8423  const ::std::vector<string> & element_printouts,
8424  const MatchMatrix & matrix,
8425  MatchResultListener * listener) const;
8426 
8427  MatcherDescriberVec & matcher_describers()
8428  {
8429  return matcher_describers_;
8430  }
8431 
8432  static Message Elements(size_t n)
8433  {
8434  return Message() << n << " element" << (n == 1 ? "" : "s");
8435  }
8436 
8437 private:
8438  MatcherDescriberVec matcher_describers_;
8439 
8441 };
8442 
8443 // Implements unordered ElementsAre and unordered ElementsAreArray.
8444 template <typename Container>
8446  : public MatcherInterface<Container>,
8448 {
8449 public:
8450  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
8452  typedef typename View::type StlContainer;
8454  typedef typename StlContainer::const_iterator StlContainerConstIterator;
8455  typedef typename StlContainer::value_type Element;
8456 
8457  // Constructs the matcher from a sequence of element values or
8458  // element matchers.
8459  template <typename InputIter>
8460  UnorderedElementsAreMatcherImpl(InputIter first, InputIter last)
8461  {
8462  for (; first != last; ++first)
8463  {
8464  matchers_.push_back(MatcherCast<const Element &>(*first));
8465  matcher_describers().push_back(matchers_.back().GetDescriber());
8466  }
8467  }
8468 
8469  // Describes what this matcher does.
8470  virtual void DescribeTo(::std::ostream * os) const
8471  {
8472  return UnorderedElementsAreMatcherImplBase::DescribeToImpl(os);
8473  }
8474 
8475  // Describes what the negation of this matcher does.
8476  virtual void DescribeNegationTo(::std::ostream * os) const
8477  {
8478  return UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl(os);
8479  }
8480 
8481  virtual bool MatchAndExplain(Container container,
8482  MatchResultListener * listener) const
8483  {
8484  StlContainerReference stl_container = View::ConstReference(container);
8485  ::std::vector<string> element_printouts;
8486  MatchMatrix matrix = AnalyzeElements(stl_container.begin(),
8487  stl_container.end(),
8488  &element_printouts,
8489  listener);
8490 
8491  const size_t actual_count = matrix.LhsSize();
8492 
8493  if (actual_count == 0 && matchers_.empty())
8494  {
8495  return true;
8496  }
8497 
8498  if (actual_count != matchers_.size())
8499  {
8500  // The element count doesn't match. If the container is empty,
8501  // there's no need to explain anything as Google Mock already
8502  // prints the empty container. Otherwise we just need to show
8503  // how many elements there actually are.
8504  if (actual_count != 0 && listener->IsInterested())
8505  {
8506  *listener << "which has " << Elements(actual_count);
8507  }
8508 
8509  return false;
8510  }
8511 
8512  return VerifyAllElementsAndMatchersAreMatched(element_printouts,
8513  matrix, listener) &&
8514  FindPairing(matrix, listener);
8515  }
8516 
8517 private:
8518  typedef ::std::vector<Matcher<const Element &> > MatcherVec;
8519 
8520  template <typename ElementIter>
8521  MatchMatrix AnalyzeElements(ElementIter elem_first, ElementIter elem_last,
8522  ::std::vector<string> * element_printouts,
8523  MatchResultListener * listener) const
8524  {
8525  element_printouts->clear();
8526  ::std::vector<char> did_match;
8527  size_t num_elements = 0;
8528 
8529  for (; elem_first != elem_last; ++num_elements, ++elem_first)
8530  {
8531  if (listener->IsInterested())
8532  {
8533  element_printouts->push_back(PrintToString(*elem_first));
8534  }
8535 
8536  for (size_t irhs = 0; irhs != matchers_.size(); ++irhs)
8537  {
8538  did_match.push_back(Matches(matchers_[irhs])(*elem_first));
8539  }
8540  }
8541 
8542  MatchMatrix matrix(num_elements, matchers_.size());
8543  ::std::vector<char>::const_iterator did_match_iter = did_match.begin();
8544 
8545  for (size_t ilhs = 0; ilhs != num_elements; ++ilhs)
8546  {
8547  for (size_t irhs = 0; irhs != matchers_.size(); ++irhs)
8548  {
8549  matrix.SetEdge(ilhs, irhs, *did_match_iter++ != 0);
8550  }
8551  }
8552 
8553  return matrix;
8554  }
8555 
8556  MatcherVec matchers_;
8557 
8559 };
8560 
8561 // Functor for use in TransformTuple.
8562 // Performs MatcherCast<Target> on an input argument of any type.
8563 template <typename Target>
8565 {
8566  template <typename Arg>
8567  Matcher<Target> operator()(const Arg & a) const
8568  {
8569  return MatcherCast<Target>(a);
8570  }
8571 };
8572 
8573 // Implements UnorderedElementsAre.
8574 template <typename MatcherTuple>
8576 {
8577 public:
8579  : matchers_(args) {}
8580 
8581  template <typename Container>
8582  operator Matcher<Container>() const
8583  {
8584  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
8586  typedef typename View::value_type Element;
8587  typedef ::std::vector<Matcher<const Element &> > MatcherVec;
8588  MatcherVec matchers;
8589  matchers.reserve(::std::tr1::tuple_size<MatcherTuple>::value);
8591  ::std::back_inserter(matchers));
8593  matchers.begin(), matchers.end()));
8594  }
8595 
8596 private:
8599 };
8600 
8601 // Implements ElementsAre.
8602 template <typename MatcherTuple>
8604 {
8605 public:
8606  explicit ElementsAreMatcher(const MatcherTuple & args) : matchers_(args) {}
8607 
8608  template <typename Container>
8609  operator Matcher<Container>() const
8610  {
8611  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
8613  typedef typename View::value_type Element;
8614  typedef ::std::vector<Matcher<const Element &> > MatcherVec;
8615  MatcherVec matchers;
8616  matchers.reserve(::std::tr1::tuple_size<MatcherTuple>::value);
8618  ::std::back_inserter(matchers));
8620  matchers.begin(), matchers.end()));
8621  }
8622 
8623 private:
8626 };
8627 
8628 // Implements UnorderedElementsAreArray().
8629 template <typename T>
8631 {
8632 public:
8634 
8635  template <typename Iter>
8637  : matchers_(first, last) {}
8638 
8639  template <typename Container>
8640  operator Matcher<Container>() const
8641  {
8642  return MakeMatcher(
8643  new UnorderedElementsAreMatcherImpl<Container>(matchers_.begin(),
8644  matchers_.end()));
8645  }
8646 
8647 private:
8648  ::std::vector<T> matchers_;
8649 
8651 };
8652 
8653 // Implements ElementsAreArray().
8654 template <typename T>
8656 {
8657 public:
8658  template <typename Iter>
8659  ElementsAreArrayMatcher(Iter first, Iter last) : matchers_(first, last) {}
8660 
8661  template <typename Container>
8662  operator Matcher<Container>() const
8663  {
8665  matchers_.begin(), matchers_.end()));
8666  }
8667 
8668 private:
8669  const ::std::vector<T> matchers_;
8670 
8672 };
8673 
8674 // Returns the description for a matcher defined using the MATCHER*()
8675 // macro where the user-supplied description string is "", if
8676 // 'negation' is false; otherwise returns the description of the
8677 // negation of the matcher. 'param_values' contains a list of strings
8678 // that are the print-out of the matcher's parameters.
8679 GTEST_API_ string FormatMatcherDescription(bool negation,
8680  const char * matcher_name,
8681  const Strings & param_values);
8682 
8683 } // namespace internal
8684 
8685 // ElementsAreArray(first, last)
8686 // ElementsAreArray(pointer, count)
8687 // ElementsAreArray(array)
8688 // ElementsAreArray(vector)
8689 // ElementsAreArray({ e1, e2, ..., en })
8690 //
8691 // The ElementsAreArray() functions are like ElementsAre(...), except
8692 // that they are given a homogeneous sequence rather than taking each
8693 // element as a function argument. The sequence can be specified as an
8694 // array, a pointer and count, a vector, an initializer list, or an
8695 // STL iterator range. In each of these cases, the underlying sequence
8696 // can be either a sequence of values or a sequence of matchers.
8697 //
8698 // All forms of ElementsAreArray() make a copy of the input matcher sequence.
8699 
8700 template <typename Iter>
8702 typename ::std::iterator_traits<Iter>::value_type >
8704 {
8705  typedef typename ::std::iterator_traits<Iter>::value_type T;
8706  return internal::ElementsAreArrayMatcher<T>(first, last);
8707 }
8708 
8709 template <typename T>
8711  const T * pointer, size_t count)
8712 {
8713  return ElementsAreArray(pointer, pointer + count);
8714 }
8715 
8716 template <typename T, size_t N>
8718  const T(&array)[N])
8719 {
8720  return ElementsAreArray(array, N);
8721 }
8722 
8723 template <typename T, typename A>
8725  const ::std::vector<T, A> & vec)
8726 {
8727  return ElementsAreArray(vec.begin(), vec.end());
8728 }
8729 
8730 #if GTEST_LANG_CXX11
8731 template <typename T>
8733 ElementsAreArray(::std::initializer_list<T> xs)
8734 {
8735  return ElementsAreArray(xs.begin(), xs.end());
8736 }
8737 #endif
8738 
8739 // UnorderedElementsAreArray(first, last)
8740 // UnorderedElementsAreArray(pointer, count)
8741 // UnorderedElementsAreArray(array)
8742 // UnorderedElementsAreArray(vector)
8743 // UnorderedElementsAreArray({ e1, e2, ..., en })
8744 //
8745 // The UnorderedElementsAreArray() functions are like
8746 // ElementsAreArray(...), but allow matching the elements in any order.
8747 template <typename Iter>
8749 typename ::std::iterator_traits<Iter>::value_type >
8751 {
8752  typedef typename ::std::iterator_traits<Iter>::value_type T;
8754 }
8755 
8756 template <typename T>
8758 UnorderedElementsAreArray(const T * pointer, size_t count)
8759 {
8760  return UnorderedElementsAreArray(pointer, pointer + count);
8761 }
8762 
8763 template <typename T, size_t N>
8765 UnorderedElementsAreArray(const T(&array)[N])
8766 {
8767  return UnorderedElementsAreArray(array, N);
8768 }
8769 
8770 template <typename T, typename A>
8772 UnorderedElementsAreArray(const ::std::vector<T, A> & vec)
8773 {
8774  return UnorderedElementsAreArray(vec.begin(), vec.end());
8775 }
8776 
8777 #if GTEST_LANG_CXX11
8778 template <typename T>
8780 UnorderedElementsAreArray(::std::initializer_list<T> xs)
8781 {
8782  return UnorderedElementsAreArray(xs.begin(), xs.end());
8783 }
8784 #endif
8785 
8786 // _ is a matcher that matches anything of any type.
8787 //
8788 // This definition is fine as:
8789 //
8790 // 1. The C++ standard permits using the name _ in a namespace that
8791 // is not the global namespace or ::std.
8792 // 2. The AnythingMatcher class has no data member or constructor,
8793 // so it's OK to create global variables of this type.
8794 // 3. c-style has approved of using _ in this case.
8796 // Creates a matcher that matches any value of the given type T.
8797 template <typename T>
8799 
8800 // Creates a matcher that matches any value of the given type T.
8801 template <typename T>
8802 inline Matcher<T> An() { return A<T>(); }
8803 
8804 // Creates a polymorphic matcher that matches anything equal to x.
8805 // Note: if the parameter of Eq() were declared as const T&, Eq("foo")
8806 // wouldn't compile.
8807 template <typename T>
8808 inline internal::EqMatcher<T> Eq(T x) { return internal::EqMatcher<T>(x); }
8809 
8810 // Constructs a Matcher<T> from a 'value' of type T. The constructed
8811 // matcher matches any value that's equal to 'value'.
8812 template <typename T>
8813 Matcher<T>::Matcher(T value) { *this = Eq(value); }
8814 
8815 // Creates a monomorphic matcher that matches anything with type Lhs
8816 // and equal to rhs. A user may need to use this instead of Eq(...)
8817 // in order to resolve an overloading ambiguity.
8818 //
8819 // TypedEq<T>(x) is just a convenient short-hand for Matcher<T>(Eq(x))
8820 // or Matcher<T>(x), but more readable than the latter.
8821 //
8822 // We could define similar monomorphic matchers for other comparison
8823 // operations (e.g. TypedLt, TypedGe, and etc), but decided not to do
8824 // it yet as those are used much less than Eq() in practice. A user
8825 // can always write Matcher<T>(Lt(5)) to be explicit about the type,
8826 // for example.
8827 template <typename Lhs, typename Rhs>
8828 inline Matcher<Lhs> TypedEq(const Rhs & rhs) { return Eq(rhs); }
8829 
8830 // Creates a polymorphic matcher that matches anything >= x.
8831 template <typename Rhs>
8832 inline internal::GeMatcher<Rhs> Ge(Rhs x)
8833 {
8834  return internal::GeMatcher<Rhs>(x);
8835 }
8836 
8837 // Creates a polymorphic matcher that matches anything > x.
8838 template <typename Rhs>
8839 inline internal::GtMatcher<Rhs> Gt(Rhs x)
8840 {
8841  return internal::GtMatcher<Rhs>(x);
8842 }
8843 
8844 // Creates a polymorphic matcher that matches anything <= x.
8845 template <typename Rhs>
8846 inline internal::LeMatcher<Rhs> Le(Rhs x)
8847 {
8848  return internal::LeMatcher<Rhs>(x);
8849 }
8850 
8851 // Creates a polymorphic matcher that matches anything < x.
8852 template <typename Rhs>
8853 inline internal::LtMatcher<Rhs> Lt(Rhs x)
8854 {
8855  return internal::LtMatcher<Rhs>(x);
8856 }
8857 
8858 // Creates a polymorphic matcher that matches anything != x.
8859 template <typename Rhs>
8860 inline internal::NeMatcher<Rhs> Ne(Rhs x)
8861 {
8862  return internal::NeMatcher<Rhs>(x);
8863 }
8864 
8865 // Creates a polymorphic matcher that matches any NULL pointer.
8867 {
8869 }
8870 
8871 // Creates a polymorphic matcher that matches any non-NULL pointer.
8872 // This is convenient as Not(NULL) doesn't compile (the compiler
8873 // thinks that that expression is comparing a pointer with an integer).
8875 {
8877 }
8878 
8879 // Creates a polymorphic matcher that matches any argument that
8880 // references variable x.
8881 template <typename T>
8882 inline internal::RefMatcher<T &> Ref(T & x) // NOLINT
8883 {
8884  return internal::RefMatcher<T &>(x);
8885 }
8886 
8887 // Creates a matcher that matches any double argument approximately
8888 // equal to rhs, where two NANs are considered unequal.
8890 {
8891  return internal::FloatingEqMatcher<double>(rhs, false);
8892 }
8893 
8894 // Creates a matcher that matches any double argument approximately
8895 // equal to rhs, including NaN values when rhs is NaN.
8897 {
8898  return internal::FloatingEqMatcher<double>(rhs, true);
8899 }
8900 
8901 // Creates a matcher that matches any double argument approximately equal to
8902 // rhs, up to the specified max absolute error bound, where two NANs are
8903 // considered unequal. The max absolute error bound must be non-negative.
8905  double rhs, double max_abs_error)
8906 {
8907  return internal::FloatingEqMatcher<double>(rhs, false, max_abs_error);
8908 }
8909 
8910 // Creates a matcher that matches any double argument approximately equal to
8911 // rhs, up to the specified max absolute error bound, including NaN values when
8912 // rhs is NaN. The max absolute error bound must be non-negative.
8914  double rhs, double max_abs_error)
8915 {
8916  return internal::FloatingEqMatcher<double>(rhs, true, max_abs_error);
8917 }
8918 
8919 // Creates a matcher that matches any float argument approximately
8920 // equal to rhs, where two NANs are considered unequal.
8922 {
8923  return internal::FloatingEqMatcher<float>(rhs, false);
8924 }
8925 
8926 // Creates a matcher that matches any float argument approximately
8927 // equal to rhs, including NaN values when rhs is NaN.
8929 {
8930  return internal::FloatingEqMatcher<float>(rhs, true);
8931 }
8932 
8933 // Creates a matcher that matches any float argument approximately equal to
8934 // rhs, up to the specified max absolute error bound, where two NANs are
8935 // considered unequal. The max absolute error bound must be non-negative.
8937  float rhs, float max_abs_error)
8938 {
8939  return internal::FloatingEqMatcher<float>(rhs, false, max_abs_error);
8940 }
8941 
8942 // Creates a matcher that matches any float argument approximately equal to
8943 // rhs, up to the specified max absolute error bound, including NaN values when
8944 // rhs is NaN. The max absolute error bound must be non-negative.
8946  float rhs, float max_abs_error)
8947 {
8948  return internal::FloatingEqMatcher<float>(rhs, true, max_abs_error);
8949 }
8950 
8951 // Creates a matcher that matches a pointer (raw or smart) that points
8952 // to a value that matches inner_matcher.
8953 template <typename InnerMatcher>
8955  const InnerMatcher & inner_matcher)
8956 {
8957  return internal::PointeeMatcher<InnerMatcher>(inner_matcher);
8958 }
8959 
8960 // Creates a matcher that matches an object whose given field matches
8961 // 'matcher'. For example,
8962 // Field(&Foo::number, Ge(5))
8963 // matches a Foo object x iff x.number >= 5.
8964 template <typename Class, typename FieldType, typename FieldMatcher>
8965 inline PolymorphicMatcher <
8967  FieldType Class::*field, const FieldMatcher & matcher)
8968 {
8969  return MakePolymorphicMatcher(
8971  field, MatcherCast<const FieldType &>(matcher)));
8972  // The call to MatcherCast() is required for supporting inner
8973  // matchers of compatible types. For example, it allows
8974  // Field(&Foo::bar, m)
8975  // to compile where bar is an int32 and m is a matcher for int64.
8976 }
8977 
8978 // Creates a matcher that matches an object whose given property
8979 // matches 'matcher'. For example,
8980 // Property(&Foo::str, StartsWith("hi"))
8981 // matches a Foo object x iff x.str() starts with "hi".
8982 template <typename Class, typename PropertyType, typename PropertyMatcher>
8983 inline PolymorphicMatcher <
8985  PropertyType(Class::*property)() const, const PropertyMatcher & matcher)
8986 {
8987  return MakePolymorphicMatcher(
8989  property,
8990  MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
8991  // The call to MatcherCast() is required for supporting inner
8992  // matchers of compatible types. For example, it allows
8993  // Property(&Foo::bar, m)
8994  // to compile where bar() returns an int32 and m is a matcher for int64.
8995 }
8996 
8997 // Creates a matcher that matches an object iff the result of applying
8998 // a callable to x matches 'matcher'.
8999 // For example,
9000 // ResultOf(f, StartsWith("hi"))
9001 // matches a Foo object x iff f(x) starts with "hi".
9002 // callable parameter can be a function, function pointer, or a functor.
9003 // Callable has to satisfy the following conditions:
9004 // * It is required to keep no state affecting the results of
9005 // the calls on it and make no assumptions about how many calls
9006 // will be made. Any state it keeps must be protected from the
9007 // concurrent access.
9008 // * If it is a function object, it has to define type result_type.
9009 // We recommend deriving your functor classes from std::unary_function.
9010 template <typename Callable, typename ResultOfMatcher>
9012  Callable callable, const ResultOfMatcher & matcher)
9013 {
9015  callable,
9016  MatcherCast<typename internal::CallableTraits<Callable>::ResultType>(
9017  matcher));
9018  // The call to MatcherCast() is required for supporting inner
9019  // matchers of compatible types. For example, it allows
9020  // ResultOf(Function, m)
9021  // to compile where Function() returns an int32 and m is a matcher for int64.
9022 }
9023 
9024 // String matchers.
9025 
9026 // Matches a string equal to str.
9029 {
9031  str, true, true));
9032 }
9033 
9034 // Matches a string not equal to str.
9037 {
9039  str, false, true));
9040 }
9041 
9042 // Matches a string equal to str, ignoring case.
9045 {
9047  str, true, false));
9048 }
9049 
9050 // Matches a string not equal to str, ignoring case.
9053 {
9055  str, false, false));
9056 }
9057 
9058 // Creates a matcher that matches any string, std::string, or C string
9059 // that contains the given substring.
9061 HasSubstr(const internal::string & substring)
9062 {
9064  substring));
9065 }
9066 
9067 // Matches a string that starts with 'prefix' (case-sensitive).
9070 {
9072  prefix));
9073 }
9074 
9075 // Matches a string that ends with 'suffix' (case-sensitive).
9078 {
9080  suffix));
9081 }
9082 
9083 // Matches a string that fully matches regular expression 'regex'.
9084 // The matcher takes ownership of 'regex'.
9086  const internal::RE * regex)
9087 {
9089 }
9091  const internal::string & regex)
9092 {
9093  return MatchesRegex(new internal::RE(regex));
9094 }
9095 
9096 // Matches a string that contains regular expression 'regex'.
9097 // The matcher takes ownership of 'regex'.
9099  const internal::RE * regex)
9100 {
9102 }
9104  const internal::string & regex)
9105 {
9106  return ContainsRegex(new internal::RE(regex));
9107 }
9108 
9109 #if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
9110 // Wide string matchers.
9111 
9112 // Matches a string equal to str.
9114 StrEq(const internal::wstring & str)
9115 {
9117  str, true, true));
9118 }
9119 
9120 // Matches a string not equal to str.
9122 StrNe(const internal::wstring & str)
9123 {
9125  str, false, true));
9126 }
9127 
9128 // Matches a string equal to str, ignoring case.
9130 StrCaseEq(const internal::wstring & str)
9131 {
9133  str, true, false));
9134 }
9135 
9136 // Matches a string not equal to str, ignoring case.
9138 StrCaseNe(const internal::wstring & str)
9139 {
9141  str, false, false));
9142 }
9143 
9144 // Creates a matcher that matches any wstring, std::wstring, or C wide string
9145 // that contains the given substring.
9147 HasSubstr(const internal::wstring & substring)
9148 {
9150  substring));
9151 }
9152 
9153 // Matches a string that starts with 'prefix' (case-sensitive).
9155 StartsWith(const internal::wstring & prefix)
9156 {
9158  prefix));
9159 }
9160 
9161 // Matches a string that ends with 'suffix' (case-sensitive).
9163 EndsWith(const internal::wstring & suffix)
9164 {
9166  suffix));
9167 }
9168 
9169 #endif // GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
9170 
9171 // Creates a polymorphic matcher that matches a 2-tuple where the
9172 // first field == the second field.
9173 inline internal::Eq2Matcher Eq() { return internal::Eq2Matcher(); }
9174 
9175 // Creates a polymorphic matcher that matches a 2-tuple where the
9176 // first field >= the second field.
9177 inline internal::Ge2Matcher Ge() { return internal::Ge2Matcher(); }
9178 
9179 // Creates a polymorphic matcher that matches a 2-tuple where the
9180 // first field > the second field.
9181 inline internal::Gt2Matcher Gt() { return internal::Gt2Matcher(); }
9182 
9183 // Creates a polymorphic matcher that matches a 2-tuple where the
9184 // first field <= the second field.
9185 inline internal::Le2Matcher Le() { return internal::Le2Matcher(); }
9186 
9187 // Creates a polymorphic matcher that matches a 2-tuple where the
9188 // first field < the second field.
9189 inline internal::Lt2Matcher Lt() { return internal::Lt2Matcher(); }
9190 
9191 // Creates a polymorphic matcher that matches a 2-tuple where the
9192 // first field != the second field.
9193 inline internal::Ne2Matcher Ne() { return internal::Ne2Matcher(); }
9194 
9195 // Creates a matcher that matches any value of type T that m doesn't
9196 // match.
9197 template <typename InnerMatcher>
9199 {
9201 }
9202 
9203 // Returns a matcher that matches anything that satisfies the given
9204 // predicate. The predicate can be any unary function or functor
9205 // whose return type can be implicitly converted to bool.
9206 template <typename Predicate>
9208 Truly(Predicate pred)
9209 {
9211 }
9212 
9213 // Returns a matcher that matches the container size. The container must
9214 // support both size() and size_type which all STL-like containers provide.
9215 // Note that the parameter 'size' can be a value of type size_type as well as
9216 // matcher. For instance:
9217 // EXPECT_THAT(container, SizeIs(2)); // Checks container has 2 elements.
9218 // EXPECT_THAT(container, SizeIs(Le(2)); // Checks container has at most 2.
9219 template <typename SizeMatcher>
9221 SizeIs(const SizeMatcher & size_matcher)
9222 {
9223  return internal::SizeIsMatcher<SizeMatcher>(size_matcher);
9224 }
9225 
9226 // Returns a matcher that matches an equal container.
9227 // This matcher behaves like Eq(), but in the event of mismatch lists the
9228 // values that are included in one container but not the other. (Duplicate
9229 // values and order differences are not explained.)
9230 template <typename Container>
9232 GTEST_REMOVE_CONST_(Container)> >
9233 ContainerEq(const Container & rhs)
9234 {
9235  // This following line is for working around a bug in MSVC 8.0,
9236  // which causes Container to be a const type sometimes.
9237  typedef GTEST_REMOVE_CONST_(Container) RawContainer;
9238  return MakePolymorphicMatcher(
9240 }
9241 
9242 // Returns a matcher that matches a container that, when sorted using
9243 // the given comparator, matches container_matcher.
9244 template <typename Comparator, typename ContainerMatcher>
9246 WhenSortedBy(const Comparator & comparator,
9247  const ContainerMatcher & container_matcher)
9248 {
9250  comparator, container_matcher);
9251 }
9252 
9253 // Returns a matcher that matches a container that, when sorted using
9254 // the < operator, matches container_matcher.
9255 template <typename ContainerMatcher>
9257 WhenSorted(const ContainerMatcher & container_matcher)
9258 {
9259  return
9261  internal::LessComparator(), container_matcher);
9262 }
9263 
9264 // Matches an STL-style container or a native array that contains the
9265 // same number of elements as in rhs, where its i-th element and rhs's
9266 // i-th element (as a pair) satisfy the given pair matcher, for all i.
9267 // TupleMatcher must be able to be safely cast to Matcher<tuple<const
9268 // T1&, const T2&> >, where T1 and T2 are the types of elements in the
9269 // LHS container and the RHS container respectively.
9270 template <typename TupleMatcher, typename Container>
9271 inline internal::PointwiseMatcher<TupleMatcher,
9272  GTEST_REMOVE_CONST_(Container)>
9273  Pointwise(const TupleMatcher & tuple_matcher, const Container & rhs)
9274 {
9275  // This following line is for working around a bug in MSVC 8.0,
9276  // which causes Container to be a const type sometimes.
9277  typedef GTEST_REMOVE_CONST_(Container) RawContainer;
9279  tuple_matcher, rhs);
9280 }
9281 
9282 // Matches an STL-style container or a native array that contains at
9283 // least one element matching the given value or matcher.
9284 //
9285 // Examples:
9286 // ::std::set<int> page_ids;
9287 // page_ids.insert(3);
9288 // page_ids.insert(1);
9289 // EXPECT_THAT(page_ids, Contains(1));
9290 // EXPECT_THAT(page_ids, Contains(Gt(2)));
9291 // EXPECT_THAT(page_ids, Not(Contains(4)));
9292 //
9293 // ::std::map<int, size_t> page_lengths;
9294 // page_lengths[1] = 100;
9295 // EXPECT_THAT(page_lengths,
9296 // Contains(::std::pair<const int, size_t>(1, 100)));
9297 //
9298 // const char* user_ids[] = { "joe", "mike", "tom" };
9299 // EXPECT_THAT(user_ids, Contains(Eq(::std::string("tom"))));
9300 template <typename M>
9302 {
9303  return internal::ContainsMatcher<M>(matcher);
9304 }
9305 
9306 // Matches an STL-style container or a native array that contains only
9307 // elements matching the given value or matcher.
9308 //
9309 // Each(m) is semantically equivalent to Not(Contains(Not(m))). Only
9310 // the messages are different.
9311 //
9312 // Examples:
9313 // ::std::set<int> page_ids;
9314 // // Each(m) matches an empty container, regardless of what m is.
9315 // EXPECT_THAT(page_ids, Each(Eq(1)));
9316 // EXPECT_THAT(page_ids, Each(Eq(77)));
9317 //
9318 // page_ids.insert(3);
9319 // EXPECT_THAT(page_ids, Each(Gt(0)));
9320 // EXPECT_THAT(page_ids, Not(Each(Gt(4))));
9321 // page_ids.insert(1);
9322 // EXPECT_THAT(page_ids, Not(Each(Lt(2))));
9323 //
9324 // ::std::map<int, size_t> page_lengths;
9325 // page_lengths[1] = 100;
9326 // page_lengths[2] = 200;
9327 // page_lengths[3] = 300;
9328 // EXPECT_THAT(page_lengths, Not(Each(Pair(1, 100))));
9329 // EXPECT_THAT(page_lengths, Each(Key(Le(3))));
9330 //
9331 // const char* user_ids[] = { "joe", "mike", "tom" };
9332 // EXPECT_THAT(user_ids, Not(Each(Eq(::std::string("tom")))));
9333 template <typename M>
9335 {
9336  return internal::EachMatcher<M>(matcher);
9337 }
9338 
9339 // Key(inner_matcher) matches an std::pair whose 'first' field matches
9340 // inner_matcher. For example, Contains(Key(Ge(5))) can be used to match an
9341 // std::map that contains at least one element whose key is >= 5.
9342 template <typename M>
9343 inline internal::KeyMatcher<M> Key(M inner_matcher)
9344 {
9345  return internal::KeyMatcher<M>(inner_matcher);
9346 }
9347 
9348 // Pair(first_matcher, second_matcher) matches a std::pair whose 'first' field
9349 // matches first_matcher and whose 'second' field matches second_matcher. For
9350 // example, EXPECT_THAT(map_type, ElementsAre(Pair(Ge(5), "foo"))) can be used
9351 // to match a std::map<int, string> that contains exactly one element whose key
9352 // is >= 5 and whose value equals "foo".
9353 template <typename FirstMatcher, typename SecondMatcher>
9355 Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
9356 {
9358  first_matcher, second_matcher);
9359 }
9360 
9361 // Returns a predicate that is satisfied by anything that matches the
9362 // given matcher.
9363 template <typename M>
9365 {
9366  return internal::MatcherAsPredicate<M>(matcher);
9367 }
9368 
9369 // Returns true iff the value matches the matcher.
9370 template <typename T, typename M>
9371 inline bool Value(const T & value, M matcher)
9372 {
9373  return testing::Matches(matcher)(value);
9374 }
9375 
9376 // Matches the value against the given matcher and explains the match
9377 // result to listener.
9378 template <typename T, typename M>
9380  M matcher, const T & value, MatchResultListener * listener)
9381 {
9382  return SafeMatcherCast<const T &>(matcher).MatchAndExplain(value, listener);
9383 }
9384 
9385 #if GTEST_LANG_CXX11
9386 // Define variadic matcher versions. They are overloaded in
9387 // gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
9388 template <typename... Args>
9389 inline internal::AllOfMatcher<Args...> AllOf(const Args & ... matchers)
9390 {
9391  return internal::AllOfMatcher<Args...>(matchers...);
9392 }
9393 
9394 template <typename... Args>
9395 inline internal::AnyOfMatcher<Args...> AnyOf(const Args & ... matchers)
9396 {
9397  return internal::AnyOfMatcher<Args...>(matchers...);
9398 }
9399 
9400 #endif // GTEST_LANG_CXX11
9401 
9402 // AllArgs(m) is a synonym of m. This is useful in
9403 //
9404 // EXPECT_CALL(foo, Bar(_, _)).With(AllArgs(Eq()));
9405 //
9406 // which is easier to read than
9407 //
9408 // EXPECT_CALL(foo, Bar(_, _)).With(Eq());
9409 template <typename InnerMatcher>
9410 inline InnerMatcher AllArgs(const InnerMatcher & matcher) { return matcher; }
9411 
9412 // These macros allow using matchers to check values in Google Test
9413 // tests. ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher)
9414 // succeed iff the value matches the matcher. If the assertion fails,
9415 // the value and the description of the matcher will be printed.
9416 #define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\
9417  ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
9418 #define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\
9419  ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
9420 
9421 } // namespace testing
9422 
9423 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
9424 
9425 namespace testing
9426 {
9427 
9428 // An abstract handle of an expectation.
9429 class Expectation;
9430 
9431 // A set of expectation handles.
9432 class ExpectationSet;
9433 
9434 // Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
9435 // and MUST NOT BE USED IN USER CODE!!!
9436 namespace internal
9437 {
9438 
9439 // Implements a mock function.
9440 template <typename F> class FunctionMocker;
9441 
9442 // Base class for expectations.
9443 class ExpectationBase;
9444 
9445 // Implements an expectation.
9446 template <typename F> class TypedExpectation;
9447 
9448 // Helper class for testing the Expectation class template.
9449 class ExpectationTester;
9450 
9451 // Base class for function mockers.
9452 template <typename F> class FunctionMockerBase;
9453 
9454 // Protects the mock object registry (in class Mock), all function
9455 // mockers, and all expectations.
9456 //
9457 // The reason we don't use more fine-grained protection is: when a
9458 // mock function Foo() is called, it needs to consult its expectations
9459 // to see which one should be picked. If another thread is allowed to
9460 // call a mock function (either Foo() or a different one) at the same
9461 // time, it could affect the "retired" attributes of Foo()'s
9462 // expectations when InSequence() is used, and thus affect which
9463 // expectation gets picked. Therefore, we sequence all mock function
9464 // calls to ensure the integrity of the mock objects' states.
9466 
9467 // Untyped base class for ActionResultHolder<R>.
9469 
9470 // Abstract base class of FunctionMockerBase. This is the
9471 // type-agnostic part of the function mocker interface. Its pure
9472 // virtual methods are implemented by FunctionMockerBase.
9474 {
9475 public:
9477  virtual ~UntypedFunctionMockerBase();
9478 
9479  // Verifies that all expectations on this mock function have been
9480  // satisfied. Reports one or more Google Test non-fatal failures
9481  // and returns false if not.
9482  bool VerifyAndClearExpectationsLocked()
9483  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
9484 
9485  // Clears the ON_CALL()s set on this mock function.
9486  virtual void ClearDefaultActionsLocked()
9487  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) = 0;
9488 
9489  // In all of the following Untyped* functions, it's the caller's
9490  // responsibility to guarantee the correctness of the arguments'
9491  // types.
9492 
9493  // Performs the default action with the given arguments and returns
9494  // the action's result. The call description string will be used in
9495  // the error message to describe the call in the case the default
9496  // action fails.
9497  // L = *
9498  virtual UntypedActionResultHolderBase * UntypedPerformDefaultAction(
9499  const void * untyped_args,
9500  const string & call_description) const = 0;
9501 
9502  // Performs the given action with the given arguments and returns
9503  // the action's result.
9504  // L = *
9505  virtual UntypedActionResultHolderBase * UntypedPerformAction(
9506  const void * untyped_action,
9507  const void * untyped_args) const = 0;
9508 
9509  // Writes a message that the call is uninteresting (i.e. neither
9510  // explicitly expected nor explicitly unexpected) to the given
9511  // ostream.
9512  virtual void UntypedDescribeUninterestingCall(
9513  const void * untyped_args,
9514  ::std::ostream * os) const
9515  GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
9516 
9517  // Returns the expectation that matches the given function arguments
9518  // (or NULL is there's no match); when a match is found,
9519  // untyped_action is set to point to the action that should be
9520  // performed (or NULL if the action is "do default"), and
9521  // is_excessive is modified to indicate whether the call exceeds the
9522  // expected number.
9523  virtual const ExpectationBase * UntypedFindMatchingExpectation(
9524  const void * untyped_args,
9525  const void ** untyped_action, bool * is_excessive,
9526  ::std::ostream * what, ::std::ostream * why)
9527  GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
9528 
9529  // Prints the given function arguments to the ostream.
9530  virtual void UntypedPrintArgs(const void * untyped_args,
9531  ::std::ostream * os) const = 0;
9532 
9533  // Sets the mock object this mock method belongs to, and registers
9534  // this information in the global mock registry. Will be called
9535  // whenever an EXPECT_CALL() or ON_CALL() is executed on this mock
9536  // method.
9537  // TODO(wan@google.com): rename to SetAndRegisterOwner().
9538  void RegisterOwner(const void * mock_obj)
9539  GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
9540 
9541  // Sets the mock object this mock method belongs to, and sets the
9542  // name of the mock function. Will be called upon each invocation
9543  // of this mock function.
9544  void SetOwnerAndName(const void * mock_obj, const char * name)
9545  GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
9546 
9547  // Returns the mock object this mock method belongs to. Must be
9548  // called after RegisterOwner() or SetOwnerAndName() has been
9549  // called.
9550  const void * MockObject() const
9551  GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
9552 
9553  // Returns the name of this mock method. Must be called after
9554  // SetOwnerAndName() has been called.
9555  const char * Name() const
9556  GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
9557 
9558  // Returns the result of invoking this mock function with the given
9559  // arguments. This function can be safely called from multiple
9560  // threads concurrently. The caller is responsible for deleting the
9561  // result.
9562  const UntypedActionResultHolderBase * UntypedInvokeWith(
9563  const void * untyped_args)
9564  GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
9565 
9566 protected:
9567  typedef std::vector<const void *> UntypedOnCallSpecs;
9568 
9569  typedef std::vector<internal::linked_ptr<ExpectationBase> >
9571 
9572  // Returns an Expectation object that references and co-owns exp,
9573  // which must be an expectation on this mock function.
9574  Expectation GetHandleOf(ExpectationBase * exp);
9575 
9576  // Address of the mock object this mock method belongs to. Only
9577  // valid after this mock method has been called or
9578  // ON_CALL/EXPECT_CALL has been invoked on it.
9579  const void * mock_obj_; // Protected by g_gmock_mutex.
9580 
9581  // Name of the function being mocked. Only valid after this mock
9582  // method has been called.
9583  const char * name_; // Protected by g_gmock_mutex.
9584 
9585  // All default action specs for this function mocker.
9586  UntypedOnCallSpecs untyped_on_call_specs_;
9587 
9588  // All expectations for this function mocker.
9590 }; // class UntypedFunctionMockerBase
9591 
9592 // Untyped base class for OnCallSpec<F>.
9594 {
9595 public:
9596  // The arguments are the location of the ON_CALL() statement.
9597  UntypedOnCallSpecBase(const char * a_file, int a_line)
9598  : file_(a_file), line_(a_line), last_clause_(kNone) {}
9599 
9600  // Where in the source file was the default action spec defined?
9601  const char * file() const { return file_; }
9602  int line() const { return line_; }
9603 
9604 protected:
9605  // Gives each clause in the ON_CALL() statement a name.
9606  enum Clause
9607  {
9608  // Do not change the order of the enum members! The run-time
9609  // syntax checking relies on it.
9612  kWillByDefault
9613  };
9614 
9615  // Asserts that the ON_CALL() statement has a certain property.
9616  void AssertSpecProperty(bool property, const string & failure_message) const
9617  {
9618  Assert(property, file_, line_, failure_message);
9619  }
9620 
9621  // Expects that the ON_CALL() statement has a certain property.
9622  void ExpectSpecProperty(bool property, const string & failure_message) const
9623  {
9624  Expect(property, file_, line_, failure_message);
9625  }
9626 
9627  const char * file_;
9628  int line_;
9629 
9630  // The last clause in the ON_CALL() statement as seen so far.
9631  // Initially kNone and changes as the statement is parsed.
9633 }; // class UntypedOnCallSpecBase
9634 
9635 // This template class implements an ON_CALL spec.
9636 template <typename F>
9638 {
9639 public:
9642 
9643  // Constructs an OnCallSpec object from the information inside
9644  // the parenthesis of an ON_CALL() statement.
9645  OnCallSpec(const char * a_file, int a_line,
9646  const ArgumentMatcherTuple & matchers)
9647  : UntypedOnCallSpecBase(a_file, a_line),
9648  matchers_(matchers),
9649  // By default, extra_matcher_ should match anything. However,
9650  // we cannot initialize it with _ as that triggers a compiler
9651  // bug in Symbian's C++ compiler (cannot decide between two
9652  // overloaded constructors of Matcher<const ArgumentTuple&>).
9653  extra_matcher_(A<const ArgumentTuple & >())
9654  {
9655  }
9656 
9657  // Implements the .With() clause.
9659  {
9660  // Makes sure this is called at most once.
9661  ExpectSpecProperty(last_clause_ < kWith,
9662  ".With() cannot appear "
9663  "more than once in an ON_CALL().");
9664  last_clause_ = kWith;
9665 
9666  extra_matcher_ = m;
9667  return *this;
9668  }
9669 
9670  // Implements the .WillByDefault() clause.
9672  {
9673  ExpectSpecProperty(last_clause_ < kWillByDefault,
9674  ".WillByDefault() must appear "
9675  "exactly once in an ON_CALL().");
9676  last_clause_ = kWillByDefault;
9677 
9678  ExpectSpecProperty(!action.IsDoDefault(),
9679  "DoDefault() cannot be used in ON_CALL().");
9680  action_ = action;
9681  return *this;
9682  }
9683 
9684  // Returns true iff the given arguments match the matchers.
9685  bool Matches(const ArgumentTuple & args) const
9686  {
9687  return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
9688  }
9689 
9690  // Returns the action specified by the user.
9691  const Action<F> & GetAction() const
9692  {
9693  AssertSpecProperty(last_clause_ == kWillByDefault,
9694  ".WillByDefault() must appear exactly "
9695  "once in an ON_CALL().");
9696  return action_;
9697  }
9698 
9699 private:
9700  // The information in statement
9701  //
9702  // ON_CALL(mock_object, Method(matchers))
9703  // .With(multi-argument-matcher)
9704  // .WillByDefault(action);
9705  //
9706  // is recorded in the data members like this:
9707  //
9708  // source file that contains the statement => file_
9709  // line number of the statement => line_
9710  // matchers => matchers_
9711  // multi-argument-matcher => extra_matcher_
9712  // action => action_
9713  ArgumentMatcherTuple matchers_;
9716 }; // class OnCallSpec
9717 
9718 // Possible reactions on uninteresting calls.
9720 {
9724  kDefault = kWarn // By default, warn about uninteresting calls.
9725 };
9726 
9727 } // namespace internal
9728 
9729 // Utilities for manipulating mock objects.
9731 {
9732 public:
9733  // The following public methods can be called concurrently.
9734 
9735  // Tells Google Mock to ignore mock_obj when checking for leaked
9736  // mock objects.
9737  static void AllowLeak(const void * mock_obj)
9738  GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
9739 
9740  // Verifies and clears all expectations on the given mock object.
9741  // If the expectations aren't satisfied, generates one or more
9742  // Google Test non-fatal failures and returns false.
9743  static bool VerifyAndClearExpectations(void * mock_obj)
9744  GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
9745 
9746  // Verifies all expectations on the given mock object and clears its
9747  // default actions and expectations. Returns true iff the
9748  // verification was successful.
9749  static bool VerifyAndClear(void * mock_obj)
9750  GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
9751 
9752 private:
9754 
9755  // Needed for a function mocker to register itself (so that we know
9756  // how to clear a mock object).
9757  template <typename F>
9759 
9760  template <typename M>
9761  friend class NiceMock;
9762 
9763  template <typename M>
9764  friend class NaggyMock;
9765 
9766  template <typename M>
9767  friend class StrictMock;
9768 
9769  // Tells Google Mock to allow uninteresting calls on the given mock
9770  // object.
9771  static void AllowUninterestingCalls(const void * mock_obj)
9772  GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
9773 
9774  // Tells Google Mock to warn the user about uninteresting calls on
9775  // the given mock object.
9776  static void WarnUninterestingCalls(const void * mock_obj)
9777  GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
9778 
9779  // Tells Google Mock to fail uninteresting calls on the given mock
9780  // object.
9781  static void FailUninterestingCalls(const void * mock_obj)
9782  GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
9783 
9784  // Tells Google Mock the given mock object is being destroyed and
9785  // its entry in the call-reaction table should be removed.
9786  static void UnregisterCallReaction(const void * mock_obj)
9787  GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
9788 
9789  // Returns the reaction Google Mock will have on uninteresting calls
9790  // made on the given mock object.
9791  static internal::CallReaction GetReactionOnUninterestingCalls(
9792  const void * mock_obj)
9793  GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
9794 
9795  // Verifies that all expectations on the given mock object have been
9796  // satisfied. Reports one or more Google Test non-fatal failures
9797  // and returns false if not.
9798  static bool VerifyAndClearExpectationsLocked(void * mock_obj)
9799  GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
9800 
9801  // Clears all ON_CALL()s set on the given mock object.
9802  static void ClearDefaultActionsLocked(void * mock_obj)
9803  GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
9804 
9805  // Registers a mock object and a mock method it owns.
9806  static void Register(
9807  const void * mock_obj,
9809  GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
9810 
9811  // Tells Google Mock where in the source code mock_obj is used in an
9812  // ON_CALL or EXPECT_CALL. In case mock_obj is leaked, this
9813  // information helps the user identify which object it is.
9814  static void RegisterUseByOnCallOrExpectCall(
9815  const void * mock_obj, const char * file, int line)
9816  GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
9817 
9818  // Unregisters a mock method; removes the owning mock object from
9819  // the registry when the last mock method associated with it has
9820  // been unregistered. This is called only in the destructor of
9821  // FunctionMockerBase.
9822  static void UnregisterLocked(internal::UntypedFunctionMockerBase * mocker)
9823  GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
9824 }; // class Mock
9825 
9826 // An abstract handle of an expectation. Useful in the .After()
9827 // clause of EXPECT_CALL() for setting the (partial) order of
9828 // expectations. The syntax:
9829 //
9830 // Expectation e1 = EXPECT_CALL(...)...;
9831 // EXPECT_CALL(...).After(e1)...;
9832 //
9833 // sets two expectations where the latter can only be matched after
9834 // the former has been satisfied.
9835 //
9836 // Notes:
9837 // - This class is copyable and has value semantics.
9838 // - Constness is shallow: a const Expectation object itself cannot
9839 // be modified, but the mutable methods of the ExpectationBase
9840 // object it references can be called via expectation_base().
9841 // - The constructors and destructor are defined out-of-line because
9842 // the Symbian WINSCW compiler wants to otherwise instantiate them
9843 // when it sees this class definition, at which point it doesn't have
9844 // ExpectationBase available yet, leading to incorrect destruction
9845 // in the linked_ptr (or compilation errors if using a checking
9846 // linked_ptr).
9848 {
9849 public:
9850  // Constructs a null object that doesn't reference any expectation.
9851  Expectation();
9852 
9853  ~Expectation();
9854 
9855  // This single-argument ctor must not be explicit, in order to support the
9856  // Expectation e = EXPECT_CALL(...);
9857  // syntax.
9858  //
9859  // A TypedExpectation object stores its pre-requisites as
9860  // Expectation objects, and needs to call the non-const Retire()
9861  // method on the ExpectationBase objects they reference. Therefore
9862  // Expectation must receive a *non-const* reference to the
9863  // ExpectationBase object.
9864  Expectation(internal::ExpectationBase & exp); // NOLINT
9865 
9866  // The compiler-generated copy ctor and operator= work exactly as
9867  // intended, so we don't need to define our own.
9868 
9869  // Returns true iff rhs references the same expectation as this object does.
9870  bool operator==(const Expectation & rhs) const
9871  {
9872  return expectation_base_ == rhs.expectation_base_;
9873  }
9874 
9875  bool operator!=(const Expectation & rhs) const { return !(*this == rhs); }
9876 
9877 private:
9878  friend class ExpectationSet;
9879  friend class Sequence;
9880  friend class ::testing::internal::ExpectationBase;
9881  friend class ::testing::internal::UntypedFunctionMockerBase;
9882 
9883  template <typename F>
9884  friend class ::testing::internal::FunctionMockerBase;
9885 
9886  template <typename F>
9887  friend class ::testing::internal::TypedExpectation;
9888 
9889  // This comparator is needed for putting Expectation objects into a set.
9890  class Less
9891  {
9892  public:
9893  bool operator()(const Expectation & lhs, const Expectation & rhs) const
9894  {
9895  return lhs.expectation_base_.get() < rhs.expectation_base_.get();
9896  }
9897  };
9898 
9899  typedef ::std::set<Expectation, Less> Set;
9900 
9901  Expectation(
9902  const internal::linked_ptr<internal::ExpectationBase> & expectation_base);
9903 
9904  // Returns the expectation this object references.
9907  {
9908  return expectation_base_;
9909  }
9910 
9911  // A linked_ptr that co-owns the expectation this handle references.
9913 };
9914 
9915 // A set of expectation handles. Useful in the .After() clause of
9916 // EXPECT_CALL() for setting the (partial) order of expectations. The
9917 // syntax:
9918 //
9919 // ExpectationSet es;
9920 // es += EXPECT_CALL(...)...;
9921 // es += EXPECT_CALL(...)...;
9922 // EXPECT_CALL(...).After(es)...;
9923 //
9924 // sets three expectations where the last one can only be matched
9925 // after the first two have both been satisfied.
9926 //
9927 // This class is copyable and has value semantics.
9929 {
9930 public:
9931  // A bidirectional iterator that can read a const element in the set.
9932  typedef Expectation::Set::const_iterator const_iterator;
9933 
9934  // An object stored in the set. This is an alias of Expectation.
9935  typedef Expectation::Set::value_type value_type;
9936 
9937  // Constructs an empty set.
9939 
9940  // This single-argument ctor must not be explicit, in order to support the
9941  // ExpectationSet es = EXPECT_CALL(...);
9942  // syntax.
9944  {
9945  *this += Expectation(exp);
9946  }
9947 
9948  // This single-argument ctor implements implicit conversion from
9949  // Expectation and thus must not be explicit. This allows either an
9950  // Expectation or an ExpectationSet to be used in .After().
9951  ExpectationSet(const Expectation & e) // NOLINT
9952  {
9953  *this += e;
9954  }
9955 
9956  // The compiler-generator ctor and operator= works exactly as
9957  // intended, so we don't need to define our own.
9958 
9959  // Returns true iff rhs contains the same set of Expectation objects
9960  // as this does.
9961  bool operator==(const ExpectationSet & rhs) const
9962  {
9963  return expectations_ == rhs.expectations_;
9964  }
9965 
9966  bool operator!=(const ExpectationSet & rhs) const { return !(*this == rhs); }
9967 
9968  // Implements the syntax
9969  // expectation_set += EXPECT_CALL(...);
9971  {
9972  expectations_.insert(e);
9973  return *this;
9974  }
9975 
9976  int size() const { return static_cast<int>(expectations_.size()); }
9977 
9978  const_iterator begin() const { return expectations_.begin(); }
9979  const_iterator end() const { return expectations_.end(); }
9980 
9981 private:
9983 };
9984 
9985 
9986 // Sequence objects are used by a user to specify the relative order
9987 // in which the expectations should match. They are copyable (we rely
9988 // on the compiler-defined copy constructor and assignment operator).
9990 {
9991 public:
9992  // Constructs an empty sequence.
9993  Sequence() : last_expectation_(new Expectation) {}
9994 
9995  // Adds an expectation to this sequence. The caller must ensure
9996  // that no other thread is accessing this Sequence object.
9997  void AddExpectation(const Expectation & expectation) const;
9998 
9999 private:
10000  // The last expectation in this sequence. We use a linked_ptr here
10001  // because Sequence objects are copyable and we want the copies to
10002  // be aliases. The linked_ptr allows the copies to co-own and share
10003  // the same Expectation object.
10005 }; // class Sequence
10006 
10007 // An object of this type causes all EXPECT_CALL() statements
10008 // encountered in its scope to be put in an anonymous sequence. The
10009 // work is done in the constructor and destructor. You should only
10010 // create an InSequence object on the stack.
10011 //
10012 // The sole purpose for this class is to support easy definition of
10013 // sequential expectations, e.g.
10014 //
10015 // {
10016 // InSequence dummy; // The name of the object doesn't matter.
10017 //
10018 // // The following expectations must match in the order they appear.
10019 // EXPECT_CALL(a, Bar())...;
10020 // EXPECT_CALL(a, Baz())...;
10021 // ...
10022 // EXPECT_CALL(b, Xyz())...;
10023 // }
10024 //
10025 // You can create InSequence objects in multiple threads, as long as
10026 // they are used to affect different mock objects. The idea is that
10027 // each thread can create and set up its own mocks as if it's the only
10028 // thread. However, for clarity of your tests we recommend you to set
10029 // up mocks in the main thread unless you have a good reason not to do
10030 // so.
10032 {
10033 public:
10034  InSequence();
10035  ~InSequence();
10036 private:
10038 
10041 
10042 namespace internal
10043 {
10044 
10045 // Points to the implicit sequence introduced by a living InSequence
10046 // object (if any) in the current thread or NULL.
10047 GTEST_API_ extern ThreadLocal<Sequence *> g_gmock_implicit_sequence;
10048 
10049 // Base class for implementing expectations.
10050 //
10051 // There are two reasons for having a type-agnostic base class for
10052 // Expectation:
10053 //
10054 // 1. We need to store collections of expectations of different
10055 // types (e.g. all pre-requisites of a particular expectation, all
10056 // expectations in a sequence). Therefore these expectation objects
10057 // must share a common base class.
10058 //
10059 // 2. We can avoid binary code bloat by moving methods not depending
10060 // on the template argument of Expectation to the base class.
10061 //
10062 // This class is internal and mustn't be used by user code directly.
10064 {
10065 public:
10066  // source_text is the EXPECT_CALL(...) source that created this Expectation.
10067  ExpectationBase(const char * file, int line, const string & source_text);
10068 
10069  virtual ~ExpectationBase();
10070 
10071  // Where in the source file was the expectation spec defined?
10072  const char * file() const { return file_; }
10073  int line() const { return line_; }
10074  const char * source_text() const { return source_text_.c_str(); }
10075  // Returns the cardinality specified in the expectation spec.
10076  const Cardinality & cardinality() const { return cardinality_; }
10077 
10078  // Describes the source file location of this expectation.
10079  void DescribeLocationTo(::std::ostream * os) const
10080  {
10081  *os << FormatFileLocation(file(), line()) << " ";
10082  }
10083 
10084  // Describes how many times a function call matching this
10085  // expectation has occurred.
10086  void DescribeCallCountTo(::std::ostream * os) const
10087  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
10088 
10089  // If this mock method has an extra matcher (i.e. .With(matcher)),
10090  // describes it to the ostream.
10091  virtual void MaybeDescribeExtraMatcherTo(::std::ostream * os) = 0;
10092 
10093 protected:
10094  friend class ::testing::Expectation;
10096 
10097  enum Clause
10098  {
10099  // Don't change the order of the enum members!
10107  kRetiresOnSaturation
10108  };
10109 
10110  typedef std::vector<const void *> UntypedActions;
10111 
10112  // Returns an Expectation object that references and co-owns this
10113  // expectation.
10114  virtual Expectation GetHandle() = 0;
10115 
10116  // Asserts that the EXPECT_CALL() statement has the given property.
10117  void AssertSpecProperty(bool property, const string & failure_message) const
10118  {
10119  Assert(property, file_, line_, failure_message);
10120  }
10121 
10122  // Expects that the EXPECT_CALL() statement has the given property.
10123  void ExpectSpecProperty(bool property, const string & failure_message) const
10124  {
10125  Expect(property, file_, line_, failure_message);
10126  }
10127 
10128  // Explicitly specifies the cardinality of this expectation. Used
10129  // by the subclasses to implement the .Times() clause.
10130  void SpecifyCardinality(const Cardinality & cardinality);
10131 
10132  // Returns true iff the user specified the cardinality explicitly
10133  // using a .Times().
10134  bool cardinality_specified() const { return cardinality_specified_; }
10135 
10136  // Sets the cardinality of this expectation spec.
10137  void set_cardinality(const Cardinality & a_cardinality)
10138  {
10139  cardinality_ = a_cardinality;
10140  }
10141 
10142  // The following group of methods should only be called after the
10143  // EXPECT_CALL() statement, and only when g_gmock_mutex is held by
10144  // the current thread.
10145 
10146  // Retires all pre-requisites of this expectation.
10147  void RetireAllPreRequisites()
10148  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
10149 
10150  // Returns true iff this expectation is retired.
10151  bool is_retired() const
10152  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10153  {
10154  g_gmock_mutex.AssertHeld();
10155  return retired_;
10156  }
10157 
10158  // Retires this expectation.
10159  void Retire()
10160  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10161  {
10162  g_gmock_mutex.AssertHeld();
10163  retired_ = true;
10164  }
10165 
10166  // Returns true iff this expectation is satisfied.
10167  bool IsSatisfied() const
10168  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10169  {
10170  g_gmock_mutex.AssertHeld();
10171  return cardinality().IsSatisfiedByCallCount(call_count_);
10172  }
10173 
10174  // Returns true iff this expectation is saturated.
10175  bool IsSaturated() const
10176  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10177  {
10178  g_gmock_mutex.AssertHeld();
10179  return cardinality().IsSaturatedByCallCount(call_count_);
10180  }
10181 
10182  // Returns true iff this expectation is over-saturated.
10183  bool IsOverSaturated() const
10184  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10185  {
10186  g_gmock_mutex.AssertHeld();
10187  return cardinality().IsOverSaturatedByCallCount(call_count_);
10188  }
10189 
10190  // Returns true iff all pre-requisites of this expectation are satisfied.
10191  bool AllPrerequisitesAreSatisfied() const
10192  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
10193 
10194  // Adds unsatisfied pre-requisites of this expectation to 'result'.
10195  void FindUnsatisfiedPrerequisites(ExpectationSet * result) const
10196  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
10197 
10198  // Returns the number this expectation has been invoked.
10199  int call_count() const
10200  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10201  {
10202  g_gmock_mutex.AssertHeld();
10203  return call_count_;
10204  }
10205 
10206  // Increments the number this expectation has been invoked.
10208  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10209  {
10210  g_gmock_mutex.AssertHeld();
10211  call_count_++;
10212  }
10213 
10214  // Checks the action count (i.e. the number of WillOnce() and
10215  // WillRepeatedly() clauses) against the cardinality if this hasn't
10216  // been done before. Prints a warning if there are too many or too
10217  // few actions.
10218  void CheckActionCountIfNotDone() const
10219  GTEST_LOCK_EXCLUDED_(mutex_);
10220 
10221  friend class ::testing::Sequence;
10222  friend class ::testing::internal::ExpectationTester;
10223 
10224  template <typename Function>
10225  friend class TypedExpectation;
10226 
10227  // Implements the .Times() clause.
10228  void UntypedTimes(const Cardinality & a_cardinality);
10229 
10230  // This group of fields are part of the spec and won't change after
10231  // an EXPECT_CALL() statement finishes.
10232  const char * file_; // The file that contains the expectation.
10233  int line_; // The line number of the expectation.
10234  const string source_text_; // The EXPECT_CALL(...) source text.
10235  // True iff the cardinality is specified explicitly.
10237  Cardinality cardinality_; // The cardinality of the expectation.
10238  // The immediate pre-requisites (i.e. expectations that must be
10239  // satisfied before this expectation can be matched) of this
10240  // expectation. We use linked_ptr in the set because we want an
10241  // Expectation object to be co-owned by its FunctionMocker and its
10242  // successors. This allows multiple mock objects to be deleted at
10243  // different times.
10245 
10246  // This group of fields are the current state of the expectation,
10247  // and can change as the mock function is called.
10248  int call_count_; // How many times this expectation has been invoked.
10249  bool retired_; // True iff this expectation has retired.
10250  UntypedActions untyped_actions_;
10252  bool repeated_action_specified_; // True if a WillRepeatedly() was specified.
10255  mutable bool action_count_checked_; // Under mutex_.
10256  mutable Mutex mutex_; // Protects action_count_checked_.
10257 
10259 }; // class ExpectationBase
10260 
10261 // Impements an expectation for the given function type.
10262 template <typename F>
10263 class TypedExpectation : public ExpectationBase
10264 {
10265 public:
10268  typedef typename Function<F>::Result Result;
10269 
10271  const char * a_file, int a_line, const string & a_source_text,
10272  const ArgumentMatcherTuple & m)
10273  : ExpectationBase(a_file, a_line, a_source_text),
10274  owner_(owner),
10275  matchers_(m),
10276  // By default, extra_matcher_ should match anything. However,
10277  // we cannot initialize it with _ as that triggers a compiler
10278  // bug in Symbian's C++ compiler (cannot decide between two
10279  // overloaded constructors of Matcher<const ArgumentTuple&>).
10280  extra_matcher_(A<const ArgumentTuple & >()),
10281  repeated_action_(DoDefault()) {}
10282 
10284  {
10285  // Check the validity of the action count if it hasn't been done
10286  // yet (for example, if the expectation was never used).
10287  CheckActionCountIfNotDone();
10288 
10289  for (UntypedActions::const_iterator it = untyped_actions_.begin();
10290  it != untyped_actions_.end(); ++it)
10291  {
10292  delete static_cast<const Action<F>*>(*it);
10293  }
10294  }
10295 
10296  // Implements the .With() clause.
10298  {
10299  if (last_clause_ == kWith)
10300  {
10301  ExpectSpecProperty(false,
10302  ".With() cannot appear "
10303  "more than once in an EXPECT_CALL().");
10304  }
10305 
10306  else
10307  {
10308  ExpectSpecProperty(last_clause_ < kWith,
10309  ".With() must be the first "
10310  "clause in an EXPECT_CALL().");
10311  }
10312 
10313  last_clause_ = kWith;
10314 
10315  extra_matcher_ = m;
10316  extra_matcher_specified_ = true;
10317  return *this;
10318  }
10319 
10320  // Implements the .Times() clause.
10321  TypedExpectation & Times(const Cardinality & a_cardinality)
10322  {
10323  ExpectationBase::UntypedTimes(a_cardinality);
10324  return *this;
10325  }
10326 
10327  // Implements the .Times() clause.
10329  {
10330  return Times(Exactly(n));
10331  }
10332 
10333  // Implements the .InSequence() clause.
10335  {
10336  ExpectSpecProperty(last_clause_ <= kInSequence,
10337  ".InSequence() cannot appear after .After(),"
10338  " .WillOnce(), .WillRepeatedly(), or "
10339  ".RetiresOnSaturation().");
10340  last_clause_ = kInSequence;
10341 
10342  s.AddExpectation(GetHandle());
10343  return *this;
10344  }
10345  TypedExpectation & InSequence(const Sequence & s1, const Sequence & s2)
10346  {
10347  return InSequence(s1).InSequence(s2);
10348  }
10349  TypedExpectation & InSequence(const Sequence & s1, const Sequence & s2,
10350  const Sequence & s3)
10351  {
10352  return InSequence(s1, s2).InSequence(s3);
10353  }
10354  TypedExpectation & InSequence(const Sequence & s1, const Sequence & s2,
10355  const Sequence & s3, const Sequence & s4)
10356  {
10357  return InSequence(s1, s2, s3).InSequence(s4);
10358  }
10359  TypedExpectation & InSequence(const Sequence & s1, const Sequence & s2,
10360  const Sequence & s3, const Sequence & s4,
10361  const Sequence & s5)
10362  {
10363  return InSequence(s1, s2, s3, s4).InSequence(s5);
10364  }
10365 
10366  // Implements that .After() clause.
10368  {
10369  ExpectSpecProperty(last_clause_ <= kAfter,
10370  ".After() cannot appear after .WillOnce(),"
10371  " .WillRepeatedly(), or "
10372  ".RetiresOnSaturation().");
10373  last_clause_ = kAfter;
10374 
10375  for (ExpectationSet::const_iterator it = s.begin(); it != s.end(); ++it)
10376  {
10377  immediate_prerequisites_ += *it;
10378  }
10379 
10380  return *this;
10381  }
10383  {
10384  return After(s1).After(s2);
10385  }
10387  const ExpectationSet & s3)
10388  {
10389  return After(s1, s2).After(s3);
10390  }
10392  const ExpectationSet & s3, const ExpectationSet & s4)
10393  {
10394  return After(s1, s2, s3).After(s4);
10395  }
10397  const ExpectationSet & s3, const ExpectationSet & s4,
10398  const ExpectationSet & s5)
10399  {
10400  return After(s1, s2, s3, s4).After(s5);
10401  }
10402 
10403  // Implements the .WillOnce() clause.
10405  {
10406  ExpectSpecProperty(last_clause_ <= kWillOnce,
10407  ".WillOnce() cannot appear after "
10408  ".WillRepeatedly() or .RetiresOnSaturation().");
10409  last_clause_ = kWillOnce;
10410 
10411  untyped_actions_.push_back(new Action<F>(action));
10412 
10413  if (!cardinality_specified())
10414  {
10415  set_cardinality(Exactly(static_cast<int>(untyped_actions_.size())));
10416  }
10417 
10418  return *this;
10419  }
10420 
10421  // Implements the .WillRepeatedly() clause.
10423  {
10424  if (last_clause_ == kWillRepeatedly)
10425  {
10426  ExpectSpecProperty(false,
10427  ".WillRepeatedly() cannot appear "
10428  "more than once in an EXPECT_CALL().");
10429  }
10430 
10431  else
10432  {
10433  ExpectSpecProperty(last_clause_ < kWillRepeatedly,
10434  ".WillRepeatedly() cannot appear "
10435  "after .RetiresOnSaturation().");
10436  }
10437 
10438  last_clause_ = kWillRepeatedly;
10439  repeated_action_specified_ = true;
10440 
10441  repeated_action_ = action;
10442 
10443  if (!cardinality_specified())
10444  {
10445  set_cardinality(AtLeast(static_cast<int>(untyped_actions_.size())));
10446  }
10447 
10448  // Now that no more action clauses can be specified, we check
10449  // whether their count makes sense.
10450  CheckActionCountIfNotDone();
10451  return *this;
10452  }
10453 
10454  // Implements the .RetiresOnSaturation() clause.
10456  {
10457  ExpectSpecProperty(last_clause_ < kRetiresOnSaturation,
10458  ".RetiresOnSaturation() cannot appear "
10459  "more than once.");
10460  last_clause_ = kRetiresOnSaturation;
10461  retires_on_saturation_ = true;
10462 
10463  // Now that no more action clauses can be specified, we check
10464  // whether their count makes sense.
10465  CheckActionCountIfNotDone();
10466  return *this;
10467  }
10468 
10469  // Returns the matchers for the arguments as specified inside the
10470  // EXPECT_CALL() macro.
10471  const ArgumentMatcherTuple & matchers() const
10472  {
10473  return matchers_;
10474  }
10475 
10476  // Returns the matcher specified by the .With() clause.
10478  {
10479  return extra_matcher_;
10480  }
10481 
10482  // Returns the action specified by the .WillRepeatedly() clause.
10483  const Action<F> & repeated_action() const { return repeated_action_; }
10484 
10485  // If this mock method has an extra matcher (i.e. .With(matcher)),
10486  // describes it to the ostream.
10487  virtual void MaybeDescribeExtraMatcherTo(::std::ostream * os)
10488  {
10489  if (extra_matcher_specified_)
10490  {
10491  *os << " Expected args: ";
10492  extra_matcher_.DescribeTo(os);
10493  *os << "\n";
10494  }
10495  }
10496 
10497 private:
10498  template <typename Function>
10499  friend class FunctionMockerBase;
10500 
10501  // Returns an Expectation object that references and co-owns this
10502  // expectation.
10504  {
10505  return owner_->GetHandleOf(this);
10506  }
10507 
10508  // The following methods will be called only after the EXPECT_CALL()
10509  // statement finishes and when the current thread holds
10510  // g_gmock_mutex.
10511 
10512  // Returns true iff this expectation matches the given arguments.
10513  bool Matches(const ArgumentTuple & args) const
10514  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10515  {
10516  g_gmock_mutex.AssertHeld();
10517  return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
10518  }
10519 
10520  // Returns true iff this expectation should handle the given arguments.
10521  bool ShouldHandleArguments(const ArgumentTuple & args) const
10522  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10523  {
10524  g_gmock_mutex.AssertHeld();
10525 
10526  // In case the action count wasn't checked when the expectation
10527  // was defined (e.g. if this expectation has no WillRepeatedly()
10528  // or RetiresOnSaturation() clause), we check it when the
10529  // expectation is used for the first time.
10530  CheckActionCountIfNotDone();
10531  return !is_retired() && AllPrerequisitesAreSatisfied() && Matches(args);
10532  }
10533 
10534  // Describes the result of matching the arguments against this
10535  // expectation to the given ostream.
10537  const ArgumentTuple & args,
10538  ::std::ostream * os) const
10539  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10540  {
10541  g_gmock_mutex.AssertHeld();
10542 
10543  if (is_retired())
10544  {
10545  *os << " Expected: the expectation is active\n"
10546  << " Actual: it is retired\n";
10547  }
10548 
10549  else if (!Matches(args))
10550  {
10551  if (!TupleMatches(matchers_, args))
10552  {
10553  ExplainMatchFailureTupleTo(matchers_, args, os);
10554  }
10555 
10556  StringMatchResultListener listener;
10557 
10558  if (!extra_matcher_.MatchAndExplain(args, &listener))
10559  {
10560  *os << " Expected args: ";
10561  extra_matcher_.DescribeTo(os);
10562  *os << "\n Actual: don't match";
10563 
10564  internal::PrintIfNotEmpty(listener.str(), os);
10565  *os << "\n";
10566  }
10567  }
10568 
10569  else if (!AllPrerequisitesAreSatisfied())
10570  {
10571  *os << " Expected: all pre-requisites are satisfied\n"
10572  << " Actual: the following immediate pre-requisites "
10573  << "are not satisfied:\n";
10574  ExpectationSet unsatisfied_prereqs;
10575  FindUnsatisfiedPrerequisites(&unsatisfied_prereqs);
10576  int i = 0;
10577 
10578  for (ExpectationSet::const_iterator it = unsatisfied_prereqs.begin();
10579  it != unsatisfied_prereqs.end(); ++it)
10580  {
10581  it->expectation_base()->DescribeLocationTo(os);
10582  *os << "pre-requisite #" << i++ << "\n";
10583  }
10584 
10585  *os << " (end of pre-requisites)\n";
10586  }
10587 
10588  else
10589  {
10590  // This line is here just for completeness' sake. It will never
10591  // be executed as currently the ExplainMatchResultTo() function
10592  // is called only when the mock function call does NOT match the
10593  // expectation.
10594  *os << "The call matches the expectation.\n";
10595  }
10596  }
10597 
10598  // Returns the action that should be taken for the current invocation.
10600  const FunctionMockerBase<F> * mocker,
10601  const ArgumentTuple & args) const
10602  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10603  {
10604  g_gmock_mutex.AssertHeld();
10605  const int count = call_count();
10606  Assert(count >= 1, __FILE__, __LINE__,
10607  "call_count() is <= 0 when GetCurrentAction() is "
10608  "called - this should never happen.");
10609 
10610  const int action_count = static_cast<int>(untyped_actions_.size());
10611 
10612  if (action_count > 0 && !repeated_action_specified_ &&
10613  count > action_count)
10614  {
10615  // If there is at least one WillOnce() and no WillRepeatedly(),
10616  // we warn the user when the WillOnce() clauses ran out.
10617  ::std::stringstream ss;
10618  DescribeLocationTo(&ss);
10619  ss << "Actions ran out in " << source_text() << "...\n"
10620  << "Called " << count << " times, but only "
10621  << action_count << " WillOnce()"
10622  << (action_count == 1 ? " is" : "s are") << " specified - ";
10623  mocker->DescribeDefaultActionTo(args, &ss);
10624  Log(kWarning, ss.str(), 1);
10625  }
10626 
10627  return count <= action_count ?
10628  *static_cast<const Action<F>*>(untyped_actions_[count - 1]) :
10629  repeated_action();
10630  }
10631 
10632  // Given the arguments of a mock function call, if the call will
10633  // over-saturate this expectation, returns the default action;
10634  // otherwise, returns the next action in this expectation. Also
10635  // describes *what* happened to 'what', and explains *why* Google
10636  // Mock does it to 'why'. This method is not const as it calls
10637  // IncrementCallCount(). A return value of NULL means the default
10638  // action.
10640  const FunctionMockerBase<F> * mocker,
10641  const ArgumentTuple & args,
10642  ::std::ostream * what,
10643  ::std::ostream * why)
10644  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10645  {
10646  g_gmock_mutex.AssertHeld();
10647 
10648  if (IsSaturated())
10649  {
10650  // We have an excessive call.
10651  IncrementCallCount();
10652  *what << "Mock function called more times than expected - ";
10653  mocker->DescribeDefaultActionTo(args, what);
10654  DescribeCallCountTo(why);
10655 
10656  // TODO(wan@google.com): allow the user to control whether
10657  // unexpected calls should fail immediately or continue using a
10658  // flag --gmock_unexpected_calls_are_fatal.
10659  return NULL;
10660  }
10661 
10662  IncrementCallCount();
10663  RetireAllPreRequisites();
10664 
10665  if (retires_on_saturation_ && IsSaturated())
10666  {
10667  Retire();
10668  }
10669 
10670  // Must be done after IncrementCount()!
10671  *what << "Mock function call matches " << source_text() << "...\n";
10672  return &(GetCurrentAction(mocker, args));
10673  }
10674 
10675  // All the fields below won't change once the EXPECT_CALL()
10676  // statement finishes.
10678  ArgumentMatcherTuple matchers_;
10681 
10683 }; // class TypedExpectation
10684 
10685 // A MockSpec object is used by ON_CALL() or EXPECT_CALL() for
10686 // specifying the default behavior of, or expectation on, a mock
10687 // function.
10688 
10689 // Note: class MockSpec really belongs to the ::testing namespace.
10690 // However if we define it in ::testing, MSVC will complain when
10691 // classes in ::testing::internal declare it as a friend class
10692 // template. To workaround this compiler bug, we define MockSpec in
10693 // ::testing::internal and import it into ::testing.
10694 
10695 // Logs a message including file and line number information.
10697  const char * file, int line,
10698  const string & message);
10699 
10700 template <typename F>
10702 {
10703 public:
10707 
10708  // Constructs a MockSpec object, given the function mocker object
10709  // that the spec is associated with.
10710  explicit MockSpec(internal::FunctionMockerBase<F> * function_mocker)
10711  : function_mocker_(function_mocker) {}
10712 
10713  // Adds a new default action spec to the function mocker and returns
10714  // the newly created spec.
10716  const char * file, int line, const char * obj, const char * call)
10717  {
10718  LogWithLocation(internal::kInfo, file, line,
10719  string("ON_CALL(") + obj + ", " + call + ") invoked");
10720  return function_mocker_->AddNewOnCallSpec(file, line, matchers_);
10721  }
10722 
10723  // Adds a new expectation spec to the function mocker and returns
10724  // the newly created spec.
10726  const char * file, int line, const char * obj, const char * call)
10727  {
10728  const string source_text(string("EXPECT_CALL(") + obj + ", " + call + ")");
10729  LogWithLocation(internal::kInfo, file, line, source_text + " invoked");
10730  return function_mocker_->AddNewExpectation(
10731  file, line, source_text, matchers_);
10732  }
10733 
10734 private:
10735  template <typename Function>
10737 
10738  void SetMatchers(const ArgumentMatcherTuple & matchers)
10739  {
10740  matchers_ = matchers;
10741  }
10742 
10743  // The function mocker that owns this spec.
10745  // The argument matchers specified in the spec.
10747 
10749 }; // class MockSpec
10750 
10751 // MSVC warns about using 'this' in base member initializer list, so
10752 // we need to temporarily disable the warning. We have to do it for
10753 // the entire class to suppress the warning, even though it's about
10754 // the constructor only.
10755 
10756 #ifdef _MSC_VER
10757 # pragma warning(push) // Saves the current warning state.
10758 # pragma warning(disable:4355) // Temporarily disables warning 4355.
10759 #endif // _MSV_VER
10760 
10761 // C++ treats the void type specially. For example, you cannot define
10762 // a void-typed variable or pass a void value to a function.
10763 // ActionResultHolder<T> holds a value of type T, where T must be a
10764 // copyable type or void (T doesn't need to be default-constructable).
10765 // It hides the syntactic difference between void and other types, and
10766 // is used to unify the code for invoking both void-returning and
10767 // non-void-returning mock functions.
10768 
10769 // Untyped base class for ActionResultHolder<T>.
10771 {
10772 public:
10774 
10775  // Prints the held value as an action's result to os.
10776  virtual void PrintAsActionResult(::std::ostream * os) const = 0;
10777 };
10778 
10779 // This generic definition is used when T is not void.
10780 template <typename T>
10782 {
10783 public:
10784  explicit ActionResultHolder(T a_value) : value_(a_value) {}
10785 
10786  // The compiler-generated copy constructor and assignment operator
10787  // are exactly what we need, so we don't need to define them.
10788 
10789  // Returns the held value and deletes this object.
10791  {
10792  T retval(value_);
10793  delete this;
10794  return retval;
10795  }
10796 
10797  // Prints the held value as an action's result to os.
10798  virtual void PrintAsActionResult(::std::ostream * os) const
10799  {
10800  *os << "\n Returns: ";
10801  // T may be a reference type, so we don't use UniversalPrint().
10802  UniversalPrinter<T>::Print(value_, os);
10803  }
10804 
10805  // Performs the given mock function's default action and returns the
10806  // result in a new-ed ActionResultHolder.
10807  template <typename F>
10809  const FunctionMockerBase<F> * func_mocker,
10810  const typename Function<F>::ArgumentTuple & args,
10811  const string & call_description)
10812  {
10813  return new ActionResultHolder(
10814  func_mocker->PerformDefaultAction(args, call_description));
10815  }
10816 
10817  // Performs the given action and returns the result in a new-ed
10818  // ActionResultHolder.
10819  template <typename F>
10820  static ActionResultHolder *
10821  PerformAction(const Action<F> & action,
10822  const typename Function<F>::ArgumentTuple & args)
10823  {
10824  return new ActionResultHolder(action.Perform(args));
10825  }
10826 
10827 private:
10829 
10830  // T could be a reference type, so = isn't supported.
10832 };
10833 
10834 // Specialization for T = void.
10835 template <>
10837 {
10838 public:
10839  void GetValueAndDelete() const { delete this; }
10840 
10841  virtual void PrintAsActionResult(::std::ostream * /* os */) const {}
10842 
10843  // Performs the given mock function's default action and returns NULL;
10844  template <typename F>
10846  const FunctionMockerBase<F> * func_mocker,
10847  const typename Function<F>::ArgumentTuple & args,
10848  const string & call_description)
10849  {
10850  func_mocker->PerformDefaultAction(args, call_description);
10851  return NULL;
10852  }
10853 
10854  // Performs the given action and returns NULL.
10855  template <typename F>
10857  const Action<F> & action,
10858  const typename Function<F>::ArgumentTuple & args)
10859  {
10860  action.Perform(args);
10861  return NULL;
10862  }
10863 };
10864 
10865 // The base of the function mocker class for the given function type.
10866 // We put the methods in this class instead of its child to avoid code
10867 // bloat.
10868 template <typename F>
10870 {
10871 public:
10872  typedef typename Function<F>::Result Result;
10875 
10876  FunctionMockerBase() : current_spec_(this) {}
10877 
10878  // The destructor verifies that all expectations on this mock
10879  // function have been satisfied. If not, it will report Google Test
10880  // non-fatal failures for the violations.
10882  GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
10883  {
10884  MutexLock l(&g_gmock_mutex);
10885  VerifyAndClearExpectationsLocked();
10886  Mock::UnregisterLocked(this);
10887  ClearDefaultActionsLocked();
10888  }
10889 
10890  // Returns the ON_CALL spec that matches this mock function with the
10891  // given arguments; returns NULL if no matching ON_CALL is found.
10892  // L = *
10894  const ArgumentTuple & args) const
10895  {
10896  for (UntypedOnCallSpecs::const_reverse_iterator it
10897  = untyped_on_call_specs_.rbegin();
10898  it != untyped_on_call_specs_.rend(); ++it)
10899  {
10900  const OnCallSpec<F> * spec = static_cast<const OnCallSpec<F>*>(*it);
10901 
10902  if (spec->Matches(args))
10903  { return spec; }
10904  }
10905 
10906  return NULL;
10907  }
10908 
10909  // Performs the default action of this mock function on the given
10910  // arguments and returns the result. Asserts (or throws if
10911  // exceptions are enabled) with a helpful call descrption if there
10912  // is no valid return value. This method doesn't depend on the
10913  // mutable state of this object, and thus can be called concurrently
10914  // without locking.
10915  // L = *
10916  Result PerformDefaultAction(const ArgumentTuple & args,
10917  const string & call_description) const
10918  {
10919  const OnCallSpec<F> * const spec =
10920  this->FindOnCallSpec(args);
10921 
10922  if (spec != NULL)
10923  {
10924  return spec->GetAction().Perform(args);
10925  }
10926 
10927  const string message = call_description +
10928  "\n The mock function has no default action "
10929  "set, and its return type has no default value set.";
10930 #if GTEST_HAS_EXCEPTIONS
10931 
10933  {
10934  throw std::runtime_error(message);
10935  }
10936 
10937 #else
10938  Assert(DefaultValue<Result>::Exists(), "", -1, message);
10939 #endif
10940  return DefaultValue<Result>::Get();
10941  }
10942 
10943  // Performs the default action with the given arguments and returns
10944  // the action's result. The call description string will be used in
10945  // the error message to describe the call in the case the default
10946  // action fails. The caller is responsible for deleting the result.
10947  // L = *
10949  const void * untyped_args, // must point to an ArgumentTuple
10950  const string & call_description) const
10951  {
10952  const ArgumentTuple & args =
10953  *static_cast<const ArgumentTuple *>(untyped_args);
10954  return ResultHolder::PerformDefaultAction(this, args, call_description);
10955  }
10956 
10957  // Performs the given action with the given arguments and returns
10958  // the action's result. The caller is responsible for deleting the
10959  // result.
10960  // L = *
10962  const void * untyped_action, const void * untyped_args) const
10963  {
10964  // Make a copy of the action before performing it, in case the
10965  // action deletes the mock object (and thus deletes itself).
10966  const Action<F> action = *static_cast<const Action<F>*>(untyped_action);
10967  const ArgumentTuple & args =
10968  *static_cast<const ArgumentTuple *>(untyped_args);
10969  return ResultHolder::PerformAction(action, args);
10970  }
10971 
10972  // Implements UntypedFunctionMockerBase::ClearDefaultActionsLocked():
10973  // clears the ON_CALL()s set on this mock function.
10975  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
10976  {
10977  g_gmock_mutex.AssertHeld();
10978 
10979  // Deleting our default actions may trigger other mock objects to be
10980  // deleted, for example if an action contains a reference counted smart
10981  // pointer to that mock object, and that is the last reference. So if we
10982  // delete our actions within the context of the global mutex we may deadlock
10983  // when this method is called again. Instead, make a copy of the set of
10984  // actions to delete, clear our set within the mutex, and then delete the
10985  // actions outside of the mutex.
10986  UntypedOnCallSpecs specs_to_delete;
10987  untyped_on_call_specs_.swap(specs_to_delete);
10988 
10989  g_gmock_mutex.Unlock();
10990 
10991  for (UntypedOnCallSpecs::const_iterator it =
10992  specs_to_delete.begin();
10993  it != specs_to_delete.end(); ++it)
10994  {
10995  delete static_cast<const OnCallSpec<F>*>(*it);
10996  }
10997 
10998  // Lock the mutex again, since the caller expects it to be locked when we
10999  // return.
11000  g_gmock_mutex.Lock();
11001  }
11002 
11003 protected:
11004  template <typename Function>
11005  friend class MockSpec;
11006 
11008 
11009  // Returns the result of invoking this mock function with the given
11010  // arguments. This function can be safely called from multiple
11011  // threads concurrently.
11012  Result InvokeWith(const ArgumentTuple & args)
11013  GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
11014  {
11015  return static_cast<const ResultHolder *>(
11016  this->UntypedInvokeWith(&args))->GetValueAndDelete();
11017  }
11018 
11019  // Adds and returns a default action spec for this mock function.
11021  const char * file, int line,
11022  const ArgumentMatcherTuple & m)
11023  GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
11024  {
11025  Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
11026  OnCallSpec<F> * const on_call_spec = new OnCallSpec<F>(file, line, m);
11027  untyped_on_call_specs_.push_back(on_call_spec);
11028  return *on_call_spec;
11029  }
11030 
11031  // Adds and returns an expectation spec for this mock function.
11033  const char * file,
11034  int line,
11035  const string & source_text,
11036  const ArgumentMatcherTuple & m)
11037  GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
11038  {
11039  Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
11040  TypedExpectation<F> * const expectation =
11041  new TypedExpectation<F>(this, file, line, source_text, m);
11042  const linked_ptr<ExpectationBase> untyped_expectation(expectation);
11043  untyped_expectations_.push_back(untyped_expectation);
11044 
11045  // Adds this expectation into the implicit sequence if there is one.
11046  Sequence * const implicit_sequence = g_gmock_implicit_sequence.get();
11047 
11048  if (implicit_sequence != NULL)
11049  {
11050  implicit_sequence->AddExpectation(Expectation(untyped_expectation));
11051  }
11052 
11053  return *expectation;
11054  }
11055 
11056  // The current spec (either default action spec or expectation spec)
11057  // being described on this function mocker.
11058  MockSpec<F> & current_spec() { return current_spec_; }
11059 
11060 private:
11061  template <typename Func> friend class TypedExpectation;
11062 
11063  // Some utilities needed for implementing UntypedInvokeWith().
11064 
11065  // Describes what default action will be performed for the given
11066  // arguments.
11067  // L = *
11068  void DescribeDefaultActionTo(const ArgumentTuple & args,
11069  ::std::ostream * os) const
11070  {
11071  const OnCallSpec<F> * const spec = FindOnCallSpec(args);
11072 
11073  if (spec == NULL)
11074  {
11075  *os << (internal::type_equals<Result, void>::value ?
11076  "returning directly.\n" :
11077  "returning default value.\n");
11078  }
11079 
11080  else
11081  {
11082  *os << "taking default action specified at:\n"
11083  << FormatFileLocation(spec->file(), spec->line()) << "\n";
11084  }
11085  }
11086 
11087  // Writes a message that the call is uninteresting (i.e. neither
11088  // explicitly expected nor explicitly unexpected) to the given
11089  // ostream.
11091  const void * untyped_args,
11092  ::std::ostream * os) const
11093  GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
11094  {
11095  const ArgumentTuple & args =
11096  *static_cast<const ArgumentTuple *>(untyped_args);
11097  *os << "Uninteresting mock function call - ";
11098  DescribeDefaultActionTo(args, os);
11099  *os << " Function call: " << Name();
11100  UniversalPrint(args, os);
11101  }
11102 
11103  // Returns the expectation that matches the given function arguments
11104  // (or NULL is there's no match); when a match is found,
11105  // untyped_action is set to point to the action that should be
11106  // performed (or NULL if the action is "do default"), and
11107  // is_excessive is modified to indicate whether the call exceeds the
11108  // expected number.
11109  //
11110  // Critical section: We must find the matching expectation and the
11111  // corresponding action that needs to be taken in an ATOMIC
11112  // transaction. Otherwise another thread may call this mock
11113  // method in the middle and mess up the state.
11114  //
11115  // However, performing the action has to be left out of the critical
11116  // section. The reason is that we have no control on what the
11117  // action does (it can invoke an arbitrary user function or even a
11118  // mock function) and excessive locking could cause a dead lock.
11120  const void * untyped_args,
11121  const void ** untyped_action, bool * is_excessive,
11122  ::std::ostream * what, ::std::ostream * why)
11123  GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
11124  {
11125  const ArgumentTuple & args =
11126  *static_cast<const ArgumentTuple *>(untyped_args);
11127  MutexLock l(&g_gmock_mutex);
11128  TypedExpectation<F> * exp = this->FindMatchingExpectationLocked(args);
11129 
11130  if (exp == NULL) // A match wasn't found.
11131  {
11132  this->FormatUnexpectedCallMessageLocked(args, what, why);
11133  return NULL;
11134  }
11135 
11136  // This line must be done before calling GetActionForArguments(),
11137  // which will increment the call count for *exp and thus affect
11138  // its saturation status.
11139  *is_excessive = exp->IsSaturated();
11140  const Action<F> * action = exp->GetActionForArguments(this, args, what, why);
11141 
11142  if (action != NULL && action->IsDoDefault())
11143  { action = NULL; } // Normalize "do default" to NULL.
11144 
11145  *untyped_action = action;
11146  return exp;
11147  }
11148 
11149  // Prints the given function arguments to the ostream.
11150  virtual void UntypedPrintArgs(const void * untyped_args,
11151  ::std::ostream * os) const
11152  {
11153  const ArgumentTuple & args =
11154  *static_cast<const ArgumentTuple *>(untyped_args);
11155  UniversalPrint(args, os);
11156  }
11157 
11158  // Returns the expectation that matches the arguments, or NULL if no
11159  // expectation matches them.
11161  const ArgumentTuple & args) const
11162  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
11163  {
11164  g_gmock_mutex.AssertHeld();
11165 
11166  for (typename UntypedExpectations::const_reverse_iterator it =
11167  untyped_expectations_.rbegin();
11168  it != untyped_expectations_.rend(); ++it)
11169  {
11170  TypedExpectation<F> * const exp =
11171  static_cast<TypedExpectation<F>*>(it->get());
11172 
11173  if (exp->ShouldHandleArguments(args))
11174  {
11175  return exp;
11176  }
11177  }
11178 
11179  return NULL;
11180  }
11181 
11182  // Returns a message that the arguments don't match any expectation.
11184  const ArgumentTuple & args,
11185  ::std::ostream * os,
11186  ::std::ostream * why) const
11187  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
11188  {
11189  g_gmock_mutex.AssertHeld();
11190  *os << "\nUnexpected mock function call - ";
11191  DescribeDefaultActionTo(args, os);
11192  PrintTriedExpectationsLocked(args, why);
11193  }
11194 
11195  // Prints a list of expectations that have been tried against the
11196  // current mock function call.
11198  const ArgumentTuple & args,
11199  ::std::ostream * why) const
11200  GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
11201  {
11202  g_gmock_mutex.AssertHeld();
11203  const int count = static_cast<int>(untyped_expectations_.size());
11204  *why << "Google Mock tried the following " << count << " "
11205  << (count == 1 ? "expectation, but it didn't match" :
11206  "expectations, but none matched")
11207  << ":\n";
11208 
11209  for (int i = 0; i < count; i++)
11210  {
11211  TypedExpectation<F> * const expectation =
11212  static_cast<TypedExpectation<F>*>(untyped_expectations_[i].get());
11213  *why << "\n";
11214  expectation->DescribeLocationTo(why);
11215 
11216  if (count > 1)
11217  {
11218  *why << "tried expectation #" << i << ": ";
11219  }
11220 
11221  *why << expectation->source_text() << "...\n";
11222  expectation->ExplainMatchResultTo(args, why);
11223  expectation->DescribeCallCountTo(why);
11224  }
11225  }
11226 
11227  // The current spec (either default action spec or expectation spec)
11228  // being described on this function mocker.
11230 
11231  // There is no generally useful and implementable semantics of
11232  // copying a mock object, so copying a mock is usually a user error.
11233  // Thus we disallow copying function mockers. If the user really
11234  // wants to copy a mock object, he should implement his own copy
11235  // operation, for example:
11236  //
11237  // class MockFoo : public Foo {
11238  // public:
11239  // // Defines a copy constructor explicitly.
11240  // MockFoo(const MockFoo& src) {}
11241  // ...
11242  // };
11244 }; // class FunctionMockerBase
11245 
11246 #ifdef _MSC_VER
11247 # pragma warning(pop) // Restores the warning state.
11248 #endif // _MSV_VER
11249 
11250 // Implements methods of FunctionMockerBase.
11251 
11252 // Verifies that all expectations on this mock function have been
11253 // satisfied. Reports one or more Google Test non-fatal failures and
11254 // returns false if not.
11255 
11256 // Reports an uninteresting call (whose description is in msg) in the
11257 // manner specified by 'reaction'.
11258 void ReportUninterestingCall(CallReaction reaction, const string & msg);
11259 
11260 } // namespace internal
11261 
11262 // The style guide prohibits "using" statements in a namespace scope
11263 // inside a header file. However, the MockSpec class template is
11264 // meant to be defined in the ::testing namespace. The following line
11265 // is just a trick for working around a bug in MSVC 8.0, which cannot
11266 // handle it if we define MockSpec in ::testing.
11267 using internal::MockSpec;
11268 
11269 // Const(x) is a convenient function for obtaining a const reference
11270 // to x. This is useful for setting expectations on an overloaded
11271 // const mock method, e.g.
11272 //
11273 // class MockFoo : public FooInterface {
11274 // public:
11275 // MOCK_METHOD0(Bar, int());
11276 // MOCK_CONST_METHOD0(Bar, int&());
11277 // };
11278 //
11279 // MockFoo foo;
11280 // // Expects a call to non-const MockFoo::Bar().
11281 // EXPECT_CALL(foo, Bar());
11282 // // Expects a call to const MockFoo::Bar().
11283 // EXPECT_CALL(Const(foo), Bar());
11284 template <typename T>
11285 inline const T & Const(const T & x) { return x; }
11286 
11287 // Constructs an Expectation object that references and co-owns exp.
11289  : expectation_base_(exp.GetHandle().expectation_base()) {}
11290 
11291 } // namespace testing
11292 
11293 // A separate macro is required to avoid compile errors when the name
11294 // of the method used in call is a result of macro expansion.
11295 // See CompilesWithMethodNameExpandedFromMacro tests in
11296 // internal/gmock-spec-builders_test.cc for more details.
11297 #define GMOCK_ON_CALL_IMPL_(obj, call) \
11298  ((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \
11299  #obj, #call)
11300 #define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call)
11301 
11302 #define GMOCK_EXPECT_CALL_IMPL_(obj, call) \
11303  ((obj).gmock_##call).InternalExpectedAt(__FILE__, __LINE__, #obj, #call)
11304 #define EXPECT_CALL(obj, call) GMOCK_EXPECT_CALL_IMPL_(obj, call)
11305 
11306 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
11307 
11308 namespace testing
11309 {
11310 namespace internal
11311 {
11312 
11313 template <typename F>
11314 class FunctionMockerBase;
11315 
11316 // Note: class FunctionMocker really belongs to the ::testing
11317 // namespace. However if we define it in ::testing, MSVC will
11318 // complain when classes in ::testing::internal declare it as a
11319 // friend class template. To workaround this compiler bug, we define
11320 // FunctionMocker in ::testing::internal and import it into ::testing.
11321 template <typename F>
11322 class FunctionMocker;
11323 
11324 template <typename R>
11325 class FunctionMocker<R()> : public
11327 {
11328 public:
11329  typedef R F();
11331 
11333  {
11334  return this->current_spec();
11335  }
11336 
11338  {
11339  // Even though gcc and MSVC don't enforce it, 'this->' is required
11340  // by the C++ standard [14.6.4] here, as the base class type is
11341  // dependent on the template argument (and thus shouldn't be
11342  // looked into when resolving InvokeWith).
11343  return this->InvokeWith(ArgumentTuple());
11344  }
11345 };
11346 
11347 template <typename R, typename A1>
11348 class FunctionMocker<R(A1)> : public
11350 {
11351 public:
11352  typedef R F(A1);
11354 
11356  {
11357  this->current_spec().SetMatchers(::std::tr1::make_tuple(m1));
11358  return this->current_spec();
11359  }
11360 
11361  R Invoke(A1 a1)
11362  {
11363  // Even though gcc and MSVC don't enforce it, 'this->' is required
11364  // by the C++ standard [14.6.4] here, as the base class type is
11365  // dependent on the template argument (and thus shouldn't be
11366  // looked into when resolving InvokeWith).
11367  return this->InvokeWith(ArgumentTuple(a1));
11368  }
11369 };
11370 
11371 template <typename R, typename A1, typename A2>
11372 class FunctionMocker<R(A1, A2)> : public
11373  internal::FunctionMockerBase<R(A1, A2)>
11374 {
11375 public:
11376  typedef R F(A1, A2);
11378 
11379  MockSpec<F> & With(const Matcher<A1> & m1, const Matcher<A2> & m2)
11380  {
11381  this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2));
11382  return this->current_spec();
11383  }
11384 
11385  R Invoke(A1 a1, A2 a2)
11386  {
11387  // Even though gcc and MSVC don't enforce it, 'this->' is required
11388  // by the C++ standard [14.6.4] here, as the base class type is
11389  // dependent on the template argument (and thus shouldn't be
11390  // looked into when resolving InvokeWith).
11391  return this->InvokeWith(ArgumentTuple(a1, a2));
11392  }
11393 };
11394 
11395 template <typename R, typename A1, typename A2, typename A3>
11396 class FunctionMocker<R(A1, A2, A3)> : public
11397  internal::FunctionMockerBase<R(A1, A2, A3)>
11398 {
11399 public:
11400  typedef R F(A1, A2, A3);
11402 
11403  MockSpec<F> & With(const Matcher<A1> & m1, const Matcher<A2> & m2,
11404  const Matcher<A3> & m3)
11405  {
11406  this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3));
11407  return this->current_spec();
11408  }
11409 
11410  R Invoke(A1 a1, A2 a2, A3 a3)
11411  {
11412  // Even though gcc and MSVC don't enforce it, 'this->' is required
11413  // by the C++ standard [14.6.4] here, as the base class type is
11414  // dependent on the template argument (and thus shouldn't be
11415  // looked into when resolving InvokeWith).
11416  return this->InvokeWith(ArgumentTuple(a1, a2, a3));
11417  }
11418 };
11419 
11420 template <typename R, typename A1, typename A2, typename A3, typename A4>
11421 class FunctionMocker<R(A1, A2, A3, A4)> : public
11422  internal::FunctionMockerBase<R(A1, A2, A3, A4)>
11423 {
11424 public:
11425  typedef R F(A1, A2, A3, A4);
11427 
11428  MockSpec<F> & With(const Matcher<A1> & m1, const Matcher<A2> & m2,
11429  const Matcher<A3> & m3, const Matcher<A4> & m4)
11430  {
11431  this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4));
11432  return this->current_spec();
11433  }
11434 
11435  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4)
11436  {
11437  // Even though gcc and MSVC don't enforce it, 'this->' is required
11438  // by the C++ standard [14.6.4] here, as the base class type is
11439  // dependent on the template argument (and thus shouldn't be
11440  // looked into when resolving InvokeWith).
11441  return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4));
11442  }
11443 };
11444 
11445 template <typename R, typename A1, typename A2, typename A3, typename A4,
11446  typename A5>
11447 class FunctionMocker<R(A1, A2, A3, A4, A5)> : public
11448  internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)>
11449 {
11450 public:
11451  typedef R F(A1, A2, A3, A4, A5);
11453 
11454  MockSpec<F> & With(const Matcher<A1> & m1, const Matcher<A2> & m2,
11455  const Matcher<A3> & m3, const Matcher<A4> & m4, const Matcher<A5> & m5)
11456  {
11457  this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
11458  m5));
11459  return this->current_spec();
11460  }
11461 
11462  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
11463  {
11464  // Even though gcc and MSVC don't enforce it, 'this->' is required
11465  // by the C++ standard [14.6.4] here, as the base class type is
11466  // dependent on the template argument (and thus shouldn't be
11467  // looked into when resolving InvokeWith).
11468  return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5));
11469  }
11470 };
11471 
11472 template <typename R, typename A1, typename A2, typename A3, typename A4,
11473  typename A5, typename A6>
11474 class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public
11475  internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6)>
11476 {
11477 public:
11478  typedef R F(A1, A2, A3, A4, A5, A6);
11480 
11481  MockSpec<F> & With(const Matcher<A1> & m1, const Matcher<A2> & m2,
11482  const Matcher<A3> & m3, const Matcher<A4> & m4, const Matcher<A5> & m5,
11483  const Matcher<A6> & m6)
11484  {
11485  this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
11486  m6));
11487  return this->current_spec();
11488  }
11489 
11490  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
11491  {
11492  // Even though gcc and MSVC don't enforce it, 'this->' is required
11493  // by the C++ standard [14.6.4] here, as the base class type is
11494  // dependent on the template argument (and thus shouldn't be
11495  // looked into when resolving InvokeWith).
11496  return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6));
11497  }
11498 };
11499 
11500 template <typename R, typename A1, typename A2, typename A3, typename A4,
11501  typename A5, typename A6, typename A7>
11502 class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public
11503  internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)>
11504 {
11505 public:
11506  typedef R F(A1, A2, A3, A4, A5, A6, A7);
11508 
11509  MockSpec<F> & With(const Matcher<A1> & m1, const Matcher<A2> & m2,
11510  const Matcher<A3> & m3, const Matcher<A4> & m4, const Matcher<A5> & m5,
11511  const Matcher<A6> & m6, const Matcher<A7> & m7)
11512  {
11513  this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
11514  m6, m7));
11515  return this->current_spec();
11516  }
11517 
11518  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
11519  {
11520  // Even though gcc and MSVC don't enforce it, 'this->' is required
11521  // by the C++ standard [14.6.4] here, as the base class type is
11522  // dependent on the template argument (and thus shouldn't be
11523  // looked into when resolving InvokeWith).
11524  return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7));
11525  }
11526 };
11527 
11528 template <typename R, typename A1, typename A2, typename A3, typename A4,
11529  typename A5, typename A6, typename A7, typename A8>
11530 class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public
11531  internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)>
11532 {
11533 public:
11534  typedef R F(A1, A2, A3, A4, A5, A6, A7, A8);
11536 
11537  MockSpec<F> & With(const Matcher<A1> & m1, const Matcher<A2> & m2,
11538  const Matcher<A3> & m3, const Matcher<A4> & m4, const Matcher<A5> & m5,
11539  const Matcher<A6> & m6, const Matcher<A7> & m7, const Matcher<A8> & m8)
11540  {
11541  this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
11542  m6, m7, m8));
11543  return this->current_spec();
11544  }
11545 
11546  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
11547  {
11548  // Even though gcc and MSVC don't enforce it, 'this->' is required
11549  // by the C++ standard [14.6.4] here, as the base class type is
11550  // dependent on the template argument (and thus shouldn't be
11551  // looked into when resolving InvokeWith).
11552  return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8));
11553  }
11554 };
11555 
11556 template <typename R, typename A1, typename A2, typename A3, typename A4,
11557  typename A5, typename A6, typename A7, typename A8, typename A9>
11558 class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public
11559  internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
11560 {
11561 public:
11562  typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9);
11564 
11565  MockSpec<F> & With(const Matcher<A1> & m1, const Matcher<A2> & m2,
11566  const Matcher<A3> & m3, const Matcher<A4> & m4, const Matcher<A5> & m5,
11567  const Matcher<A6> & m6, const Matcher<A7> & m7, const Matcher<A8> & m8,
11568  const Matcher<A9> & m9)
11569  {
11570  this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
11571  m6, m7, m8, m9));
11572  return this->current_spec();
11573  }
11574 
11575  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
11576  {
11577  // Even though gcc and MSVC don't enforce it, 'this->' is required
11578  // by the C++ standard [14.6.4] here, as the base class type is
11579  // dependent on the template argument (and thus shouldn't be
11580  // looked into when resolving InvokeWith).
11581  return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9));
11582  }
11583 };
11584 
11585 template <typename R, typename A1, typename A2, typename A3, typename A4,
11586  typename A5, typename A6, typename A7, typename A8, typename A9,
11587  typename A10>
11588 class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
11589  internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
11590 {
11591 public:
11592  typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
11594 
11595  MockSpec<F> & With(const Matcher<A1> & m1, const Matcher<A2> & m2,
11596  const Matcher<A3> & m3, const Matcher<A4> & m4, const Matcher<A5> & m5,
11597  const Matcher<A6> & m6, const Matcher<A7> & m7, const Matcher<A8> & m8,
11598  const Matcher<A9> & m9, const Matcher<A10> & m10)
11599  {
11600  this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
11601  m6, m7, m8, m9, m10));
11602  return this->current_spec();
11603  }
11604 
11605  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
11606  A10 a10)
11607  {
11608  // Even though gcc and MSVC don't enforce it, 'this->' is required
11609  // by the C++ standard [14.6.4] here, as the base class type is
11610  // dependent on the template argument (and thus shouldn't be
11611  // looked into when resolving InvokeWith).
11612  return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9,
11613  a10));
11614  }
11615 };
11616 
11617 } // namespace internal
11618 
11619 // The style guide prohibits "using" statements in a namespace scope
11620 // inside a header file. However, the FunctionMocker class template
11621 // is meant to be defined in the ::testing namespace. The following
11622 // line is just a trick for working around a bug in MSVC 8.0, which
11623 // cannot handle it if we define FunctionMocker in ::testing.
11625 
11626 // GMOCK_RESULT_(tn, F) expands to the result type of function type F.
11627 // We define this as a variadic macro in case F contains unprotected
11628 // commas (the same reason that we use variadic macros in other places
11629 // in this file).
11630 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11631 #define GMOCK_RESULT_(tn, ...) \
11632  tn ::testing::internal::Function<__VA_ARGS__>::Result
11633 
11634 // The type of argument N of the given function type.
11635 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11636 #define GMOCK_ARG_(tn, N, ...) \
11637  tn ::testing::internal::Function<__VA_ARGS__>::Argument##N
11638 
11639 // The matcher type for argument N of the given function type.
11640 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11641 #define GMOCK_MATCHER_(tn, N, ...) \
11642  const ::testing::Matcher<GMOCK_ARG_(tn, N, __VA_ARGS__)>&
11643 
11644 // The variable for mocking the given method.
11645 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11646 #define GMOCK_MOCKER_(arity, constness, Method) \
11647  GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
11648 
11649 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11650 #define GMOCK_METHOD0_(tn, constness, ct, Method, ...) \
11651  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
11652  ) constness { \
11653  GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
11654  tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
11655  == 0), \
11656  this_method_does_not_take_0_arguments); \
11657  GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \
11658  return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
11659  } \
11660  ::testing::MockSpec<__VA_ARGS__>& \
11661  gmock_##Method() constness { \
11662  GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \
11663  return GMOCK_MOCKER_(0, constness, Method).With(); \
11664  } \
11665  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(0, constness, \
11666  Method)
11667 
11668 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11669 #define GMOCK_METHOD1_(tn, constness, ct, Method, ...) \
11670  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
11671  GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
11672  GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
11673  tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
11674  == 1), \
11675  this_method_does_not_take_1_argument); \
11676  GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \
11677  return GMOCK_MOCKER_(1, constness, Method).Invoke(gmock_a1); \
11678  } \
11679  ::testing::MockSpec<__VA_ARGS__>& \
11680  gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
11681  GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \
11682  return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \
11683  } \
11684  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(1, constness, \
11685  Method)
11686 
11687 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11688 #define GMOCK_METHOD2_(tn, constness, ct, Method, ...) \
11689  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
11690  GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
11691  GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
11692  GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
11693  tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
11694  == 2), \
11695  this_method_does_not_take_2_arguments); \
11696  GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \
11697  return GMOCK_MOCKER_(2, constness, Method).Invoke(gmock_a1, gmock_a2); \
11698  } \
11699  ::testing::MockSpec<__VA_ARGS__>& \
11700  gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
11701  GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
11702  GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \
11703  return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \
11704  } \
11705  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(2, constness, \
11706  Method)
11707 
11708 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11709 #define GMOCK_METHOD3_(tn, constness, ct, Method, ...) \
11710  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
11711  GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
11712  GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
11713  GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
11714  GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
11715  tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
11716  == 3), \
11717  this_method_does_not_take_3_arguments); \
11718  GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \
11719  return GMOCK_MOCKER_(3, constness, Method).Invoke(gmock_a1, gmock_a2, \
11720  gmock_a3); \
11721  } \
11722  ::testing::MockSpec<__VA_ARGS__>& \
11723  gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
11724  GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
11725  GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
11726  GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \
11727  return GMOCK_MOCKER_(3, constness, Method).With(gmock_a1, gmock_a2, \
11728  gmock_a3); \
11729  } \
11730  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(3, constness, \
11731  Method)
11732 
11733 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11734 #define GMOCK_METHOD4_(tn, constness, ct, Method, ...) \
11735  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
11736  GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
11737  GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
11738  GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
11739  GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
11740  GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
11741  tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
11742  == 4), \
11743  this_method_does_not_take_4_arguments); \
11744  GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \
11745  return GMOCK_MOCKER_(4, constness, Method).Invoke(gmock_a1, gmock_a2, \
11746  gmock_a3, gmock_a4); \
11747  } \
11748  ::testing::MockSpec<__VA_ARGS__>& \
11749  gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
11750  GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
11751  GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
11752  GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
11753  GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \
11754  return GMOCK_MOCKER_(4, constness, Method).With(gmock_a1, gmock_a2, \
11755  gmock_a3, gmock_a4); \
11756  } \
11757  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(4, constness, \
11758  Method)
11759 
11760 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11761 #define GMOCK_METHOD5_(tn, constness, ct, Method, ...) \
11762  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
11763  GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
11764  GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
11765  GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
11766  GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
11767  GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
11768  GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
11769  tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
11770  == 5), \
11771  this_method_does_not_take_5_arguments); \
11772  GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \
11773  return GMOCK_MOCKER_(5, constness, Method).Invoke(gmock_a1, gmock_a2, \
11774  gmock_a3, gmock_a4, gmock_a5); \
11775  } \
11776  ::testing::MockSpec<__VA_ARGS__>& \
11777  gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
11778  GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
11779  GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
11780  GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
11781  GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
11782  GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \
11783  return GMOCK_MOCKER_(5, constness, Method).With(gmock_a1, gmock_a2, \
11784  gmock_a3, gmock_a4, gmock_a5); \
11785  } \
11786  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(5, constness, \
11787  Method)
11788 
11789 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11790 #define GMOCK_METHOD6_(tn, constness, ct, Method, ...) \
11791  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
11792  GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
11793  GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
11794  GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
11795  GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
11796  GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
11797  GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
11798  GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
11799  tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
11800  == 6), \
11801  this_method_does_not_take_6_arguments); \
11802  GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \
11803  return GMOCK_MOCKER_(6, constness, Method).Invoke(gmock_a1, gmock_a2, \
11804  gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
11805  } \
11806  ::testing::MockSpec<__VA_ARGS__>& \
11807  gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
11808  GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
11809  GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
11810  GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
11811  GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
11812  GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
11813  GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \
11814  return GMOCK_MOCKER_(6, constness, Method).With(gmock_a1, gmock_a2, \
11815  gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
11816  } \
11817  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(6, constness, \
11818  Method)
11819 
11820 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11821 #define GMOCK_METHOD7_(tn, constness, ct, Method, ...) \
11822  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
11823  GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
11824  GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
11825  GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
11826  GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
11827  GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
11828  GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
11829  GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
11830  GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
11831  tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
11832  == 7), \
11833  this_method_does_not_take_7_arguments); \
11834  GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \
11835  return GMOCK_MOCKER_(7, constness, Method).Invoke(gmock_a1, gmock_a2, \
11836  gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
11837  } \
11838  ::testing::MockSpec<__VA_ARGS__>& \
11839  gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
11840  GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
11841  GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
11842  GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
11843  GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
11844  GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
11845  GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
11846  GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \
11847  return GMOCK_MOCKER_(7, constness, Method).With(gmock_a1, gmock_a2, \
11848  gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
11849  } \
11850  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(7, constness, \
11851  Method)
11852 
11853 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11854 #define GMOCK_METHOD8_(tn, constness, ct, Method, ...) \
11855  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
11856  GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
11857  GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
11858  GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
11859  GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
11860  GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
11861  GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
11862  GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
11863  GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
11864  GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
11865  tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
11866  == 8), \
11867  this_method_does_not_take_8_arguments); \
11868  GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \
11869  return GMOCK_MOCKER_(8, constness, Method).Invoke(gmock_a1, gmock_a2, \
11870  gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
11871  } \
11872  ::testing::MockSpec<__VA_ARGS__>& \
11873  gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
11874  GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
11875  GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
11876  GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
11877  GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
11878  GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
11879  GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
11880  GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
11881  GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \
11882  return GMOCK_MOCKER_(8, constness, Method).With(gmock_a1, gmock_a2, \
11883  gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
11884  } \
11885  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(8, constness, \
11886  Method)
11887 
11888 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11889 #define GMOCK_METHOD9_(tn, constness, ct, Method, ...) \
11890  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
11891  GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
11892  GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
11893  GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
11894  GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
11895  GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
11896  GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
11897  GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
11898  GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
11899  GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
11900  GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
11901  tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
11902  == 9), \
11903  this_method_does_not_take_9_arguments); \
11904  GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \
11905  return GMOCK_MOCKER_(9, constness, Method).Invoke(gmock_a1, gmock_a2, \
11906  gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
11907  gmock_a9); \
11908  } \
11909  ::testing::MockSpec<__VA_ARGS__>& \
11910  gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
11911  GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
11912  GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
11913  GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
11914  GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
11915  GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
11916  GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
11917  GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
11918  GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
11919  GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \
11920  return GMOCK_MOCKER_(9, constness, Method).With(gmock_a1, gmock_a2, \
11921  gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
11922  gmock_a9); \
11923  } \
11924  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(9, constness, \
11925  Method)
11926 
11927 // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
11928 #define GMOCK_METHOD10_(tn, constness, ct, Method, ...) \
11929  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
11930  GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
11931  GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
11932  GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
11933  GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
11934  GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
11935  GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
11936  GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
11937  GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
11938  GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9, \
11939  GMOCK_ARG_(tn, 10, __VA_ARGS__) gmock_a10) constness { \
11940  GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
11941  tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
11942  == 10), \
11943  this_method_does_not_take_10_arguments); \
11944  GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \
11945  return GMOCK_MOCKER_(10, constness, Method).Invoke(gmock_a1, gmock_a2, \
11946  gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
11947  gmock_a10); \
11948  } \
11949  ::testing::MockSpec<__VA_ARGS__>& \
11950  gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
11951  GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
11952  GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
11953  GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
11954  GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
11955  GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
11956  GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
11957  GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
11958  GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9, \
11959  GMOCK_MATCHER_(tn, 10, \
11960  __VA_ARGS__) gmock_a10) constness { \
11961  GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \
11962  return GMOCK_MOCKER_(10, constness, Method).With(gmock_a1, gmock_a2, \
11963  gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
11964  gmock_a10); \
11965  } \
11966  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(10, constness, \
11967  Method)
11968 
11969 #define MOCK_METHOD0(m, ...) GMOCK_METHOD0_(, , , m, __VA_ARGS__)
11970 #define MOCK_METHOD1(m, ...) GMOCK_METHOD1_(, , , m, __VA_ARGS__)
11971 #define MOCK_METHOD2(m, ...) GMOCK_METHOD2_(, , , m, __VA_ARGS__)
11972 #define MOCK_METHOD3(m, ...) GMOCK_METHOD3_(, , , m, __VA_ARGS__)
11973 #define MOCK_METHOD4(m, ...) GMOCK_METHOD4_(, , , m, __VA_ARGS__)
11974 #define MOCK_METHOD5(m, ...) GMOCK_METHOD5_(, , , m, __VA_ARGS__)
11975 #define MOCK_METHOD6(m, ...) GMOCK_METHOD6_(, , , m, __VA_ARGS__)
11976 #define MOCK_METHOD7(m, ...) GMOCK_METHOD7_(, , , m, __VA_ARGS__)
11977 #define MOCK_METHOD8(m, ...) GMOCK_METHOD8_(, , , m, __VA_ARGS__)
11978 #define MOCK_METHOD9(m, ...) GMOCK_METHOD9_(, , , m, __VA_ARGS__)
11979 #define MOCK_METHOD10(m, ...) GMOCK_METHOD10_(, , , m, __VA_ARGS__)
11980 
11981 #define MOCK_CONST_METHOD0(m, ...) GMOCK_METHOD0_(, const, , m, __VA_ARGS__)
11982 #define MOCK_CONST_METHOD1(m, ...) GMOCK_METHOD1_(, const, , m, __VA_ARGS__)
11983 #define MOCK_CONST_METHOD2(m, ...) GMOCK_METHOD2_(, const, , m, __VA_ARGS__)
11984 #define MOCK_CONST_METHOD3(m, ...) GMOCK_METHOD3_(, const, , m, __VA_ARGS__)
11985 #define MOCK_CONST_METHOD4(m, ...) GMOCK_METHOD4_(, const, , m, __VA_ARGS__)
11986 #define MOCK_CONST_METHOD5(m, ...) GMOCK_METHOD5_(, const, , m, __VA_ARGS__)
11987 #define MOCK_CONST_METHOD6(m, ...) GMOCK_METHOD6_(, const, , m, __VA_ARGS__)
11988 #define MOCK_CONST_METHOD7(m, ...) GMOCK_METHOD7_(, const, , m, __VA_ARGS__)
11989 #define MOCK_CONST_METHOD8(m, ...) GMOCK_METHOD8_(, const, , m, __VA_ARGS__)
11990 #define MOCK_CONST_METHOD9(m, ...) GMOCK_METHOD9_(, const, , m, __VA_ARGS__)
11991 #define MOCK_CONST_METHOD10(m, ...) GMOCK_METHOD10_(, const, , m, __VA_ARGS__)
11992 
11993 #define MOCK_METHOD0_T(m, ...) GMOCK_METHOD0_(typename, , , m, __VA_ARGS__)
11994 #define MOCK_METHOD1_T(m, ...) GMOCK_METHOD1_(typename, , , m, __VA_ARGS__)
11995 #define MOCK_METHOD2_T(m, ...) GMOCK_METHOD2_(typename, , , m, __VA_ARGS__)
11996 #define MOCK_METHOD3_T(m, ...) GMOCK_METHOD3_(typename, , , m, __VA_ARGS__)
11997 #define MOCK_METHOD4_T(m, ...) GMOCK_METHOD4_(typename, , , m, __VA_ARGS__)
11998 #define MOCK_METHOD5_T(m, ...) GMOCK_METHOD5_(typename, , , m, __VA_ARGS__)
11999 #define MOCK_METHOD6_T(m, ...) GMOCK_METHOD6_(typename, , , m, __VA_ARGS__)
12000 #define MOCK_METHOD7_T(m, ...) GMOCK_METHOD7_(typename, , , m, __VA_ARGS__)
12001 #define MOCK_METHOD8_T(m, ...) GMOCK_METHOD8_(typename, , , m, __VA_ARGS__)
12002 #define MOCK_METHOD9_T(m, ...) GMOCK_METHOD9_(typename, , , m, __VA_ARGS__)
12003 #define MOCK_METHOD10_T(m, ...) GMOCK_METHOD10_(typename, , , m, __VA_ARGS__)
12004 
12005 #define MOCK_CONST_METHOD0_T(m, ...) \
12006  GMOCK_METHOD0_(typename, const, , m, __VA_ARGS__)
12007 #define MOCK_CONST_METHOD1_T(m, ...) \
12008  GMOCK_METHOD1_(typename, const, , m, __VA_ARGS__)
12009 #define MOCK_CONST_METHOD2_T(m, ...) \
12010  GMOCK_METHOD2_(typename, const, , m, __VA_ARGS__)
12011 #define MOCK_CONST_METHOD3_T(m, ...) \
12012  GMOCK_METHOD3_(typename, const, , m, __VA_ARGS__)
12013 #define MOCK_CONST_METHOD4_T(m, ...) \
12014  GMOCK_METHOD4_(typename, const, , m, __VA_ARGS__)
12015 #define MOCK_CONST_METHOD5_T(m, ...) \
12016  GMOCK_METHOD5_(typename, const, , m, __VA_ARGS__)
12017 #define MOCK_CONST_METHOD6_T(m, ...) \
12018  GMOCK_METHOD6_(typename, const, , m, __VA_ARGS__)
12019 #define MOCK_CONST_METHOD7_T(m, ...) \
12020  GMOCK_METHOD7_(typename, const, , m, __VA_ARGS__)
12021 #define MOCK_CONST_METHOD8_T(m, ...) \
12022  GMOCK_METHOD8_(typename, const, , m, __VA_ARGS__)
12023 #define MOCK_CONST_METHOD9_T(m, ...) \
12024  GMOCK_METHOD9_(typename, const, , m, __VA_ARGS__)
12025 #define MOCK_CONST_METHOD10_T(m, ...) \
12026  GMOCK_METHOD10_(typename, const, , m, __VA_ARGS__)
12027 
12028 #define MOCK_METHOD0_WITH_CALLTYPE(ct, m, ...) \
12029  GMOCK_METHOD0_(, , ct, m, __VA_ARGS__)
12030 #define MOCK_METHOD1_WITH_CALLTYPE(ct, m, ...) \
12031  GMOCK_METHOD1_(, , ct, m, __VA_ARGS__)
12032 #define MOCK_METHOD2_WITH_CALLTYPE(ct, m, ...) \
12033  GMOCK_METHOD2_(, , ct, m, __VA_ARGS__)
12034 #define MOCK_METHOD3_WITH_CALLTYPE(ct, m, ...) \
12035  GMOCK_METHOD3_(, , ct, m, __VA_ARGS__)
12036 #define MOCK_METHOD4_WITH_CALLTYPE(ct, m, ...) \
12037  GMOCK_METHOD4_(, , ct, m, __VA_ARGS__)
12038 #define MOCK_METHOD5_WITH_CALLTYPE(ct, m, ...) \
12039  GMOCK_METHOD5_(, , ct, m, __VA_ARGS__)
12040 #define MOCK_METHOD6_WITH_CALLTYPE(ct, m, ...) \
12041  GMOCK_METHOD6_(, , ct, m, __VA_ARGS__)
12042 #define MOCK_METHOD7_WITH_CALLTYPE(ct, m, ...) \
12043  GMOCK_METHOD7_(, , ct, m, __VA_ARGS__)
12044 #define MOCK_METHOD8_WITH_CALLTYPE(ct, m, ...) \
12045  GMOCK_METHOD8_(, , ct, m, __VA_ARGS__)
12046 #define MOCK_METHOD9_WITH_CALLTYPE(ct, m, ...) \
12047  GMOCK_METHOD9_(, , ct, m, __VA_ARGS__)
12048 #define MOCK_METHOD10_WITH_CALLTYPE(ct, m, ...) \
12049  GMOCK_METHOD10_(, , ct, m, __VA_ARGS__)
12050 
12051 #define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, ...) \
12052  GMOCK_METHOD0_(, const, ct, m, __VA_ARGS__)
12053 #define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, ...) \
12054  GMOCK_METHOD1_(, const, ct, m, __VA_ARGS__)
12055 #define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, ...) \
12056  GMOCK_METHOD2_(, const, ct, m, __VA_ARGS__)
12057 #define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, ...) \
12058  GMOCK_METHOD3_(, const, ct, m, __VA_ARGS__)
12059 #define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, ...) \
12060  GMOCK_METHOD4_(, const, ct, m, __VA_ARGS__)
12061 #define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, ...) \
12062  GMOCK_METHOD5_(, const, ct, m, __VA_ARGS__)
12063 #define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, ...) \
12064  GMOCK_METHOD6_(, const, ct, m, __VA_ARGS__)
12065 #define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, ...) \
12066  GMOCK_METHOD7_(, const, ct, m, __VA_ARGS__)
12067 #define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, ...) \
12068  GMOCK_METHOD8_(, const, ct, m, __VA_ARGS__)
12069 #define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, ...) \
12070  GMOCK_METHOD9_(, const, ct, m, __VA_ARGS__)
12071 #define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, ...) \
12072  GMOCK_METHOD10_(, const, ct, m, __VA_ARGS__)
12073 
12074 #define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
12075  GMOCK_METHOD0_(typename, , ct, m, __VA_ARGS__)
12076 #define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
12077  GMOCK_METHOD1_(typename, , ct, m, __VA_ARGS__)
12078 #define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
12079  GMOCK_METHOD2_(typename, , ct, m, __VA_ARGS__)
12080 #define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
12081  GMOCK_METHOD3_(typename, , ct, m, __VA_ARGS__)
12082 #define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
12083  GMOCK_METHOD4_(typename, , ct, m, __VA_ARGS__)
12084 #define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
12085  GMOCK_METHOD5_(typename, , ct, m, __VA_ARGS__)
12086 #define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
12087  GMOCK_METHOD6_(typename, , ct, m, __VA_ARGS__)
12088 #define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
12089  GMOCK_METHOD7_(typename, , ct, m, __VA_ARGS__)
12090 #define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
12091  GMOCK_METHOD8_(typename, , ct, m, __VA_ARGS__)
12092 #define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
12093  GMOCK_METHOD9_(typename, , ct, m, __VA_ARGS__)
12094 #define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
12095  GMOCK_METHOD10_(typename, , ct, m, __VA_ARGS__)
12096 
12097 #define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \
12098  GMOCK_METHOD0_(typename, const, ct, m, __VA_ARGS__)
12099 #define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \
12100  GMOCK_METHOD1_(typename, const, ct, m, __VA_ARGS__)
12101 #define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \
12102  GMOCK_METHOD2_(typename, const, ct, m, __VA_ARGS__)
12103 #define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \
12104  GMOCK_METHOD3_(typename, const, ct, m, __VA_ARGS__)
12105 #define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \
12106  GMOCK_METHOD4_(typename, const, ct, m, __VA_ARGS__)
12107 #define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \
12108  GMOCK_METHOD5_(typename, const, ct, m, __VA_ARGS__)
12109 #define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \
12110  GMOCK_METHOD6_(typename, const, ct, m, __VA_ARGS__)
12111 #define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \
12112  GMOCK_METHOD7_(typename, const, ct, m, __VA_ARGS__)
12113 #define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \
12114  GMOCK_METHOD8_(typename, const, ct, m, __VA_ARGS__)
12115 #define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \
12116  GMOCK_METHOD9_(typename, const, ct, m, __VA_ARGS__)
12117 #define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
12118  GMOCK_METHOD10_(typename, const, ct, m, __VA_ARGS__)
12119 
12120 // A MockFunction<F> class has one mock method whose type is F. It is
12121 // useful when you just want your test code to emit some messages and
12122 // have Google Mock verify the right messages are sent (and perhaps at
12123 // the right times). For example, if you are exercising code:
12124 //
12125 // Foo(1);
12126 // Foo(2);
12127 // Foo(3);
12128 //
12129 // and want to verify that Foo(1) and Foo(3) both invoke
12130 // mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
12131 //
12132 // TEST(FooTest, InvokesBarCorrectly) {
12133 // MyMock mock;
12134 // MockFunction<void(string check_point_name)> check;
12135 // {
12136 // InSequence s;
12137 //
12138 // EXPECT_CALL(mock, Bar("a"));
12139 // EXPECT_CALL(check, Call("1"));
12140 // EXPECT_CALL(check, Call("2"));
12141 // EXPECT_CALL(mock, Bar("a"));
12142 // }
12143 // Foo(1);
12144 // check.Call("1");
12145 // Foo(2);
12146 // check.Call("2");
12147 // Foo(3);
12148 // }
12149 //
12150 // The expectation spec says that the first Bar("a") must happen
12151 // before check point "1", the second Bar("a") must happen after check
12152 // point "2", and nothing should happen between the two check
12153 // points. The explicit check points make it easy to tell which
12154 // Bar("a") is called by which call to Foo().
12155 template <typename F>
12157 
12158 template <typename R>
12159 class MockFunction<R()>
12160 {
12161 public:
12163 
12164  MOCK_METHOD0_T(Call, R());
12165 
12166 private:
12168 };
12169 
12170 template <typename R, typename A0>
12171 class MockFunction<R(A0)>
12172 {
12173 public:
12175 
12176  MOCK_METHOD1_T(Call, R(A0));
12177 
12178 private:
12180 };
12181 
12182 template <typename R, typename A0, typename A1>
12183 class MockFunction<R(A0, A1)>
12184 {
12185 public:
12187 
12188  MOCK_METHOD2_T(Call, R(A0, A1));
12189 
12190 private:
12192 };
12193 
12194 template <typename R, typename A0, typename A1, typename A2>
12195 class MockFunction<R(A0, A1, A2)>
12196 {
12197 public:
12199 
12200  MOCK_METHOD3_T(Call, R(A0, A1, A2));
12201 
12202 private:
12204 };
12205 
12206 template <typename R, typename A0, typename A1, typename A2, typename A3>
12207 class MockFunction<R(A0, A1, A2, A3)>
12208 {
12209 public:
12211 
12212  MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));
12213 
12214 private:
12216 };
12217 
12218 template <typename R, typename A0, typename A1, typename A2, typename A3,
12219  typename A4>
12220 class MockFunction<R(A0, A1, A2, A3, A4)>
12221 {
12222 public:
12224 
12225  MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));
12226 
12227 private:
12229 };
12230 
12231 template <typename R, typename A0, typename A1, typename A2, typename A3,
12232  typename A4, typename A5>
12233 class MockFunction<R(A0, A1, A2, A3, A4, A5)>
12234 {
12235 public:
12237 
12238  MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));
12239 
12240 private:
12242 };
12243 
12244 template <typename R, typename A0, typename A1, typename A2, typename A3,
12245  typename A4, typename A5, typename A6>
12246 class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)>
12247 {
12248 public:
12250 
12251  MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));
12252 
12253 private:
12255 };
12256 
12257 template <typename R, typename A0, typename A1, typename A2, typename A3,
12258  typename A4, typename A5, typename A6, typename A7>
12259 class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)>
12260 {
12261 public:
12263 
12264  MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));
12265 
12266 private:
12268 };
12269 
12270 template <typename R, typename A0, typename A1, typename A2, typename A3,
12271  typename A4, typename A5, typename A6, typename A7, typename A8>
12272 class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)>
12273 {
12274 public:
12276 
12277  MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));
12278 
12279 private:
12281 };
12282 
12283 template <typename R, typename A0, typename A1, typename A2, typename A3,
12284  typename A4, typename A5, typename A6, typename A7, typename A8,
12285  typename A9>
12286 class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)>
12287 {
12288 public:
12290 
12291  MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
12292 
12293 private:
12295 };
12296 
12297 } // namespace testing
12298 
12299 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
12300 // This file was GENERATED by command:
12301 // pump.py gmock-generated-nice-strict.h.pump
12302 // DO NOT EDIT BY HAND!!!
12303 
12304 // Copyright 2008, Google Inc.
12305 // All rights reserved.
12306 //
12307 // Redistribution and use in source and binary forms, with or without
12308 // modification, are permitted provided that the following conditions are
12309 // met:
12310 //
12311 // * Redistributions of source code must retain the above copyright
12312 // notice, this list of conditions and the following disclaimer.
12313 // * Redistributions in binary form must reproduce the above
12314 // copyright notice, this list of conditions and the following disclaimer
12315 // in the documentation and/or other materials provided with the
12316 // distribution.
12317 // * Neither the name of Google Inc. nor the names of its
12318 // contributors may be used to endorse or promote products derived from
12319 // this software without specific prior written permission.
12320 //
12321 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
12322 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
12323 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
12324 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
12325 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
12326 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
12327 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12328 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12329 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12330 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
12331 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12332 //
12333 // Author: wan@google.com (Zhanyong Wan)
12334 
12335 // Implements class templates NiceMock, NaggyMock, and StrictMock.
12336 //
12337 // Given a mock class MockFoo that is created using Google Mock,
12338 // NiceMock<MockFoo> is a subclass of MockFoo that allows
12339 // uninteresting calls (i.e. calls to mock methods that have no
12340 // EXPECT_CALL specs), NaggyMock<MockFoo> is a subclass of MockFoo
12341 // that prints a warning when an uninteresting call occurs, and
12342 // StrictMock<MockFoo> is a subclass of MockFoo that treats all
12343 // uninteresting calls as errors.
12344 //
12345 // Currently a mock is naggy by default, so MockFoo and
12346 // NaggyMock<MockFoo> behave like the same. However, we will soon
12347 // switch the default behavior of mocks to be nice, as that in general
12348 // leads to more maintainable tests. When that happens, MockFoo will
12349 // stop behaving like NaggyMock<MockFoo> and start behaving like
12350 // NiceMock<MockFoo>.
12351 //
12352 // NiceMock, NaggyMock, and StrictMock "inherit" the constructors of
12353 // their respective base class, with up-to 10 arguments. Therefore
12354 // you can write NiceMock<MockFoo>(5, "a") to construct a nice mock
12355 // where MockFoo has a constructor that accepts (int, const char*),
12356 // for example.
12357 //
12358 // A known limitation is that NiceMock<MockFoo>, NaggyMock<MockFoo>,
12359 // and StrictMock<MockFoo> only works for mock methods defined using
12360 // the MOCK_METHOD* family of macros DIRECTLY in the MockFoo class.
12361 // If a mock method is defined in a base class of MockFoo, the "nice"
12362 // or "strict" modifier may not affect it, depending on the compiler.
12363 // In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
12364 // supported.
12365 //
12366 // Another known limitation is that the constructors of the base mock
12367 // cannot have arguments passed by non-const reference, which are
12368 // banned by the Google C++ style guide anyway.
12369 
12370 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
12371 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
12372 
12373 
12374 namespace testing
12375 {
12376 
12377 template <class MockClass>
12378 class NiceMock : public MockClass
12379 {
12380 public:
12381  // We don't factor out the constructor body to a common method, as
12382  // we have to avoid a possible clash with members of MockClass.
12384  {
12385  ::testing::Mock::AllowUninterestingCalls(
12386  internal::ImplicitCast_<MockClass *>(this));
12387  }
12388 
12389  // C++ doesn't (yet) allow inheritance of constructors, so we have
12390  // to define it for each arity.
12391  template <typename A1>
12392  explicit NiceMock(const A1 & a1) : MockClass(a1)
12393  {
12394  ::testing::Mock::AllowUninterestingCalls(
12395  internal::ImplicitCast_<MockClass *>(this));
12396  }
12397  template <typename A1, typename A2>
12398  NiceMock(const A1 & a1, const A2 & a2) : MockClass(a1, a2)
12399  {
12400  ::testing::Mock::AllowUninterestingCalls(
12401  internal::ImplicitCast_<MockClass *>(this));
12402  }
12403 
12404  template <typename A1, typename A2, typename A3>
12405  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3) : MockClass(a1, a2, a3)
12406  {
12407  ::testing::Mock::AllowUninterestingCalls(
12408  internal::ImplicitCast_<MockClass *>(this));
12409  }
12410 
12411  template <typename A1, typename A2, typename A3, typename A4>
12412  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3,
12413  const A4 & a4) : MockClass(a1, a2, a3, a4)
12414  {
12415  ::testing::Mock::AllowUninterestingCalls(
12416  internal::ImplicitCast_<MockClass *>(this));
12417  }
12418 
12419  template <typename A1, typename A2, typename A3, typename A4, typename A5>
12420  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12421  const A5 & a5) : MockClass(a1, a2, a3, a4, a5)
12422  {
12423  ::testing::Mock::AllowUninterestingCalls(
12424  internal::ImplicitCast_<MockClass *>(this));
12425  }
12426 
12427  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12428  typename A6>
12429  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12430  const A5 & a5, const A6 & a6) : MockClass(a1, a2, a3, a4, a5, a6)
12431  {
12432  ::testing::Mock::AllowUninterestingCalls(
12433  internal::ImplicitCast_<MockClass *>(this));
12434  }
12435 
12436  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12437  typename A6, typename A7>
12438  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12439  const A5 & a5, const A6 & a6, const A7 & a7) : MockClass(a1, a2, a3, a4, a5,
12440  a6, a7)
12441  {
12442  ::testing::Mock::AllowUninterestingCalls(
12443  internal::ImplicitCast_<MockClass *>(this));
12444  }
12445 
12446  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12447  typename A6, typename A7, typename A8>
12448  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12449  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8) : MockClass(a1,
12450  a2, a3, a4, a5, a6, a7, a8)
12451  {
12452  ::testing::Mock::AllowUninterestingCalls(
12453  internal::ImplicitCast_<MockClass *>(this));
12454  }
12455 
12456  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12457  typename A6, typename A7, typename A8, typename A9>
12458  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12459  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8,
12460  const A9 & a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9)
12461  {
12462  ::testing::Mock::AllowUninterestingCalls(
12463  internal::ImplicitCast_<MockClass *>(this));
12464  }
12465 
12466  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12467  typename A6, typename A7, typename A8, typename A9, typename A10>
12468  NiceMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12469  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8, const A9 & a9,
12470  const A10 & a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
12471  {
12472  ::testing::Mock::AllowUninterestingCalls(
12473  internal::ImplicitCast_<MockClass *>(this));
12474  }
12475 
12476  virtual ~NiceMock()
12477  {
12478  ::testing::Mock::UnregisterCallReaction(
12479  internal::ImplicitCast_<MockClass *>(this));
12480  }
12481 
12482 private:
12484 };
12485 
12486 template <class MockClass>
12487 class NaggyMock : public MockClass
12488 {
12489 public:
12490  // We don't factor out the constructor body to a common method, as
12491  // we have to avoid a possible clash with members of MockClass.
12493  {
12494  ::testing::Mock::WarnUninterestingCalls(
12495  internal::ImplicitCast_<MockClass *>(this));
12496  }
12497 
12498  // C++ doesn't (yet) allow inheritance of constructors, so we have
12499  // to define it for each arity.
12500  template <typename A1>
12501  explicit NaggyMock(const A1 & a1) : MockClass(a1)
12502  {
12503  ::testing::Mock::WarnUninterestingCalls(
12504  internal::ImplicitCast_<MockClass *>(this));
12505  }
12506  template <typename A1, typename A2>
12507  NaggyMock(const A1 & a1, const A2 & a2) : MockClass(a1, a2)
12508  {
12509  ::testing::Mock::WarnUninterestingCalls(
12510  internal::ImplicitCast_<MockClass *>(this));
12511  }
12512 
12513  template <typename A1, typename A2, typename A3>
12514  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3) : MockClass(a1, a2, a3)
12515  {
12516  ::testing::Mock::WarnUninterestingCalls(
12517  internal::ImplicitCast_<MockClass *>(this));
12518  }
12519 
12520  template <typename A1, typename A2, typename A3, typename A4>
12521  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3,
12522  const A4 & a4) : MockClass(a1, a2, a3, a4)
12523  {
12524  ::testing::Mock::WarnUninterestingCalls(
12525  internal::ImplicitCast_<MockClass *>(this));
12526  }
12527 
12528  template <typename A1, typename A2, typename A3, typename A4, typename A5>
12529  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12530  const A5 & a5) : MockClass(a1, a2, a3, a4, a5)
12531  {
12532  ::testing::Mock::WarnUninterestingCalls(
12533  internal::ImplicitCast_<MockClass *>(this));
12534  }
12535 
12536  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12537  typename A6>
12538  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12539  const A5 & a5, const A6 & a6) : MockClass(a1, a2, a3, a4, a5, a6)
12540  {
12541  ::testing::Mock::WarnUninterestingCalls(
12542  internal::ImplicitCast_<MockClass *>(this));
12543  }
12544 
12545  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12546  typename A6, typename A7>
12547  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12548  const A5 & a5, const A6 & a6, const A7 & a7) : MockClass(a1, a2, a3, a4, a5,
12549  a6, a7)
12550  {
12551  ::testing::Mock::WarnUninterestingCalls(
12552  internal::ImplicitCast_<MockClass *>(this));
12553  }
12554 
12555  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12556  typename A6, typename A7, typename A8>
12557  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12558  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8) : MockClass(a1,
12559  a2, a3, a4, a5, a6, a7, a8)
12560  {
12561  ::testing::Mock::WarnUninterestingCalls(
12562  internal::ImplicitCast_<MockClass *>(this));
12563  }
12564 
12565  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12566  typename A6, typename A7, typename A8, typename A9>
12567  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12568  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8,
12569  const A9 & a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9)
12570  {
12571  ::testing::Mock::WarnUninterestingCalls(
12572  internal::ImplicitCast_<MockClass *>(this));
12573  }
12574 
12575  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12576  typename A6, typename A7, typename A8, typename A9, typename A10>
12577  NaggyMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12578  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8, const A9 & a9,
12579  const A10 & a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
12580  {
12581  ::testing::Mock::WarnUninterestingCalls(
12582  internal::ImplicitCast_<MockClass *>(this));
12583  }
12584 
12585  virtual ~NaggyMock()
12586  {
12587  ::testing::Mock::UnregisterCallReaction(
12588  internal::ImplicitCast_<MockClass *>(this));
12589  }
12590 
12591 private:
12593 };
12594 
12595 template <class MockClass>
12596 class StrictMock : public MockClass
12597 {
12598 public:
12599  // We don't factor out the constructor body to a common method, as
12600  // we have to avoid a possible clash with members of MockClass.
12602  {
12603  ::testing::Mock::FailUninterestingCalls(
12604  internal::ImplicitCast_<MockClass *>(this));
12605  }
12606 
12607  // C++ doesn't (yet) allow inheritance of constructors, so we have
12608  // to define it for each arity.
12609  template <typename A1>
12610  explicit StrictMock(const A1 & a1) : MockClass(a1)
12611  {
12612  ::testing::Mock::FailUninterestingCalls(
12613  internal::ImplicitCast_<MockClass *>(this));
12614  }
12615  template <typename A1, typename A2>
12616  StrictMock(const A1 & a1, const A2 & a2) : MockClass(a1, a2)
12617  {
12618  ::testing::Mock::FailUninterestingCalls(
12619  internal::ImplicitCast_<MockClass *>(this));
12620  }
12621 
12622  template <typename A1, typename A2, typename A3>
12623  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3) : MockClass(a1, a2, a3)
12624  {
12625  ::testing::Mock::FailUninterestingCalls(
12626  internal::ImplicitCast_<MockClass *>(this));
12627  }
12628 
12629  template <typename A1, typename A2, typename A3, typename A4>
12630  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3,
12631  const A4 & a4) : MockClass(a1, a2, a3, a4)
12632  {
12633  ::testing::Mock::FailUninterestingCalls(
12634  internal::ImplicitCast_<MockClass *>(this));
12635  }
12636 
12637  template <typename A1, typename A2, typename A3, typename A4, typename A5>
12638  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12639  const A5 & a5) : MockClass(a1, a2, a3, a4, a5)
12640  {
12641  ::testing::Mock::FailUninterestingCalls(
12642  internal::ImplicitCast_<MockClass *>(this));
12643  }
12644 
12645  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12646  typename A6>
12647  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12648  const A5 & a5, const A6 & a6) : MockClass(a1, a2, a3, a4, a5, a6)
12649  {
12650  ::testing::Mock::FailUninterestingCalls(
12651  internal::ImplicitCast_<MockClass *>(this));
12652  }
12653 
12654  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12655  typename A6, typename A7>
12656  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12657  const A5 & a5, const A6 & a6, const A7 & a7) : MockClass(a1, a2, a3, a4, a5,
12658  a6, a7)
12659  {
12660  ::testing::Mock::FailUninterestingCalls(
12661  internal::ImplicitCast_<MockClass *>(this));
12662  }
12663 
12664  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12665  typename A6, typename A7, typename A8>
12666  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12667  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8) : MockClass(a1,
12668  a2, a3, a4, a5, a6, a7, a8)
12669  {
12670  ::testing::Mock::FailUninterestingCalls(
12671  internal::ImplicitCast_<MockClass *>(this));
12672  }
12673 
12674  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12675  typename A6, typename A7, typename A8, typename A9>
12676  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12677  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8,
12678  const A9 & a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9)
12679  {
12680  ::testing::Mock::FailUninterestingCalls(
12681  internal::ImplicitCast_<MockClass *>(this));
12682  }
12683 
12684  template <typename A1, typename A2, typename A3, typename A4, typename A5,
12685  typename A6, typename A7, typename A8, typename A9, typename A10>
12686  StrictMock(const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4,
12687  const A5 & a5, const A6 & a6, const A7 & a7, const A8 & a8, const A9 & a9,
12688  const A10 & a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
12689  {
12690  ::testing::Mock::FailUninterestingCalls(
12691  internal::ImplicitCast_<MockClass *>(this));
12692  }
12693 
12694  virtual ~StrictMock()
12695  {
12696  ::testing::Mock::UnregisterCallReaction(
12697  internal::ImplicitCast_<MockClass *>(this));
12698  }
12699 
12700 private:
12702 };
12703 
12704 // The following specializations catch some (relatively more common)
12705 // user errors of nesting nice and strict mocks. They do NOT catch
12706 // all possible errors.
12707 
12708 // These specializations are declared but not defined, as NiceMock,
12709 // NaggyMock, and StrictMock cannot be nested.
12710 
12711 template <typename MockClass>
12712 class NiceMock<NiceMock<MockClass> >;
12713 template <typename MockClass>
12714 class NiceMock<NaggyMock<MockClass> >;
12715 template <typename MockClass>
12716 class NiceMock<StrictMock<MockClass> >;
12717 
12718 template <typename MockClass>
12719 class NaggyMock<NiceMock<MockClass> >;
12720 template <typename MockClass>
12721 class NaggyMock<NaggyMock<MockClass> >;
12722 template <typename MockClass>
12723 class NaggyMock<StrictMock<MockClass> >;
12724 
12725 template <typename MockClass>
12726 class StrictMock<NiceMock<MockClass> >;
12727 template <typename MockClass>
12728 class StrictMock<NaggyMock<MockClass> >;
12729 template <typename MockClass>
12730 class StrictMock<StrictMock<MockClass> >;
12731 
12732 } // namespace testing
12733 
12734 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
12735 // This file was GENERATED by command:
12736 // pump.py gmock-generated-matchers.h.pump
12737 // DO NOT EDIT BY HAND!!!
12738 
12739 // Copyright 2008, Google Inc.
12740 // All rights reserved.
12741 //
12742 // Redistribution and use in source and binary forms, with or without
12743 // modification, are permitted provided that the following conditions are
12744 // met:
12745 //
12746 // * Redistributions of source code must retain the above copyright
12747 // notice, this list of conditions and the following disclaimer.
12748 // * Redistributions in binary form must reproduce the above
12749 // copyright notice, this list of conditions and the following disclaimer
12750 // in the documentation and/or other materials provided with the
12751 // distribution.
12752 // * Neither the name of Google Inc. nor the names of its
12753 // contributors may be used to endorse or promote products derived from
12754 // this software without specific prior written permission.
12755 //
12756 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
12757 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
12758 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
12759 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
12760 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
12761 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
12762 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12763 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12764 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12765 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
12766 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12767 
12768 // Google Mock - a framework for writing C++ mock classes.
12769 //
12770 // This file implements some commonly used variadic matchers.
12771 
12772 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
12773 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
12774 
12775 #include <iterator>
12776 #include <sstream>
12777 #include <string>
12778 #include <vector>
12779 
12780 namespace testing
12781 {
12782 namespace internal
12783 {
12784 
12785 // The type of the i-th (0-based) field of Tuple.
12786 #define GMOCK_FIELD_TYPE_(Tuple, i) \
12787  typename ::std::tr1::tuple_element<i, Tuple>::type
12788 
12789 // TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
12790 // tuple of type Tuple. It has two members:
12791 //
12792 // type: a tuple type whose i-th field is the ki-th field of Tuple.
12793 // GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
12794 //
12795 // For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
12796 //
12797 // type is tuple<int, bool>, and
12798 // GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
12799 
12800 template < class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
12801  int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
12802  int k9 = -1 >
12804 
12805 // This generic version is used when there are 10 selectors.
12806 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
12807  int k7, int k8, int k9>
12808 class TupleFields
12809 {
12810 public:
12811  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
12812  GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
12813  GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
12814  GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
12815  GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
12817  static type GetSelectedFields(const Tuple & t)
12818  {
12820  return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
12821  get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
12822  }
12823 };
12824 
12825 // The following specialization is used for 0 ~ 9 selectors.
12826 
12827 template <class Tuple>
12828 class TupleFields < Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 >
12829 {
12830 public:
12831  typedef ::std::tr1::tuple<> type;
12832  static type GetSelectedFields(const Tuple & /* t */)
12833  {
12835  return type();
12836  }
12837 };
12838 
12839 template <class Tuple, int k0>
12840 class TupleFields < Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1 >
12841 {
12842 public:
12843  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
12844  static type GetSelectedFields(const Tuple & t)
12845  {
12847  return type(get<k0>(t));
12848  }
12849 };
12850 
12851 template <class Tuple, int k0, int k1>
12852 class TupleFields < Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1 >
12853 {
12854 public:
12855  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
12857  static type GetSelectedFields(const Tuple & t)
12858  {
12860  return type(get<k0>(t), get<k1>(t));
12861  }
12862 };
12863 
12864 template <class Tuple, int k0, int k1, int k2>
12865 class TupleFields < Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1 >
12866 {
12867 public:
12868  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
12869  GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
12870  static type GetSelectedFields(const Tuple & t)
12871  {
12873  return type(get<k0>(t), get<k1>(t), get<k2>(t));
12874  }
12875 };
12876 
12877 template <class Tuple, int k0, int k1, int k2, int k3>
12878 class TupleFields < Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1 >
12879 {
12880 public:
12881  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
12882  GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
12884  static type GetSelectedFields(const Tuple & t)
12885  {
12887  return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
12888  }
12889 };
12890 
12891 template <class Tuple, int k0, int k1, int k2, int k3, int k4>
12892 class TupleFields < Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1 >
12893 {
12894 public:
12895  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
12896  GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
12897  GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
12898  static type GetSelectedFields(const Tuple & t)
12899  {
12901  return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
12902  }
12903 };
12904 
12905 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
12906 class TupleFields < Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1 >
12907 {
12908 public:
12909  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
12910  GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
12911  GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
12913  static type GetSelectedFields(const Tuple & t)
12914  {
12916  return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
12917  get<k5>(t));
12918  }
12919 };
12920 
12921 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
12922 class TupleFields < Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1 >
12923 {
12924 public:
12925  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
12926  GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
12927  GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
12928  GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
12929  static type GetSelectedFields(const Tuple & t)
12930  {
12932  return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
12933  get<k5>(t), get<k6>(t));
12934  }
12935 };
12936 
12937 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
12938  int k7>
12939 class TupleFields < Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1 >
12940 {
12941 public:
12942  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
12943  GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
12944  GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
12945  GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
12947  static type GetSelectedFields(const Tuple & t)
12948  {
12950  return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
12951  get<k5>(t), get<k6>(t), get<k7>(t));
12952  }
12953 };
12954 
12955 template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
12956  int k7, int k8>
12957 class TupleFields < Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1 >
12958 {
12959 public:
12960  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
12961  GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
12962  GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
12963  GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
12964  GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
12965  static type GetSelectedFields(const Tuple & t)
12966  {
12968  return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
12969  get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
12970  }
12971 };
12972 
12973 #undef GMOCK_FIELD_TYPE_
12974 
12975 // Implements the Args() matcher.
12976 template < class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
12977  int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
12978  int k9 = -1 >
12979 class ArgsMatcherImpl : public MatcherInterface<ArgsTuple>
12980 {
12981 public:
12982  // ArgsTuple may have top-level const or reference modifiers.
12983  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;
12984  typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,
12985  k6, k7, k8, k9>::type SelectedArgs;
12987 
12988  template <typename InnerMatcher>
12989  explicit ArgsMatcherImpl(const InnerMatcher & inner_matcher)
12990  : inner_matcher_(SafeMatcherCast<const SelectedArgs & >(inner_matcher)) {}
12991 
12992  virtual bool MatchAndExplain(ArgsTuple args,
12993  MatchResultListener * listener) const
12994  {
12995  const SelectedArgs & selected_args = GetSelectedArgs(args);
12996 
12997  if (!listener->IsInterested())
12998  { return inner_matcher_.Matches(selected_args); }
12999 
13000  PrintIndices(listener->stream());
13001  *listener << "are " << PrintToString(selected_args);
13002 
13003  StringMatchResultListener inner_listener;
13004  const bool match = inner_matcher_.MatchAndExplain(selected_args,
13005  &inner_listener);
13006  PrintIfNotEmpty(inner_listener.str(), listener->stream());
13007  return match;
13008  }
13009 
13010  virtual void DescribeTo(::std::ostream * os) const
13011  {
13012  *os << "are a tuple ";
13013  PrintIndices(os);
13014  inner_matcher_.DescribeTo(os);
13015  }
13016 
13017  virtual void DescribeNegationTo(::std::ostream * os) const
13018  {
13019  *os << "are a tuple ";
13020  PrintIndices(os);
13021  inner_matcher_.DescribeNegationTo(os);
13022  }
13023 
13024 private:
13025  static SelectedArgs GetSelectedArgs(ArgsTuple args)
13026  {
13027  return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
13028  k9>::GetSelectedFields(args);
13029  }
13030 
13031  // Prints the indices of the selected fields.
13032  static void PrintIndices(::std::ostream * os)
13033  {
13034  *os << "whose fields (";
13035  const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
13036 
13037  for (int i = 0; i < 10; i++)
13038  {
13039  if (indices[i] < 0)
13040  { break; }
13041 
13042  if (i >= 1)
13043  { *os << ", "; }
13044 
13045  *os << "#" << indices[i];
13046  }
13047 
13048  *os << ") ";
13049  }
13050 
13051  const MonomorphicInnerMatcher inner_matcher_;
13052 
13054 };
13055 
13056 template < class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
13057  int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,
13058  int k8 = -1, int k9 = -1 >
13060 {
13061 public:
13062  explicit ArgsMatcher(const InnerMatcher & inner_matcher)
13063  : inner_matcher_(inner_matcher) {}
13064 
13065  template <typename ArgsTuple>
13066  operator Matcher<ArgsTuple>() const
13067  {
13068  return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k5,
13069  k6, k7, k8, k9>(inner_matcher_));
13070  }
13071 
13072 private:
13073  const InnerMatcher inner_matcher_;
13074 
13076 };
13077 
13078 // A set of metafunctions for computing the result type of AllOf.
13079 // AllOf(m1, ..., mN) returns
13080 // AllOfResultN<decltype(m1), ..., decltype(mN)>::type.
13081 
13082 // Although AllOf isn't defined for one argument, AllOfResult1 is defined
13083 // to simplify the implementation.
13084 template <typename M1>
13086 {
13087  typedef M1 type;
13088 };
13089 
13090 template <typename M1, typename M2>
13092 {
13093  typedef BothOfMatcher <
13094  typename AllOfResult1<M1>::type,
13095  typename AllOfResult1<M2>::type
13096  > type;
13097 };
13098 
13099 template <typename M1, typename M2, typename M3>
13101 {
13102  typedef BothOfMatcher <
13103  typename AllOfResult1<M1>::type,
13105  > type;
13106 };
13107 
13108 template <typename M1, typename M2, typename M3, typename M4>
13110 {
13111  typedef BothOfMatcher <
13112  typename AllOfResult2<M1, M2>::type,
13114  > type;
13115 };
13116 
13117 template <typename M1, typename M2, typename M3, typename M4, typename M5>
13119 {
13120  typedef BothOfMatcher <
13121  typename AllOfResult2<M1, M2>::type,
13123  > type;
13124 };
13125 
13126 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13127  typename M6>
13129 {
13130  typedef BothOfMatcher <
13133  > type;
13134 };
13135 
13136 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13137  typename M6, typename M7>
13139 {
13140  typedef BothOfMatcher <
13143  > type;
13144 };
13145 
13146 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13147  typename M6, typename M7, typename M8>
13149 {
13150  typedef BothOfMatcher <
13153  > type;
13154 };
13155 
13156 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13157  typename M6, typename M7, typename M8, typename M9>
13159 {
13160  typedef BothOfMatcher <
13163  > type;
13164 };
13165 
13166 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13167  typename M6, typename M7, typename M8, typename M9, typename M10>
13169 {
13170  typedef BothOfMatcher <
13173  > type;
13174 };
13175 
13176 // A set of metafunctions for computing the result type of AnyOf.
13177 // AnyOf(m1, ..., mN) returns
13178 // AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.
13179 
13180 // Although AnyOf isn't defined for one argument, AnyOfResult1 is defined
13181 // to simplify the implementation.
13182 template <typename M1>
13184 {
13185  typedef M1 type;
13186 };
13187 
13188 template <typename M1, typename M2>
13190 {
13191  typedef EitherOfMatcher <
13192  typename AnyOfResult1<M1>::type,
13193  typename AnyOfResult1<M2>::type
13194  > type;
13195 };
13196 
13197 template <typename M1, typename M2, typename M3>
13199 {
13200  typedef EitherOfMatcher <
13201  typename AnyOfResult1<M1>::type,
13203  > type;
13204 };
13205 
13206 template <typename M1, typename M2, typename M3, typename M4>
13208 {
13209  typedef EitherOfMatcher <
13210  typename AnyOfResult2<M1, M2>::type,
13212  > type;
13213 };
13214 
13215 template <typename M1, typename M2, typename M3, typename M4, typename M5>
13217 {
13218  typedef EitherOfMatcher <
13219  typename AnyOfResult2<M1, M2>::type,
13221  > type;
13222 };
13223 
13224 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13225  typename M6>
13227 {
13228  typedef EitherOfMatcher <
13231  > type;
13232 };
13233 
13234 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13235  typename M6, typename M7>
13237 {
13238  typedef EitherOfMatcher <
13241  > type;
13242 };
13243 
13244 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13245  typename M6, typename M7, typename M8>
13247 {
13248  typedef EitherOfMatcher <
13251  > type;
13252 };
13253 
13254 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13255  typename M6, typename M7, typename M8, typename M9>
13257 {
13258  typedef EitherOfMatcher <
13261  > type;
13262 };
13263 
13264 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13265  typename M6, typename M7, typename M8, typename M9, typename M10>
13267 {
13268  typedef EitherOfMatcher <
13271  > type;
13272 };
13273 
13274 } // namespace internal
13275 
13276 // Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
13277 // fields of it matches a_matcher. C++ doesn't support default
13278 // arguments for function templates, so we have to overload it.
13279 template <typename InnerMatcher>
13281 Args(const InnerMatcher & matcher)
13282 {
13283  return internal::ArgsMatcher<InnerMatcher>(matcher);
13284 }
13285 
13286 template <int k1, typename InnerMatcher>
13288 Args(const InnerMatcher & matcher)
13289 {
13291 }
13292 
13293 template <int k1, int k2, typename InnerMatcher>
13295 Args(const InnerMatcher & matcher)
13296 {
13298 }
13299 
13300 template <int k1, int k2, int k3, typename InnerMatcher>
13302 Args(const InnerMatcher & matcher)
13303 {
13305 }
13306 
13307 template <int k1, int k2, int k3, int k4, typename InnerMatcher>
13309 Args(const InnerMatcher & matcher)
13310 {
13312 }
13313 
13314 template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
13316 Args(const InnerMatcher & matcher)
13317 {
13319 }
13320 
13321 template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
13323 Args(const InnerMatcher & matcher)
13324 {
13326 }
13327 
13328 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
13329  typename InnerMatcher>
13331 Args(const InnerMatcher & matcher)
13332 {
13333  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
13334  k7>(matcher);
13335 }
13336 
13337 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
13338  typename InnerMatcher>
13340 Args(const InnerMatcher & matcher)
13341 {
13342  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
13343  k8>(matcher);
13344 }
13345 
13346 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
13347  int k9, typename InnerMatcher>
13349 Args(const InnerMatcher & matcher)
13350 {
13351  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
13352  k9>(matcher);
13353 }
13354 
13355 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
13356  int k9, int k10, typename InnerMatcher>
13357 inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
13358  k10>
13359  Args(const InnerMatcher & matcher)
13360 {
13361  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
13362  k9, k10>(matcher);
13363 }
13364 
13365 // ElementsAre(e_1, e_2, ... e_n) matches an STL-style container with
13366 // n elements, where the i-th element in the container must
13367 // match the i-th argument in the list. Each argument of
13368 // ElementsAre() can be either a value or a matcher. We support up to
13369 // 10 arguments.
13370 //
13371 // The use of DecayArray in the implementation allows ElementsAre()
13372 // to accept string literals, whose type is const char[N], but we
13373 // want to treat them as const char*.
13374 //
13375 // NOTE: Since ElementsAre() cares about the order of the elements, it
13376 // must not be used with containers whose elements's order is
13377 // undefined (e.g. hash_map).
13378 
13382 {
13383  typedef std::tr1::tuple<> Args;
13385 }
13386 
13387 template <typename T1>
13390 typename internal::DecayArray<T1>::type > >
13391 ElementsAre(const T1 & e1)
13392 {
13393  typedef std::tr1::tuple <
13396 }
13397 
13398 template <typename T1, typename T2>
13402  typename internal::DecayArray<T2>::type > >
13403  ElementsAre(const T1 & e1, const T2 & e2)
13404 {
13405  typedef std::tr1::tuple <
13406  typename internal::DecayArray<T1>::type,
13408  return internal::ElementsAreMatcher<Args>(Args(e1, e2));
13409 }
13410 
13411 template <typename T1, typename T2, typename T3>
13414 typename internal::DecayArray<T1>::type,
13416  typename internal::DecayArray<T3>::type > >
13417  ElementsAre(const T1 & e1, const T2 & e2, const T3 & e3)
13418 {
13419  typedef std::tr1::tuple <
13420  typename internal::DecayArray<T1>::type,
13421  typename internal::DecayArray<T2>::type,
13423  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3));
13424 }
13425 
13426 template <typename T1, typename T2, typename T3, typename T4>
13429 typename internal::DecayArray<T1>::type,
13430  typename internal::DecayArray<T2>::type,
13432  typename internal::DecayArray<T4>::type > >
13433  ElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4)
13434 {
13435  typedef std::tr1::tuple <
13436  typename internal::DecayArray<T1>::type,
13437  typename internal::DecayArray<T2>::type,
13438  typename internal::DecayArray<T3>::type,
13440  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4));
13441 }
13442 
13443 template <typename T1, typename T2, typename T3, typename T4, typename T5>
13446 typename internal::DecayArray<T1>::type,
13447  typename internal::DecayArray<T2>::type,
13448  typename internal::DecayArray<T3>::type,
13450  typename internal::DecayArray<T5>::type > >
13451  ElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4,
13452  const T5 & e5)
13453 {
13454  typedef std::tr1::tuple <
13455  typename internal::DecayArray<T1>::type,
13456  typename internal::DecayArray<T2>::type,
13457  typename internal::DecayArray<T3>::type,
13458  typename internal::DecayArray<T4>::type,
13460  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));
13461 }
13462 
13463 template <typename T1, typename T2, typename T3, typename T4, typename T5,
13464  typename T6>
13467 typename internal::DecayArray<T1>::type,
13468  typename internal::DecayArray<T2>::type,
13469  typename internal::DecayArray<T3>::type,
13470  typename internal::DecayArray<T4>::type,
13472  typename internal::DecayArray<T6>::type > >
13473  ElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4,
13474  const T5 & e5, const T6 & e6)
13475 {
13476  typedef std::tr1::tuple <
13477  typename internal::DecayArray<T1>::type,
13478  typename internal::DecayArray<T2>::type,
13479  typename internal::DecayArray<T3>::type,
13480  typename internal::DecayArray<T4>::type,
13481  typename internal::DecayArray<T5>::type,
13483  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6));
13484 }
13485 
13486 template <typename T1, typename T2, typename T3, typename T4, typename T5,
13487  typename T6, typename T7>
13490 typename internal::DecayArray<T1>::type,
13491  typename internal::DecayArray<T2>::type,
13492  typename internal::DecayArray<T3>::type,
13493  typename internal::DecayArray<T4>::type,
13494  typename internal::DecayArray<T5>::type,
13496  typename internal::DecayArray<T7>::type > >
13497  ElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4,
13498  const T5 & e5, const T6 & e6, const T7 & e7)
13499 {
13500  typedef std::tr1::tuple <
13501  typename internal::DecayArray<T1>::type,
13502  typename internal::DecayArray<T2>::type,
13503  typename internal::DecayArray<T3>::type,
13504  typename internal::DecayArray<T4>::type,
13505  typename internal::DecayArray<T5>::type,
13506  typename internal::DecayArray<T6>::type,
13508  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7));
13509 }
13510 
13511 template <typename T1, typename T2, typename T3, typename T4, typename T5,
13512  typename T6, typename T7, typename T8>
13515 typename internal::DecayArray<T1>::type,
13516  typename internal::DecayArray<T2>::type,
13517  typename internal::DecayArray<T3>::type,
13518  typename internal::DecayArray<T4>::type,
13519  typename internal::DecayArray<T5>::type,
13520  typename internal::DecayArray<T6>::type,
13522  typename internal::DecayArray<T8>::type > >
13523  ElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4,
13524  const T5 & e5, const T6 & e6, const T7 & e7, const T8 & e8)
13525 {
13526  typedef std::tr1::tuple <
13527  typename internal::DecayArray<T1>::type,
13528  typename internal::DecayArray<T2>::type,
13529  typename internal::DecayArray<T3>::type,
13530  typename internal::DecayArray<T4>::type,
13531  typename internal::DecayArray<T5>::type,
13532  typename internal::DecayArray<T6>::type,
13533  typename internal::DecayArray<T7>::type,
13535  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
13536  e8));
13537 }
13538 
13539 template <typename T1, typename T2, typename T3, typename T4, typename T5,
13540  typename T6, typename T7, typename T8, typename T9>
13543 typename internal::DecayArray<T1>::type,
13544  typename internal::DecayArray<T2>::type,
13545  typename internal::DecayArray<T3>::type,
13546  typename internal::DecayArray<T4>::type,
13547  typename internal::DecayArray<T5>::type,
13548  typename internal::DecayArray<T6>::type,
13549  typename internal::DecayArray<T7>::type,
13551  typename internal::DecayArray<T9>::type > >
13552  ElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4,
13553  const T5 & e5, const T6 & e6, const T7 & e7, const T8 & e8, const T9 & e9)
13554 {
13555  typedef std::tr1::tuple <
13556  typename internal::DecayArray<T1>::type,
13557  typename internal::DecayArray<T2>::type,
13558  typename internal::DecayArray<T3>::type,
13559  typename internal::DecayArray<T4>::type,
13560  typename internal::DecayArray<T5>::type,
13561  typename internal::DecayArray<T6>::type,
13562  typename internal::DecayArray<T7>::type,
13563  typename internal::DecayArray<T8>::type,
13565  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
13566  e8, e9));
13567 }
13568 
13569 template <typename T1, typename T2, typename T3, typename T4, typename T5,
13570  typename T6, typename T7, typename T8, typename T9, typename T10>
13573 typename internal::DecayArray<T1>::type,
13574  typename internal::DecayArray<T2>::type,
13575  typename internal::DecayArray<T3>::type,
13576  typename internal::DecayArray<T4>::type,
13577  typename internal::DecayArray<T5>::type,
13578  typename internal::DecayArray<T6>::type,
13579  typename internal::DecayArray<T7>::type,
13580  typename internal::DecayArray<T8>::type,
13582  typename internal::DecayArray<T10>::type > >
13583  ElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4,
13584  const T5 & e5, const T6 & e6, const T7 & e7, const T8 & e8, const T9 & e9,
13585  const T10 & e10)
13586 {
13587  typedef std::tr1::tuple <
13588  typename internal::DecayArray<T1>::type,
13589  typename internal::DecayArray<T2>::type,
13590  typename internal::DecayArray<T3>::type,
13591  typename internal::DecayArray<T4>::type,
13592  typename internal::DecayArray<T5>::type,
13593  typename internal::DecayArray<T6>::type,
13594  typename internal::DecayArray<T7>::type,
13595  typename internal::DecayArray<T8>::type,
13596  typename internal::DecayArray<T9>::type,
13598  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
13599  e8, e9, e10));
13600 }
13601 
13602 // UnorderedElementsAre(e_1, e_2, ..., e_n) is an ElementsAre extension
13603 // that matches n elements in any order. We support up to n=10 arguments.
13604 
13608 {
13609  typedef std::tr1::tuple<> Args;
13611 }
13612 
13613 template <typename T1>
13616 typename internal::DecayArray<T1>::type > >
13617 UnorderedElementsAre(const T1 & e1)
13618 {
13619  typedef std::tr1::tuple <
13620  typename internal::DecayArray<T1>::type > Args;
13622 }
13623 
13624 template <typename T1, typename T2>
13627 typename internal::DecayArray<T1>::type,
13628  typename internal::DecayArray<T2>::type > >
13629  UnorderedElementsAre(const T1 & e1, const T2 & e2)
13630 {
13631  typedef std::tr1::tuple <
13632  typename internal::DecayArray<T1>::type,
13633  typename internal::DecayArray<T2>::type > Args;
13635 }
13636 
13637 template <typename T1, typename T2, typename T3>
13640 typename internal::DecayArray<T1>::type,
13641  typename internal::DecayArray<T2>::type,
13642  typename internal::DecayArray<T3>::type > >
13643  UnorderedElementsAre(const T1 & e1, const T2 & e2, const T3 & e3)
13644 {
13645  typedef std::tr1::tuple <
13646  typename internal::DecayArray<T1>::type,
13647  typename internal::DecayArray<T2>::type,
13648  typename internal::DecayArray<T3>::type > Args;
13650 }
13651 
13652 template <typename T1, typename T2, typename T3, typename T4>
13655 typename internal::DecayArray<T1>::type,
13656  typename internal::DecayArray<T2>::type,
13657  typename internal::DecayArray<T3>::type,
13658  typename internal::DecayArray<T4>::type > >
13659  UnorderedElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4)
13660 {
13661  typedef std::tr1::tuple <
13662  typename internal::DecayArray<T1>::type,
13663  typename internal::DecayArray<T2>::type,
13664  typename internal::DecayArray<T3>::type,
13665  typename internal::DecayArray<T4>::type > Args;
13666  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4));
13667 }
13668 
13669 template <typename T1, typename T2, typename T3, typename T4, typename T5>
13672 typename internal::DecayArray<T1>::type,
13673  typename internal::DecayArray<T2>::type,
13674  typename internal::DecayArray<T3>::type,
13675  typename internal::DecayArray<T4>::type,
13676  typename internal::DecayArray<T5>::type > >
13677  UnorderedElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4,
13678  const T5 & e5)
13679 {
13680  typedef std::tr1::tuple <
13681  typename internal::DecayArray<T1>::type,
13682  typename internal::DecayArray<T2>::type,
13683  typename internal::DecayArray<T3>::type,
13684  typename internal::DecayArray<T4>::type,
13685  typename internal::DecayArray<T5>::type > Args;
13686  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));
13687 }
13688 
13689 template <typename T1, typename T2, typename T3, typename T4, typename T5,
13690  typename T6>
13693 typename internal::DecayArray<T1>::type,
13694  typename internal::DecayArray<T2>::type,
13695  typename internal::DecayArray<T3>::type,
13696  typename internal::DecayArray<T4>::type,
13697  typename internal::DecayArray<T5>::type,
13698  typename internal::DecayArray<T6>::type > >
13699  UnorderedElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4,
13700  const T5 & e5, const T6 & e6)
13701 {
13702  typedef std::tr1::tuple <
13703  typename internal::DecayArray<T1>::type,
13704  typename internal::DecayArray<T2>::type,
13705  typename internal::DecayArray<T3>::type,
13706  typename internal::DecayArray<T4>::type,
13707  typename internal::DecayArray<T5>::type,
13708  typename internal::DecayArray<T6>::type > Args;
13709  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
13710  e6));
13711 }
13712 
13713 template <typename T1, typename T2, typename T3, typename T4, typename T5,
13714  typename T6, typename T7>
13717 typename internal::DecayArray<T1>::type,
13718  typename internal::DecayArray<T2>::type,
13719  typename internal::DecayArray<T3>::type,
13720  typename internal::DecayArray<T4>::type,
13721  typename internal::DecayArray<T5>::type,
13722  typename internal::DecayArray<T6>::type,
13723  typename internal::DecayArray<T7>::type > >
13724  UnorderedElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4,
13725  const T5 & e5, const T6 & e6, const T7 & e7)
13726 {
13727  typedef std::tr1::tuple <
13728  typename internal::DecayArray<T1>::type,
13729  typename internal::DecayArray<T2>::type,
13730  typename internal::DecayArray<T3>::type,
13731  typename internal::DecayArray<T4>::type,
13732  typename internal::DecayArray<T5>::type,
13733  typename internal::DecayArray<T6>::type,
13734  typename internal::DecayArray<T7>::type > Args;
13735  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
13736  e6, e7));
13737 }
13738 
13739 template <typename T1, typename T2, typename T3, typename T4, typename T5,
13740  typename T6, typename T7, typename T8>
13743 typename internal::DecayArray<T1>::type,
13744  typename internal::DecayArray<T2>::type,
13745  typename internal::DecayArray<T3>::type,
13746  typename internal::DecayArray<T4>::type,
13747  typename internal::DecayArray<T5>::type,
13748  typename internal::DecayArray<T6>::type,
13749  typename internal::DecayArray<T7>::type,
13750  typename internal::DecayArray<T8>::type > >
13751  UnorderedElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4,
13752  const T5 & e5, const T6 & e6, const T7 & e7, const T8 & e8)
13753 {
13754  typedef std::tr1::tuple <
13755  typename internal::DecayArray<T1>::type,
13756  typename internal::DecayArray<T2>::type,
13757  typename internal::DecayArray<T3>::type,
13758  typename internal::DecayArray<T4>::type,
13759  typename internal::DecayArray<T5>::type,
13760  typename internal::DecayArray<T6>::type,
13761  typename internal::DecayArray<T7>::type,
13762  typename internal::DecayArray<T8>::type > Args;
13763  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
13764  e6, e7, e8));
13765 }
13766 
13767 template <typename T1, typename T2, typename T3, typename T4, typename T5,
13768  typename T6, typename T7, typename T8, typename T9>
13771 typename internal::DecayArray<T1>::type,
13772  typename internal::DecayArray<T2>::type,
13773  typename internal::DecayArray<T3>::type,
13774  typename internal::DecayArray<T4>::type,
13775  typename internal::DecayArray<T5>::type,
13776  typename internal::DecayArray<T6>::type,
13777  typename internal::DecayArray<T7>::type,
13778  typename internal::DecayArray<T8>::type,
13779  typename internal::DecayArray<T9>::type > >
13780  UnorderedElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4,
13781  const T5 & e5, const T6 & e6, const T7 & e7, const T8 & e8, const T9 & e9)
13782 {
13783  typedef std::tr1::tuple <
13784  typename internal::DecayArray<T1>::type,
13785  typename internal::DecayArray<T2>::type,
13786  typename internal::DecayArray<T3>::type,
13787  typename internal::DecayArray<T4>::type,
13788  typename internal::DecayArray<T5>::type,
13789  typename internal::DecayArray<T6>::type,
13790  typename internal::DecayArray<T7>::type,
13791  typename internal::DecayArray<T8>::type,
13792  typename internal::DecayArray<T9>::type > Args;
13793  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
13794  e6, e7, e8, e9));
13795 }
13796 
13797 template <typename T1, typename T2, typename T3, typename T4, typename T5,
13798  typename T6, typename T7, typename T8, typename T9, typename T10>
13801 typename internal::DecayArray<T1>::type,
13802  typename internal::DecayArray<T2>::type,
13803  typename internal::DecayArray<T3>::type,
13804  typename internal::DecayArray<T4>::type,
13805  typename internal::DecayArray<T5>::type,
13806  typename internal::DecayArray<T6>::type,
13807  typename internal::DecayArray<T7>::type,
13808  typename internal::DecayArray<T8>::type,
13809  typename internal::DecayArray<T9>::type,
13810  typename internal::DecayArray<T10>::type > >
13811  UnorderedElementsAre(const T1 & e1, const T2 & e2, const T3 & e3, const T4 & e4,
13812  const T5 & e5, const T6 & e6, const T7 & e7, const T8 & e8, const T9 & e9,
13813  const T10 & e10)
13814 {
13815  typedef std::tr1::tuple <
13816  typename internal::DecayArray<T1>::type,
13817  typename internal::DecayArray<T2>::type,
13818  typename internal::DecayArray<T3>::type,
13819  typename internal::DecayArray<T4>::type,
13820  typename internal::DecayArray<T5>::type,
13821  typename internal::DecayArray<T6>::type,
13822  typename internal::DecayArray<T7>::type,
13823  typename internal::DecayArray<T8>::type,
13824  typename internal::DecayArray<T9>::type,
13826  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
13827  e6, e7, e8, e9, e10));
13828 }
13829 
13830 // AllOf(m1, m2, ..., mk) matches any value that matches all of the given
13831 // sub-matchers. AllOf is called fully qualified to prevent ADL from firing.
13832 
13833 template <typename M1, typename M2>
13835 AllOf(M1 m1, M2 m2)
13836 {
13837  return typename internal::AllOfResult2<M1, M2>::type(
13838  m1,
13839  m2);
13840 }
13841 
13842 template <typename M1, typename M2, typename M3>
13844 AllOf(M1 m1, M2 m2, M3 m3)
13845 {
13847  m1,
13848  ::testing::AllOf(m2, m3));
13849 }
13850 
13851 template <typename M1, typename M2, typename M3, typename M4>
13853 AllOf(M1 m1, M2 m2, M3 m3, M4 m4)
13854 {
13856  ::testing::AllOf(m1, m2),
13857  ::testing::AllOf(m3, m4));
13858 }
13859 
13860 template <typename M1, typename M2, typename M3, typename M4, typename M5>
13862 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5)
13863 {
13865  ::testing::AllOf(m1, m2),
13866  ::testing::AllOf(m3, m4, m5));
13867 }
13868 
13869 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13870  typename M6>
13872 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6)
13873 {
13875  ::testing::AllOf(m1, m2, m3),
13876  ::testing::AllOf(m4, m5, m6));
13877 }
13878 
13879 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13880  typename M6, typename M7>
13882 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7)
13883 {
13885  ::testing::AllOf(m1, m2, m3),
13886  ::testing::AllOf(m4, m5, m6, m7));
13887 }
13888 
13889 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13890  typename M6, typename M7, typename M8>
13892 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8)
13893 {
13895  ::testing::AllOf(m1, m2, m3, m4),
13896  ::testing::AllOf(m5, m6, m7, m8));
13897 }
13898 
13899 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13900  typename M6, typename M7, typename M8, typename M9>
13902 AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9)
13903 {
13904  return typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
13905  M9>::type(
13906  ::testing::AllOf(m1, m2, m3, m4),
13907  ::testing::AllOf(m5, m6, m7, m8, m9));
13908 }
13909 
13910 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13911  typename M6, typename M7, typename M8, typename M9, typename M10>
13912 inline typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
13913  M10>::type
13914  AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10)
13915 {
13916  return typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
13917  M10>::type(
13918  ::testing::AllOf(m1, m2, m3, m4, m5),
13919  ::testing::AllOf(m6, m7, m8, m9, m10));
13920 }
13921 
13922 // AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
13923 // sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
13924 
13925 template <typename M1, typename M2>
13927 AnyOf(M1 m1, M2 m2)
13928 {
13929  return typename internal::AnyOfResult2<M1, M2>::type(
13930  m1,
13931  m2);
13932 }
13933 
13934 template <typename M1, typename M2, typename M3>
13936 AnyOf(M1 m1, M2 m2, M3 m3)
13937 {
13939  m1,
13940  ::testing::AnyOf(m2, m3));
13941 }
13942 
13943 template <typename M1, typename M2, typename M3, typename M4>
13945 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4)
13946 {
13948  ::testing::AnyOf(m1, m2),
13949  ::testing::AnyOf(m3, m4));
13950 }
13951 
13952 template <typename M1, typename M2, typename M3, typename M4, typename M5>
13954 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5)
13955 {
13957  ::testing::AnyOf(m1, m2),
13958  ::testing::AnyOf(m3, m4, m5));
13959 }
13960 
13961 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13962  typename M6>
13964 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6)
13965 {
13967  ::testing::AnyOf(m1, m2, m3),
13968  ::testing::AnyOf(m4, m5, m6));
13969 }
13970 
13971 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13972  typename M6, typename M7>
13974 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7)
13975 {
13977  ::testing::AnyOf(m1, m2, m3),
13978  ::testing::AnyOf(m4, m5, m6, m7));
13979 }
13980 
13981 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13982  typename M6, typename M7, typename M8>
13984 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8)
13985 {
13987  ::testing::AnyOf(m1, m2, m3, m4),
13988  ::testing::AnyOf(m5, m6, m7, m8));
13989 }
13990 
13991 template <typename M1, typename M2, typename M3, typename M4, typename M5,
13992  typename M6, typename M7, typename M8, typename M9>
13994 AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9)
13995 {
13996  return typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
13997  M9>::type(
13998  ::testing::AnyOf(m1, m2, m3, m4),
13999  ::testing::AnyOf(m5, m6, m7, m8, m9));
14000 }
14001 
14002 template <typename M1, typename M2, typename M3, typename M4, typename M5,
14003  typename M6, typename M7, typename M8, typename M9, typename M10>
14004 inline typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
14005  M10>::type
14006  AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10)
14007 {
14008  return typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
14009  M10>::type(
14010  ::testing::AnyOf(m1, m2, m3, m4, m5),
14011  ::testing::AnyOf(m6, m7, m8, m9, m10));
14012 }
14013 
14014 } // namespace testing
14015 
14016 
14017 // The MATCHER* family of macros can be used in a namespace scope to
14018 // define custom matchers easily.
14019 //
14020 // Basic Usage
14021 // ===========
14022 //
14023 // The syntax
14024 //
14025 // MATCHER(name, description_string) { statements; }
14026 //
14027 // defines a matcher with the given name that executes the statements,
14028 // which must return a bool to indicate if the match succeeds. Inside
14029 // the statements, you can refer to the value being matched by 'arg',
14030 // and refer to its type by 'arg_type'.
14031 //
14032 // The description string documents what the matcher does, and is used
14033 // to generate the failure message when the match fails. Since a
14034 // MATCHER() is usually defined in a header file shared by multiple
14035 // C++ source files, we require the description to be a C-string
14036 // literal to avoid possible side effects. It can be empty, in which
14037 // case we'll use the sequence of words in the matcher name as the
14038 // description.
14039 //
14040 // For example:
14041 //
14042 // MATCHER(IsEven, "") { return (arg % 2) == 0; }
14043 //
14044 // allows you to write
14045 //
14046 // // Expects mock_foo.Bar(n) to be called where n is even.
14047 // EXPECT_CALL(mock_foo, Bar(IsEven()));
14048 //
14049 // or,
14050 //
14051 // // Verifies that the value of some_expression is even.
14052 // EXPECT_THAT(some_expression, IsEven());
14053 //
14054 // If the above assertion fails, it will print something like:
14055 //
14056 // Value of: some_expression
14057 // Expected: is even
14058 // Actual: 7
14059 //
14060 // where the description "is even" is automatically calculated from the
14061 // matcher name IsEven.
14062 //
14063 // Argument Type
14064 // =============
14065 //
14066 // Note that the type of the value being matched (arg_type) is
14067 // determined by the context in which you use the matcher and is
14068 // supplied to you by the compiler, so you don't need to worry about
14069 // declaring it (nor can you). This allows the matcher to be
14070 // polymorphic. For example, IsEven() can be used to match any type
14071 // where the value of "(arg % 2) == 0" can be implicitly converted to
14072 // a bool. In the "Bar(IsEven())" example above, if method Bar()
14073 // takes an int, 'arg_type' will be int; if it takes an unsigned long,
14074 // 'arg_type' will be unsigned long; and so on.
14075 //
14076 // Parameterizing Matchers
14077 // =======================
14078 //
14079 // Sometimes you'll want to parameterize the matcher. For that you
14080 // can use another macro:
14081 //
14082 // MATCHER_P(name, param_name, description_string) { statements; }
14083 //
14084 // For example:
14085 //
14086 // MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
14087 //
14088 // will allow you to write:
14089 //
14090 // EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
14091 //
14092 // which may lead to this message (assuming n is 10):
14093 //
14094 // Value of: Blah("a")
14095 // Expected: has absolute value 10
14096 // Actual: -9
14097 //
14098 // Note that both the matcher description and its parameter are
14099 // printed, making the message human-friendly.
14100 //
14101 // In the matcher definition body, you can write 'foo_type' to
14102 // reference the type of a parameter named 'foo'. For example, in the
14103 // body of MATCHER_P(HasAbsoluteValue, value) above, you can write
14104 // 'value_type' to refer to the type of 'value'.
14105 //
14106 // We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
14107 // support multi-parameter matchers.
14108 //
14109 // Describing Parameterized Matchers
14110 // =================================
14111 //
14112 // The last argument to MATCHER*() is a string-typed expression. The
14113 // expression can reference all of the matcher's parameters and a
14114 // special bool-typed variable named 'negation'. When 'negation' is
14115 // false, the expression should evaluate to the matcher's description;
14116 // otherwise it should evaluate to the description of the negation of
14117 // the matcher. For example,
14118 //
14119 // using testing::PrintToString;
14120 //
14121 // MATCHER_P2(InClosedRange, low, hi,
14122 // string(negation ? "is not" : "is") + " in range [" +
14123 // PrintToString(low) + ", " + PrintToString(hi) + "]") {
14124 // return low <= arg && arg <= hi;
14125 // }
14126 // ...
14127 // EXPECT_THAT(3, InClosedRange(4, 6));
14128 // EXPECT_THAT(3, Not(InClosedRange(2, 4)));
14129 //
14130 // would generate two failures that contain the text:
14131 //
14132 // Expected: is in range [4, 6]
14133 // ...
14134 // Expected: is not in range [2, 4]
14135 //
14136 // If you specify "" as the description, the failure message will
14137 // contain the sequence of words in the matcher name followed by the
14138 // parameter values printed as a tuple. For example,
14139 //
14140 // MATCHER_P2(InClosedRange, low, hi, "") { ... }
14141 // ...
14142 // EXPECT_THAT(3, InClosedRange(4, 6));
14143 // EXPECT_THAT(3, Not(InClosedRange(2, 4)));
14144 //
14145 // would generate two failures that contain the text:
14146 //
14147 // Expected: in closed range (4, 6)
14148 // ...
14149 // Expected: not (in closed range (2, 4))
14150 //
14151 // Types of Matcher Parameters
14152 // ===========================
14153 //
14154 // For the purpose of typing, you can view
14155 //
14156 // MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
14157 //
14158 // as shorthand for
14159 //
14160 // template <typename p1_type, ..., typename pk_type>
14161 // FooMatcherPk<p1_type, ..., pk_type>
14162 // Foo(p1_type p1, ..., pk_type pk) { ... }
14163 //
14164 // When you write Foo(v1, ..., vk), the compiler infers the types of
14165 // the parameters v1, ..., and vk for you. If you are not happy with
14166 // the result of the type inference, you can specify the types by
14167 // explicitly instantiating the template, as in Foo<long, bool>(5,
14168 // false). As said earlier, you don't get to (or need to) specify
14169 // 'arg_type' as that's determined by the context in which the matcher
14170 // is used. You can assign the result of expression Foo(p1, ..., pk)
14171 // to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
14172 // can be useful when composing matchers.
14173 //
14174 // While you can instantiate a matcher template with reference types,
14175 // passing the parameters by pointer usually makes your code more
14176 // readable. If, however, you still want to pass a parameter by
14177 // reference, be aware that in the failure message generated by the
14178 // matcher you will see the value of the referenced object but not its
14179 // address.
14180 //
14181 // Explaining Match Results
14182 // ========================
14183 //
14184 // Sometimes the matcher description alone isn't enough to explain why
14185 // the match has failed or succeeded. For example, when expecting a
14186 // long string, it can be very helpful to also print the diff between
14187 // the expected string and the actual one. To achieve that, you can
14188 // optionally stream additional information to a special variable
14189 // named result_listener, whose type is a pointer to class
14190 // MatchResultListener:
14191 //
14192 // MATCHER_P(EqualsLongString, str, "") {
14193 // if (arg == str) return true;
14194 //
14195 // *result_listener << "the difference: "
14197 // return false;
14198 // }
14199 //
14200 // Overloading Matchers
14201 // ====================
14202 //
14203 // You can overload matchers with different numbers of parameters:
14204 //
14205 // MATCHER_P(Blah, a, description_string1) { ... }
14206 // MATCHER_P2(Blah, a, b, description_string2) { ... }
14207 //
14208 // Caveats
14209 // =======
14210 //
14211 // When defining a new matcher, you should also consider implementing
14212 // MatcherInterface or using MakePolymorphicMatcher(). These
14213 // approaches require more work than the MATCHER* macros, but also
14214 // give you more control on the types of the value being matched and
14215 // the matcher parameters, which may leads to better compiler error
14216 // messages when the matcher is used wrong. They also allow
14217 // overloading matchers based on parameter types (as opposed to just
14218 // based on the number of parameters).
14219 //
14220 // MATCHER*() can only be used in a namespace scope. The reason is
14221 // that C++ doesn't yet allow function-local types to be used to
14222 // instantiate templates. The up-coming C++0x standard will fix this.
14223 // Once that's done, we'll consider supporting using MATCHER*() inside
14224 // a function.
14225 //
14226 // More Information
14227 // ================
14228 //
14229 // To learn more about using these macros, please search for 'MATCHER'
14230 // on http://code.google.com/p/googlemock/wiki/CookBook.
14231 
14232 #define MATCHER(name, description)\
14233  class name##Matcher {\
14234  public:\
14235  template <typename arg_type>\
14236  class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
14237  public:\
14238  gmock_Impl()\
14239  {}\
14240  virtual bool MatchAndExplain(\
14241  arg_type arg, ::testing::MatchResultListener* result_listener) const;\
14242  virtual void DescribeTo(::std::ostream* gmock_os) const {\
14243  *gmock_os << FormatDescription(false);\
14244  }\
14245  virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
14246  *gmock_os << FormatDescription(true);\
14247  }\
14248  private:\
14249  ::testing::internal::string FormatDescription(bool negation) const {\
14250  const ::testing::internal::string gmock_description = (description);\
14251  if (!gmock_description.empty())\
14252  return gmock_description;\
14253  return ::testing::internal::FormatMatcherDescription(\
14254  negation, #name, \
14255  ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
14256  ::std::tr1::tuple<>()));\
14257  }\
14258  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
14259  };\
14260  template <typename arg_type>\
14261  operator ::testing::Matcher<arg_type>() const {\
14262  return ::testing::Matcher<arg_type>(\
14263  new gmock_Impl<arg_type>());\
14264  }\
14265  name##Matcher() {\
14266  }\
14267  private:\
14268  GTEST_DISALLOW_ASSIGN_(name##Matcher);\
14269  };\
14270  inline name##Matcher name() {\
14271  return name##Matcher();\
14272  }\
14273  template <typename arg_type>\
14274  bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
14275  arg_type arg, \
14276  ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
14277  const
14278 
14279 #define MATCHER_P(name, p0, description)\
14280  template <typename p0##_type>\
14281  class name##MatcherP {\
14282  public:\
14283  template <typename arg_type>\
14284  class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
14285  public:\
14286  explicit gmock_Impl(p0##_type gmock_p0)\
14287  : p0(gmock_p0) {}\
14288  virtual bool MatchAndExplain(\
14289  arg_type arg, ::testing::MatchResultListener* result_listener) const;\
14290  virtual void DescribeTo(::std::ostream* gmock_os) const {\
14291  *gmock_os << FormatDescription(false);\
14292  }\
14293  virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
14294  *gmock_os << FormatDescription(true);\
14295  }\
14296  p0##_type p0;\
14297  private:\
14298  ::testing::internal::string FormatDescription(bool negation) const {\
14299  const ::testing::internal::string gmock_description = (description);\
14300  if (!gmock_description.empty())\
14301  return gmock_description;\
14302  return ::testing::internal::FormatMatcherDescription(\
14303  negation, #name, \
14304  ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
14305  ::std::tr1::tuple<p0##_type>(p0)));\
14306  }\
14307  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
14308  };\
14309  template <typename arg_type>\
14310  operator ::testing::Matcher<arg_type>() const {\
14311  return ::testing::Matcher<arg_type>(\
14312  new gmock_Impl<arg_type>(p0));\
14313  }\
14314  name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
14315  }\
14316  p0##_type p0;\
14317  private:\
14318  GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
14319  };\
14320  template <typename p0##_type>\
14321  inline name##MatcherP<p0##_type> name(p0##_type p0) {\
14322  return name##MatcherP<p0##_type>(p0);\
14323  }\
14324  template <typename p0##_type>\
14325  template <typename arg_type>\
14326  bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
14327  arg_type arg, \
14328  ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
14329  const
14330 
14331 #define MATCHER_P2(name, p0, p1, description)\
14332  template <typename p0##_type, typename p1##_type>\
14333  class name##MatcherP2 {\
14334  public:\
14335  template <typename arg_type>\
14336  class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
14337  public:\
14338  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
14339  : p0(gmock_p0), p1(gmock_p1) {}\
14340  virtual bool MatchAndExplain(\
14341  arg_type arg, ::testing::MatchResultListener* result_listener) const;\
14342  virtual void DescribeTo(::std::ostream* gmock_os) const {\
14343  *gmock_os << FormatDescription(false);\
14344  }\
14345  virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
14346  *gmock_os << FormatDescription(true);\
14347  }\
14348  p0##_type p0;\
14349  p1##_type p1;\
14350  private:\
14351  ::testing::internal::string FormatDescription(bool negation) const {\
14352  const ::testing::internal::string gmock_description = (description);\
14353  if (!gmock_description.empty())\
14354  return gmock_description;\
14355  return ::testing::internal::FormatMatcherDescription(\
14356  negation, #name, \
14357  ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
14358  ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\
14359  }\
14360  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
14361  };\
14362  template <typename arg_type>\
14363  operator ::testing::Matcher<arg_type>() const {\
14364  return ::testing::Matcher<arg_type>(\
14365  new gmock_Impl<arg_type>(p0, p1));\
14366  }\
14367  name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
14368  p1(gmock_p1) {\
14369  }\
14370  p0##_type p0;\
14371  p1##_type p1;\
14372  private:\
14373  GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
14374  };\
14375  template <typename p0##_type, typename p1##_type>\
14376  inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
14377  p1##_type p1) {\
14378  return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
14379  }\
14380  template <typename p0##_type, typename p1##_type>\
14381  template <typename arg_type>\
14382  bool name##MatcherP2<p0##_type, \
14383  p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
14384  arg_type arg, \
14385  ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
14386  const
14387 
14388 #define MATCHER_P3(name, p0, p1, p2, description)\
14389  template <typename p0##_type, typename p1##_type, typename p2##_type>\
14390  class name##MatcherP3 {\
14391  public:\
14392  template <typename arg_type>\
14393  class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
14394  public:\
14395  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
14396  : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
14397  virtual bool MatchAndExplain(\
14398  arg_type arg, ::testing::MatchResultListener* result_listener) const;\
14399  virtual void DescribeTo(::std::ostream* gmock_os) const {\
14400  *gmock_os << FormatDescription(false);\
14401  }\
14402  virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
14403  *gmock_os << FormatDescription(true);\
14404  }\
14405  p0##_type p0;\
14406  p1##_type p1;\
14407  p2##_type p2;\
14408  private:\
14409  ::testing::internal::string FormatDescription(bool negation) const {\
14410  const ::testing::internal::string gmock_description = (description);\
14411  if (!gmock_description.empty())\
14412  return gmock_description;\
14413  return ::testing::internal::FormatMatcherDescription(\
14414  negation, #name, \
14415  ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
14416  ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
14417  p2)));\
14418  }\
14419  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
14420  };\
14421  template <typename arg_type>\
14422  operator ::testing::Matcher<arg_type>() const {\
14423  return ::testing::Matcher<arg_type>(\
14424  new gmock_Impl<arg_type>(p0, p1, p2));\
14425  }\
14426  name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
14427  p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
14428  }\
14429  p0##_type p0;\
14430  p1##_type p1;\
14431  p2##_type p2;\
14432  private:\
14433  GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
14434  };\
14435  template <typename p0##_type, typename p1##_type, typename p2##_type>\
14436  inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
14437  p1##_type p1, p2##_type p2) {\
14438  return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
14439  }\
14440  template <typename p0##_type, typename p1##_type, typename p2##_type>\
14441  template <typename arg_type>\
14442  bool name##MatcherP3<p0##_type, p1##_type, \
14443  p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
14444  arg_type arg, \
14445  ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
14446  const
14447 
14448 #define MATCHER_P4(name, p0, p1, p2, p3, description)\
14449  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14450  typename p3##_type>\
14451  class name##MatcherP4 {\
14452  public:\
14453  template <typename arg_type>\
14454  class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
14455  public:\
14456  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
14457  p3##_type gmock_p3)\
14458  : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\
14459  virtual bool MatchAndExplain(\
14460  arg_type arg, ::testing::MatchResultListener* result_listener) const;\
14461  virtual void DescribeTo(::std::ostream* gmock_os) const {\
14462  *gmock_os << FormatDescription(false);\
14463  }\
14464  virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
14465  *gmock_os << FormatDescription(true);\
14466  }\
14467  p0##_type p0;\
14468  p1##_type p1;\
14469  p2##_type p2;\
14470  p3##_type p3;\
14471  private:\
14472  ::testing::internal::string FormatDescription(bool negation) const {\
14473  const ::testing::internal::string gmock_description = (description);\
14474  if (!gmock_description.empty())\
14475  return gmock_description;\
14476  return ::testing::internal::FormatMatcherDescription(\
14477  negation, #name, \
14478  ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
14479  ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
14480  p3##_type>(p0, p1, p2, p3)));\
14481  }\
14482  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
14483  };\
14484  template <typename arg_type>\
14485  operator ::testing::Matcher<arg_type>() const {\
14486  return ::testing::Matcher<arg_type>(\
14487  new gmock_Impl<arg_type>(p0, p1, p2, p3));\
14488  }\
14489  name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
14490  p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
14491  p2(gmock_p2), p3(gmock_p3) {\
14492  }\
14493  p0##_type p0;\
14494  p1##_type p1;\
14495  p2##_type p2;\
14496  p3##_type p3;\
14497  private:\
14498  GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
14499  };\
14500  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14501  typename p3##_type>\
14502  inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
14503  p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
14504  p3##_type p3) {\
14505  return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
14506  p1, p2, p3);\
14507  }\
14508  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14509  typename p3##_type>\
14510  template <typename arg_type>\
14511  bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
14512  p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
14513  arg_type arg, \
14514  ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
14515  const
14516 
14517 #define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
14518  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14519  typename p3##_type, typename p4##_type>\
14520  class name##MatcherP5 {\
14521  public:\
14522  template <typename arg_type>\
14523  class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
14524  public:\
14525  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
14526  p3##_type gmock_p3, p4##_type gmock_p4)\
14527  : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
14528  p4(gmock_p4) {}\
14529  virtual bool MatchAndExplain(\
14530  arg_type arg, ::testing::MatchResultListener* result_listener) const;\
14531  virtual void DescribeTo(::std::ostream* gmock_os) const {\
14532  *gmock_os << FormatDescription(false);\
14533  }\
14534  virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
14535  *gmock_os << FormatDescription(true);\
14536  }\
14537  p0##_type p0;\
14538  p1##_type p1;\
14539  p2##_type p2;\
14540  p3##_type p3;\
14541  p4##_type p4;\
14542  private:\
14543  ::testing::internal::string FormatDescription(bool negation) const {\
14544  const ::testing::internal::string gmock_description = (description);\
14545  if (!gmock_description.empty())\
14546  return gmock_description;\
14547  return ::testing::internal::FormatMatcherDescription(\
14548  negation, #name, \
14549  ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
14550  ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
14551  p4##_type>(p0, p1, p2, p3, p4)));\
14552  }\
14553  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
14554  };\
14555  template <typename arg_type>\
14556  operator ::testing::Matcher<arg_type>() const {\
14557  return ::testing::Matcher<arg_type>(\
14558  new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\
14559  }\
14560  name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
14561  p2##_type gmock_p2, p3##_type gmock_p3, \
14562  p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
14563  p3(gmock_p3), p4(gmock_p4) {\
14564  }\
14565  p0##_type p0;\
14566  p1##_type p1;\
14567  p2##_type p2;\
14568  p3##_type p3;\
14569  p4##_type p4;\
14570  private:\
14571  GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
14572  };\
14573  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14574  typename p3##_type, typename p4##_type>\
14575  inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
14576  p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
14577  p4##_type p4) {\
14578  return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
14579  p4##_type>(p0, p1, p2, p3, p4);\
14580  }\
14581  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14582  typename p3##_type, typename p4##_type>\
14583  template <typename arg_type>\
14584  bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
14585  p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
14586  arg_type arg, \
14587  ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
14588  const
14589 
14590 #define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
14591  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14592  typename p3##_type, typename p4##_type, typename p5##_type>\
14593  class name##MatcherP6 {\
14594  public:\
14595  template <typename arg_type>\
14596  class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
14597  public:\
14598  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
14599  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
14600  : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
14601  p4(gmock_p4), p5(gmock_p5) {}\
14602  virtual bool MatchAndExplain(\
14603  arg_type arg, ::testing::MatchResultListener* result_listener) const;\
14604  virtual void DescribeTo(::std::ostream* gmock_os) const {\
14605  *gmock_os << FormatDescription(false);\
14606  }\
14607  virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
14608  *gmock_os << FormatDescription(true);\
14609  }\
14610  p0##_type p0;\
14611  p1##_type p1;\
14612  p2##_type p2;\
14613  p3##_type p3;\
14614  p4##_type p4;\
14615  p5##_type p5;\
14616  private:\
14617  ::testing::internal::string FormatDescription(bool negation) const {\
14618  const ::testing::internal::string gmock_description = (description);\
14619  if (!gmock_description.empty())\
14620  return gmock_description;\
14621  return ::testing::internal::FormatMatcherDescription(\
14622  negation, #name, \
14623  ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
14624  ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
14625  p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
14626  }\
14627  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
14628  };\
14629  template <typename arg_type>\
14630  operator ::testing::Matcher<arg_type>() const {\
14631  return ::testing::Matcher<arg_type>(\
14632  new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\
14633  }\
14634  name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
14635  p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
14636  p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
14637  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
14638  }\
14639  p0##_type p0;\
14640  p1##_type p1;\
14641  p2##_type p2;\
14642  p3##_type p3;\
14643  p4##_type p4;\
14644  p5##_type p5;\
14645  private:\
14646  GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
14647  };\
14648  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14649  typename p3##_type, typename p4##_type, typename p5##_type>\
14650  inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
14651  p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
14652  p3##_type p3, p4##_type p4, p5##_type p5) {\
14653  return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
14654  p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
14655  }\
14656  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14657  typename p3##_type, typename p4##_type, typename p5##_type>\
14658  template <typename arg_type>\
14659  bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
14660  p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
14661  arg_type arg, \
14662  ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
14663  const
14664 
14665 #define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
14666  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14667  typename p3##_type, typename p4##_type, typename p5##_type, \
14668  typename p6##_type>\
14669  class name##MatcherP7 {\
14670  public:\
14671  template <typename arg_type>\
14672  class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
14673  public:\
14674  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
14675  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
14676  p6##_type gmock_p6)\
14677  : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
14678  p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
14679  virtual bool MatchAndExplain(\
14680  arg_type arg, ::testing::MatchResultListener* result_listener) const;\
14681  virtual void DescribeTo(::std::ostream* gmock_os) const {\
14682  *gmock_os << FormatDescription(false);\
14683  }\
14684  virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
14685  *gmock_os << FormatDescription(true);\
14686  }\
14687  p0##_type p0;\
14688  p1##_type p1;\
14689  p2##_type p2;\
14690  p3##_type p3;\
14691  p4##_type p4;\
14692  p5##_type p5;\
14693  p6##_type p6;\
14694  private:\
14695  ::testing::internal::string FormatDescription(bool negation) const {\
14696  const ::testing::internal::string gmock_description = (description);\
14697  if (!gmock_description.empty())\
14698  return gmock_description;\
14699  return ::testing::internal::FormatMatcherDescription(\
14700  negation, #name, \
14701  ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
14702  ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
14703  p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
14704  p6)));\
14705  }\
14706  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
14707  };\
14708  template <typename arg_type>\
14709  operator ::testing::Matcher<arg_type>() const {\
14710  return ::testing::Matcher<arg_type>(\
14711  new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\
14712  }\
14713  name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
14714  p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
14715  p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
14716  p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
14717  p6(gmock_p6) {\
14718  }\
14719  p0##_type p0;\
14720  p1##_type p1;\
14721  p2##_type p2;\
14722  p3##_type p3;\
14723  p4##_type p4;\
14724  p5##_type p5;\
14725  p6##_type p6;\
14726  private:\
14727  GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
14728  };\
14729  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14730  typename p3##_type, typename p4##_type, typename p5##_type, \
14731  typename p6##_type>\
14732  inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
14733  p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
14734  p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
14735  p6##_type p6) {\
14736  return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
14737  p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
14738  }\
14739  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14740  typename p3##_type, typename p4##_type, typename p5##_type, \
14741  typename p6##_type>\
14742  template <typename arg_type>\
14743  bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
14744  p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
14745  arg_type arg, \
14746  ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
14747  const
14748 
14749 #define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
14750  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14751  typename p3##_type, typename p4##_type, typename p5##_type, \
14752  typename p6##_type, typename p7##_type>\
14753  class name##MatcherP8 {\
14754  public:\
14755  template <typename arg_type>\
14756  class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
14757  public:\
14758  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
14759  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
14760  p6##_type gmock_p6, p7##_type gmock_p7)\
14761  : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
14762  p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
14763  virtual bool MatchAndExplain(\
14764  arg_type arg, ::testing::MatchResultListener* result_listener) const;\
14765  virtual void DescribeTo(::std::ostream* gmock_os) const {\
14766  *gmock_os << FormatDescription(false);\
14767  }\
14768  virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
14769  *gmock_os << FormatDescription(true);\
14770  }\
14771  p0##_type p0;\
14772  p1##_type p1;\
14773  p2##_type p2;\
14774  p3##_type p3;\
14775  p4##_type p4;\
14776  p5##_type p5;\
14777  p6##_type p6;\
14778  p7##_type p7;\
14779  private:\
14780  ::testing::internal::string FormatDescription(bool negation) const {\
14781  const ::testing::internal::string gmock_description = (description);\
14782  if (!gmock_description.empty())\
14783  return gmock_description;\
14784  return ::testing::internal::FormatMatcherDescription(\
14785  negation, #name, \
14786  ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
14787  ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
14788  p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
14789  p3, p4, p5, p6, p7)));\
14790  }\
14791  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
14792  };\
14793  template <typename arg_type>\
14794  operator ::testing::Matcher<arg_type>() const {\
14795  return ::testing::Matcher<arg_type>(\
14796  new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\
14797  }\
14798  name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
14799  p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
14800  p5##_type gmock_p5, p6##_type gmock_p6, \
14801  p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
14802  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
14803  p7(gmock_p7) {\
14804  }\
14805  p0##_type p0;\
14806  p1##_type p1;\
14807  p2##_type p2;\
14808  p3##_type p3;\
14809  p4##_type p4;\
14810  p5##_type p5;\
14811  p6##_type p6;\
14812  p7##_type p7;\
14813  private:\
14814  GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
14815  };\
14816  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14817  typename p3##_type, typename p4##_type, typename p5##_type, \
14818  typename p6##_type, typename p7##_type>\
14819  inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
14820  p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
14821  p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
14822  p6##_type p6, p7##_type p7) {\
14823  return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
14824  p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
14825  p6, p7);\
14826  }\
14827  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14828  typename p3##_type, typename p4##_type, typename p5##_type, \
14829  typename p6##_type, typename p7##_type>\
14830  template <typename arg_type>\
14831  bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
14832  p5##_type, p6##_type, \
14833  p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
14834  arg_type arg, \
14835  ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
14836  const
14837 
14838 #define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
14839  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14840  typename p3##_type, typename p4##_type, typename p5##_type, \
14841  typename p6##_type, typename p7##_type, typename p8##_type>\
14842  class name##MatcherP9 {\
14843  public:\
14844  template <typename arg_type>\
14845  class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
14846  public:\
14847  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
14848  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
14849  p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
14850  : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
14851  p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
14852  p8(gmock_p8) {}\
14853  virtual bool MatchAndExplain(\
14854  arg_type arg, ::testing::MatchResultListener* result_listener) const;\
14855  virtual void DescribeTo(::std::ostream* gmock_os) const {\
14856  *gmock_os << FormatDescription(false);\
14857  }\
14858  virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
14859  *gmock_os << FormatDescription(true);\
14860  }\
14861  p0##_type p0;\
14862  p1##_type p1;\
14863  p2##_type p2;\
14864  p3##_type p3;\
14865  p4##_type p4;\
14866  p5##_type p5;\
14867  p6##_type p6;\
14868  p7##_type p7;\
14869  p8##_type p8;\
14870  private:\
14871  ::testing::internal::string FormatDescription(bool negation) const {\
14872  const ::testing::internal::string gmock_description = (description);\
14873  if (!gmock_description.empty())\
14874  return gmock_description;\
14875  return ::testing::internal::FormatMatcherDescription(\
14876  negation, #name, \
14877  ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
14878  ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
14879  p4##_type, p5##_type, p6##_type, p7##_type, \
14880  p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
14881  }\
14882  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
14883  };\
14884  template <typename arg_type>\
14885  operator ::testing::Matcher<arg_type>() const {\
14886  return ::testing::Matcher<arg_type>(\
14887  new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
14888  }\
14889  name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
14890  p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
14891  p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
14892  p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
14893  p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
14894  p8(gmock_p8) {\
14895  }\
14896  p0##_type p0;\
14897  p1##_type p1;\
14898  p2##_type p2;\
14899  p3##_type p3;\
14900  p4##_type p4;\
14901  p5##_type p5;\
14902  p6##_type p6;\
14903  p7##_type p7;\
14904  p8##_type p8;\
14905  private:\
14906  GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
14907  };\
14908  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14909  typename p3##_type, typename p4##_type, typename p5##_type, \
14910  typename p6##_type, typename p7##_type, typename p8##_type>\
14911  inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
14912  p4##_type, p5##_type, p6##_type, p7##_type, \
14913  p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
14914  p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
14915  p8##_type p8) {\
14916  return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
14917  p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
14918  p3, p4, p5, p6, p7, p8);\
14919  }\
14920  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14921  typename p3##_type, typename p4##_type, typename p5##_type, \
14922  typename p6##_type, typename p7##_type, typename p8##_type>\
14923  template <typename arg_type>\
14924  bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
14925  p5##_type, p6##_type, p7##_type, \
14926  p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
14927  arg_type arg, \
14928  ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
14929  const
14930 
14931 #define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
14932  template <typename p0##_type, typename p1##_type, typename p2##_type, \
14933  typename p3##_type, typename p4##_type, typename p5##_type, \
14934  typename p6##_type, typename p7##_type, typename p8##_type, \
14935  typename p9##_type>\
14936  class name##MatcherP10 {\
14937  public:\
14938  template <typename arg_type>\
14939  class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
14940  public:\
14941  gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
14942  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
14943  p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
14944  p9##_type gmock_p9)\
14945  : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
14946  p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
14947  p8(gmock_p8), p9(gmock_p9) {}\
14948  virtual bool MatchAndExplain(\
14949  arg_type arg, ::testing::MatchResultListener* result_listener) const;\
14950  virtual void DescribeTo(::std::ostream* gmock_os) const {\
14951  *gmock_os << FormatDescription(false);\
14952  }\
14953  virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
14954  *gmock_os << FormatDescription(true);\
14955  }\
14956  p0##_type p0;\
14957  p1##_type p1;\
14958  p2##_type p2;\
14959  p3##_type p3;\
14960  p4##_type p4;\
14961  p5##_type p5;\
14962  p6##_type p6;\
14963  p7##_type p7;\
14964  p8##_type p8;\
14965  p9##_type p9;\
14966  private:\
14967  ::testing::internal::string FormatDescription(bool negation) const {\
14968  const ::testing::internal::string gmock_description = (description);\
14969  if (!gmock_description.empty())\
14970  return gmock_description;\
14971  return ::testing::internal::FormatMatcherDescription(\
14972  negation, #name, \
14973  ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
14974  ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
14975  p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
14976  p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
14977  }\
14978  GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
14979  };\
14980  template <typename arg_type>\
14981  operator ::testing::Matcher<arg_type>() const {\
14982  return ::testing::Matcher<arg_type>(\
14983  new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
14984  }\
14985  name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
14986  p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
14987  p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
14988  p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
14989  p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
14990  p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
14991  }\
14992  p0##_type p0;\
14993  p1##_type p1;\
14994  p2##_type p2;\
14995  p3##_type p3;\
14996  p4##_type p4;\
14997  p5##_type p5;\
14998  p6##_type p6;\
14999  p7##_type p7;\
15000  p8##_type p8;\
15001  p9##_type p9;\
15002  private:\
15003  GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
15004  };\
15005  template <typename p0##_type, typename p1##_type, typename p2##_type, \
15006  typename p3##_type, typename p4##_type, typename p5##_type, \
15007  typename p6##_type, typename p7##_type, typename p8##_type, \
15008  typename p9##_type>\
15009  inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
15010  p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
15011  p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
15012  p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
15013  p9##_type p9) {\
15014  return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
15015  p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
15016  p1, p2, p3, p4, p5, p6, p7, p8, p9);\
15017  }\
15018  template <typename p0##_type, typename p1##_type, typename p2##_type, \
15019  typename p3##_type, typename p4##_type, typename p5##_type, \
15020  typename p6##_type, typename p7##_type, typename p8##_type, \
15021  typename p9##_type>\
15022  template <typename arg_type>\
15023  bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
15024  p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
15025  p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
15026  arg_type arg, \
15027  ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
15028  const
15029 
15030 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
15031 // Copyright 2007, Google Inc.
15032 // All rights reserved.
15033 //
15034 // Redistribution and use in source and binary forms, with or without
15035 // modification, are permitted provided that the following conditions are
15036 // met:
15037 //
15038 // * Redistributions of source code must retain the above copyright
15039 // notice, this list of conditions and the following disclaimer.
15040 // * Redistributions in binary form must reproduce the above
15041 // copyright notice, this list of conditions and the following disclaimer
15042 // in the documentation and/or other materials provided with the
15043 // distribution.
15044 // * Neither the name of Google Inc. nor the names of its
15045 // contributors may be used to endorse or promote products derived from
15046 // this software without specific prior written permission.
15047 //
15048 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15049 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15050 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15051 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
15052 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15053 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
15054 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
15055 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
15056 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15057 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15058 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15059 //
15060 // Author: wan@google.com (Zhanyong Wan)
15061 
15062 // Google Mock - a framework for writing C++ mock classes.
15063 //
15064 // This file implements some actions that depend on gmock-generated-actions.h.
15065 
15066 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
15067 #define GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
15068 
15069 #include <algorithm>
15070 
15071 
15072 namespace testing
15073 {
15074 namespace internal
15075 {
15076 
15077 // Implements the Invoke(f) action. The template argument
15078 // FunctionImpl is the implementation type of f, which can be either a
15079 // function pointer or a functor. Invoke(f) can be used as an
15080 // Action<F> as long as f's type is compatible with F (i.e. f can be
15081 // assigned to a tr1::function<F>).
15082 template <typename FunctionImpl>
15084 {
15085 public:
15086  // The c'tor makes a copy of function_impl (either a function
15087  // pointer or a functor).
15088  explicit InvokeAction(FunctionImpl function_impl)
15089  : function_impl_(function_impl) {}
15090 
15091  template <typename Result, typename ArgumentTuple>
15092  Result Perform(const ArgumentTuple & args)
15093  {
15094  return InvokeHelper<Result, ArgumentTuple>::Invoke(function_impl_, args);
15095  }
15096 
15097 private:
15098  FunctionImpl function_impl_;
15099 
15101 };
15102 
15103 // Implements the Invoke(object_ptr, &Class::Method) action.
15104 template <class Class, typename MethodPtr>
15106 {
15107 public:
15108  InvokeMethodAction(Class * obj_ptr, MethodPtr method_ptr)
15109  : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}
15110 
15111  template <typename Result, typename ArgumentTuple>
15112  Result Perform(const ArgumentTuple & args) const
15113  {
15115  obj_ptr_, method_ptr_, args);
15116  }
15117 
15118 private:
15119  Class * const obj_ptr_;
15120  const MethodPtr method_ptr_;
15121 
15123 };
15124 
15125 } // namespace internal
15126 
15127 // Various overloads for Invoke().
15128 
15129 // Creates an action that invokes 'function_impl' with the mock
15130 // function's arguments.
15131 template <typename FunctionImpl>
15133  FunctionImpl function_impl)
15134 {
15135  return MakePolymorphicAction(
15136  internal::InvokeAction<FunctionImpl>(function_impl));
15137 }
15138 
15139 // Creates an action that invokes the given method on the given object
15140 // with the mock function's arguments.
15141 template <class Class, typename MethodPtr>
15143  Class * obj_ptr, MethodPtr method_ptr)
15144 {
15145  return MakePolymorphicAction(
15146  internal::InvokeMethodAction<Class, MethodPtr>(obj_ptr, method_ptr));
15147 }
15148 
15149 // WithoutArgs(inner_action) can be used in a mock function with a
15150 // non-empty argument list to perform inner_action, which takes no
15151 // argument. In other words, it adapts an action accepting no
15152 // argument to one that accepts (and ignores) arguments.
15153 template <typename InnerAction>
15155 WithoutArgs(const InnerAction & action)
15156 {
15158 }
15159 
15160 // WithArg<k>(an_action) creates an action that passes the k-th
15161 // (0-based) argument of the mock function to an_action and performs
15162 // it. It adapts an action accepting one argument to one that accepts
15163 // multiple arguments. For convenience, we also provide
15164 // WithArgs<k>(an_action) (defined below) as a synonym.
15165 template <int k, typename InnerAction>
15167 WithArg(const InnerAction & action)
15168 {
15170 }
15171 
15172 // The ACTION*() macros trigger warning C4100 (unreferenced formal
15173 // parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
15174 // the macro definition, as the warnings are generated when the macro
15175 // is expanded and macro expansion cannot contain #pragma. Therefore
15176 // we suppress them here.
15177 #ifdef _MSC_VER
15178 # pragma warning(push)
15179 # pragma warning(disable:4100)
15180 #endif
15181 
15182 // Action ReturnArg<k>() returns the k-th argument of the mock function.
15184  HAS_1_TEMPLATE_PARAMS(int, k),
15185  AND_0_VALUE_PARAMS())
15186 {
15187  return std::tr1::get<k>(args);
15188 }
15189 
15190 // Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the
15191 // mock function to *pointer.
15193  HAS_1_TEMPLATE_PARAMS(int, k),
15194  AND_1_VALUE_PARAMS(pointer))
15195 {
15196  *pointer = ::std::tr1::get<k>(args);
15197 }
15198 
15199 // Action SaveArgPointee<k>(pointer) saves the value pointed to
15200 // by the k-th (0-based) argument of the mock function to *pointer.
15201 ACTION_TEMPLATE(SaveArgPointee,
15202  HAS_1_TEMPLATE_PARAMS(int, k),
15203  AND_1_VALUE_PARAMS(pointer))
15204 {
15205  *pointer = *::std::tr1::get<k>(args);
15206 }
15207 
15208 // Action SetArgReferee<k>(value) assigns 'value' to the variable
15209 // referenced by the k-th (0-based) argument of the mock function.
15210 ACTION_TEMPLATE(SetArgReferee,
15211  HAS_1_TEMPLATE_PARAMS(int, k),
15212  AND_1_VALUE_PARAMS(value))
15213 {
15214  typedef typename ::std::tr1::tuple_element<k, args_type>::type argk_type;
15215  // Ensures that argument #k is a reference. If you get a compiler
15216  // error on the next line, you are using SetArgReferee<k>(value) in
15217  // a mock function whose k-th (0-based) argument is not a reference.
15219  SetArgReferee_must_be_used_with_a_reference_argument);
15220  ::std::tr1::get<k>(args) = value;
15221 }
15222 
15223 // Action SetArrayArgument<k>(first, last) copies the elements in
15224 // source range [first, last) to the array pointed to by the k-th
15225 // (0-based) argument, which can be either a pointer or an
15226 // iterator. The action does not take ownership of the elements in the
15227 // source range.
15228 ACTION_TEMPLATE(SetArrayArgument,
15229  HAS_1_TEMPLATE_PARAMS(int, k),
15230  AND_2_VALUE_PARAMS(first, last))
15231 {
15232  // Microsoft compiler deprecates ::std::copy, so we want to suppress warning
15233  // 4996 (Function call with parameters that may be unsafe) there.
15234 #ifdef _MSC_VER
15235 # pragma warning(push) // Saves the current warning state.
15236 # pragma warning(disable:4996) // Temporarily disables warning 4996.
15237 #endif
15238  ::std::copy(first, last, ::std::tr1::get<k>(args));
15239 #ifdef _MSC_VER
15240 # pragma warning(pop) // Restores the warning state.
15241 #endif
15242 }
15243 
15244 // Action DeleteArg<k>() deletes the k-th (0-based) argument of the mock
15245 // function.
15247  HAS_1_TEMPLATE_PARAMS(int, k),
15248  AND_0_VALUE_PARAMS())
15249 {
15250  delete ::std::tr1::get<k>(args);
15251 }
15252 
15253 // This action returns the value pointed to by 'pointer'.
15254 ACTION_P(ReturnPointee, pointer) { return *pointer; }
15255 
15256 // Action Throw(exception) can be used in a mock function of any type
15257 // to throw the given exception. Any copyable value can be thrown.
15258 #if GTEST_HAS_EXCEPTIONS
15259 
15260 // Suppresses the 'unreachable code' warning that VC generates in opt modes.
15261 # ifdef _MSC_VER
15262 # pragma warning(push) // Saves the current warning state.
15263 # pragma warning(disable:4702) // Temporarily disables warning 4702.
15264 # endif
15265 ACTION_P(Throw, exception) { throw exception; }
15266 # ifdef _MSC_VER
15267 # pragma warning(pop) // Restores the warning state.
15268 # endif
15269 
15270 #endif // GTEST_HAS_EXCEPTIONS
15271 
15272 #ifdef _MSC_VER
15273 # pragma warning(pop)
15274 #endif
15275 
15276 } // namespace testing
15277 
15278 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
15279 // Copyright 2013, Google Inc.
15280 // All rights reserved.
15281 //
15282 // Redistribution and use in source and binary forms, with or without
15283 // modification, are permitted provided that the following conditions are
15284 // met:
15285 //
15286 // * Redistributions of source code must retain the above copyright
15287 // notice, this list of conditions and the following disclaimer.
15288 // * Redistributions in binary form must reproduce the above
15289 // copyright notice, this list of conditions and the following disclaimer
15290 // in the documentation and/or other materials provided with the
15291 // distribution.
15292 // * Neither the name of Google Inc. nor the names of its
15293 // contributors may be used to endorse or promote products derived from
15294 // this software without specific prior written permission.
15295 //
15296 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15297 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15298 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15299 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
15300 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15301 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
15302 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
15303 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
15304 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15305 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15306 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15307 //
15308 // Author: marcus.boerger@google.com (Marcus Boerger)
15309 
15310 // Google Mock - a framework for writing C++ mock classes.
15311 //
15312 // This file implements some matchers that depend on gmock-generated-matchers.h.
15313 //
15314 // Note that tests are implemented in gmock-matchers_test.cc rather than
15315 // gmock-more-matchers-test.cc.
15316 
15317 #ifndef GMOCK_GMOCK_MORE_MATCHERS_H_
15318 #define GMOCK_GMOCK_MORE_MATCHERS_H_
15319 
15320 
15321 namespace testing
15322 {
15323 
15324 // Defines a matcher that matches an empty container. The container must
15325 // support both size() and empty(), which all STL-like containers provide.
15326 MATCHER(IsEmpty, negation ? "isn't empty" : "is empty")
15327 {
15328  if (arg.empty())
15329  {
15330  return true;
15331  }
15332 
15333  *result_listener << "whose size is " << arg.size();
15334  return false;
15335 }
15336 
15337 } // namespace testing
15338 
15339 #endif // GMOCK_GMOCK_MORE_MATCHERS_H_
15340 
15341 namespace testing
15342 {
15343 
15344 // Declares Google Mock flags that we want a user to use programmatically.
15345 GMOCK_DECLARE_bool_(catch_leaked_mocks);
15346 GMOCK_DECLARE_string_(verbose);
15347 
15348 // Initializes Google Mock. This must be called before running the
15349 // tests. In particular, it parses the command line for the flags
15350 // that Google Mock recognizes. Whenever a Google Mock flag is seen,
15351 // it is removed from argv, and *argc is decremented.
15352 //
15353 // No value is returned. Instead, the Google Mock flag variables are
15354 // updated.
15355 //
15356 // Since Google Test is needed for Google Mock to work, this function
15357 // also initializes Google Test and parses its flags, if that hasn't
15358 // been done.
15359 GTEST_API_ void InitGoogleMock(int * argc, char ** argv);
15360 
15361 // This overloaded version can be used in Windows programs compiled in
15362 // UNICODE mode.
15363 GTEST_API_ void InitGoogleMock(int * argc, wchar_t ** argv);
15364 
15365 } // namespace testing
15366 
15367 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_H_
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
void ExpectSpecProperty(bool property, const string &failure_message) const
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
virtual void DescribeTo(::std::ostream *os) const
virtual void DescribeTo(::std::ostream *os) const
NaggyMock(const A1 &a1, const A2 &a2)
PolymorphicMatcher< internal::IsNullMatcher > IsNull()
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
virtual void DescribeNegationTo(::std::ostream *os) const
Function< F >::ArgumentMatcherTuple ArgumentMatcherTuple
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
void ExpectSpecProperty(bool property, const string &failure_message) const
virtual void DescribeTo(::std::ostream *os) const
GTEST_API_ ThreadLocal< Sequence * > g_gmock_implicit_sequence
internal::GtMatcher< Rhs > Gt(Rhs x)
static R InvokeMethod(Class *obj_ptr, MethodPtr method_ptr, const ::std::tr1::tuple< A1, A2, A3, A4, A5, A6 > &args)
virtual void UntypedDescribeUninterestingCall(const void *untyped_args,::std::ostream *os) const GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
TypeWithSize< 8 >::Int Int64
bool MatchAndExplainImpl(true_type, const Class *p, MatchResultListener *listener) const
virtual bool MatchAndExplain(T x, MatchResultListener *listener) const
static Result Perform(Impl *impl, const ::std::tr1::tuple< A0 > &args)
static void ExplainMatchFailuresTo(const MatcherTuple &matchers, const ValueTuple &values,::std::ostream *os)
void DescribeToHelper(bool expect_eq,::std::ostream *os) const
void AssertSpecProperty(bool property, const string &failure_message) const
static R InvokeMethod(Class *obj_ptr, MethodPtr method_ptr, const ::std::tr1::tuple< A1, A2, A3, A4, A5, A6, A7, A8 > &args)
internal::StlContainerView< GTEST_REMOVE_REFERENCE_AND_CONST_(Container) > ContainerView
virtual void DescribeNegationTo(::std::ostream *os) const
#define MOCK_METHOD0_T(m,...)
StrEqualityMatcher(const StringType &str, bool expect_eq, bool case_sensitive)
const Matcher< const SecondType & > second_matcher_
internal::StlContainerView< GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer) > LhsView
bool Matches(const ArgumentTuple &args) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
static Result Perform(Impl *impl, const ::std::tr1::tuple< A0, A1, A2 > &args)
virtual void DescribeTo(::std::ostream *os) const
PolymorphicMatcher< internal::MatchesRegexMatcher > MatchesRegex(const internal::RE *regex)
CallableTraits< Callable >::StorageType CallableStorageType
OnCallSpec(const char *a_file, int a_line, const ArgumentMatcherTuple &matchers)
static Result Perform(const ArgumentTuple &)
BothOfMatcher< typename AllOfResult3< M1, M2, M3 >::type, typename AllOfResult3< M4, M5, M6 >::type > type
static Matcher< T > Cast(M polymorphic_matcher_or_value)
internal::NeMatcher< Rhs > Ne(Rhs x)
virtual Result Perform(const ArgumentTuple &args)
virtual ~FunctionMockerBase() GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
const Matcher< InnerMatcherArg > mono_tuple_matcher_
ExpectationSet(const Expectation &e)
const internal::linked_ptr< internal::ExpectationBase > & expectation_base() const
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
bool MatchAndExplain(const T &value, MatchResultListener *listener) const
internal::Function< F >::ArgumentTuple ArgumentTuple
Matcher< T > An()
internal::IgnoredValue Unused
EitherOfMatcher< typename AnyOfResult3< M1, M2, M3 >::type, typename AnyOfResult3< M4, M5, M6 >::type > type
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
PolymorphicMatcher< internal::NotNullMatcher > NotNull()
static R Invoke(Function function, const ::std::tr1::tuple< A1, A2, A3, A4, A5, A6, A7 > &args)
GTEST_API_ string ConvertIdentifierNameToWords(const char *id_name)
GTEST_API_ Cardinality AtLeast(int n)
R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10)
MockSpec< F > & With(const Matcher< A1 > &m1, const Matcher< A2 > &m2, const Matcher< A3 > &m3, const Matcher< A4 > &m4, const Matcher< A5 > &m5, const Matcher< A6 > &m6, const Matcher< A7 > &m7, const Matcher< A8 > &m8)
AssertionResult AssertionFailure()
virtual void DescribeNegationTo(::std::ostream *os) const
int * count
internal::StlContainerView< RhsContainer > RhsView
TypedExpectation(FunctionMockerBase< F > *owner, const char *a_file, int a_line, const string &a_source_text, const ArgumentMatcherTuple &m)
EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
static const_reference ConstReference(const ::std::tr1::tuple< ElementPointer, Size > &array)
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
virtual void DescribeNegationTo(::std::ostream *os) const
internal::linked_ptr< const CardinalityInterface > impl_
static type Copy(const ::std::tr1::tuple< ElementPointer, Size > &array)
AssertionResult operator()(const char *value_text, const T &x) const
virtual bool MatchAndExplain(T value, MatchResultListener *) const
::std::tr1::tuple< Matcher< A1 >, Matcher< A2 >, Matcher< A3 > > type
#define GTEST_API_
BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
MockSpec< F > & With(const Matcher< A1 > &m1, const Matcher< A2 > &m2, const Matcher< A3 > &m3, const Matcher< A4 > &m4, const Matcher< A5 > &m5, const Matcher< A6 > &m6)
GTEST_API_ Cardinality AtMost(int n)
virtual void DescribeTo(::std::ostream *os) const
virtual void UntypedPrintArgs(const void *untyped_args,::std::ostream *os) const
static Result Perform(Impl *impl, const ::std::tr1::tuple<> &args)
InvokeMethodAction(Class *obj_ptr, MethodPtr method_ptr)
f
MatcherTuple< ArgumentTuple >::type ArgumentMatcherTuple
static R Invoke(Function function, const ::std::tr1::tuple< A1, A2, A3, A4, A5 > &args)
IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)
const Matcher< const ::std::vector< LhsValue > & > matcher_
PolymorphicAction< internal::InvokeMethodAction< Class, MethodPtr > > Invoke(Class *obj_ptr, MethodPtr method_ptr)
virtual void DescribeNegationTo(::std::ostream *os) const
BothOfMatcher< typename AllOfResult4< M1, M2, M3, M4 >::type, typename AllOfResult4< M5, M6, M7, M8 >::type > type
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
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)
virtual void DescribeTo(::std::ostream *os) const
internal::EqMatcher< T > Eq(T x)
void ExplainMatchResultTo(T x,::std::ostream *os) const
Matcher< const ArgumentTuple & > extra_matcher_
::std::string PrintToString(const T &value)
ExpectationSet(internal::ExpectationBase &exp)
static Matcher< T > Cast(const Matcher< U > &source_matcher)
internal::StlContainerView< RawContainer > View
TypedExpectation & WillOnce(const Action< F > &action)
const char Message[]
Definition: strings.h:102
R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
virtual Result Perform(const ArgumentTuple &)
static R Call(Function function, A1 a1, A2 a2)
PolymorphicAction< internal::SetArgumentPointeeAction< N, T, internal::IsAProtocolMessage< T >::value > > SetArgumentPointee(const T &x)
static ActionResultHolder * PerformAction(const Action< F > &action, const typename Function< F >::ArgumentTuple &args)
bool IsSatisfied() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
internal::Function< F1 >::ArgumentTuple ArgumentTuple
::std::tr1::tuple< Matcher< A1 >, Matcher< A2 >, Matcher< A3 >, Matcher< A4 >, Matcher< A5 > > type
bool ShouldHandleArguments(const ArgumentTuple &args) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
internal::SizeIsMatcher< SizeMatcher > SizeIs(const SizeMatcher &size_matcher)
const Action< F > & GetAction() const
GTEST_API_ void InitGoogleMock(int *argc, char **argv)
void DescribeLocationTo(::std::ostream *os) const
std::vector< internal::linked_ptr< ExpectationBase > > UntypedExpectations
static const_reference ConstReference(const RawContainer &container)
static void PrintIndices(::std::ostream *os)
GTEST_API_::std::string FormatFileLocation(const char *file, int line)
Matcher(const MatcherInterface< const internal::string & > *impl)
const Matcher< const KeyType & > inner_matcher_
TypedExpectation< F > * FindMatchingExpectationLocked(const ArgumentTuple &args) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
#define MOCK_METHOD5_T(m,...)
static Result Perform(Impl *impl, const ::std::tr1::tuple< A0, A1, A2, A3, A4, A5, A6 > &args)
MockSpec(internal::FunctionMockerBase< F > *function_mocker)
static R Invoke(Function function, const ::std::tr1::tuple< A1, A2 > &args)
PolymorphicAction< Impl > MakePolymorphicAction(const Impl &impl)
TypedExpectation & Times(const Cardinality &a_cardinality)
GTEST_API_ bool FindPairing(const MatchMatrix &matrix, MatchResultListener *listener)
::std::tr1::tuple< A1, A2, A3, A4 > ArgumentTuple
void DescribeTo(::std::ostream *os) const
Result type(GMOCK_FIELD_(ArgumentTuple, k1), GMOCK_FIELD_(ArgumentTuple, k2))
XmlRpcServer s
virtual bool MatchAndExplain(ArgsTuple args, MatchResultListener *listener) const
IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7)
MockSpec< F > & With(const Matcher< A1 > &m1, const Matcher< A2 > &m2, const Matcher< A3 > &m3, const Matcher< A4 > &m4, const Matcher< A5 > &m5, const Matcher< A6 > &m6, const Matcher< A7 > &m7)
TypedExpectation< F > & AddNewExpectation(const char *file, int line, const string &source_text, const ArgumentMatcherTuple &m) GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
virtual bool MatchAndExplain(Pointer pointer, MatchResultListener *listener) const
virtual void DescribeTo(::std::ostream *os) const
void DescribeTo(::std::ostream *os) const
internal::OnCallSpec< F > & InternalDefaultActionSetAt(const char *file, int line, const char *obj, const char *call)
DoBothAction(Action1 action1, Action2 action2)
PolymorphicMatcher< internal::MatchesRegexMatcher > ContainsRegex(const internal::RE *regex)
size_t SpaceIndex(size_t ilhs, size_t irhs) const
static Matcher< T > Cast(const Matcher< U > &matcher)
std::vector< const void * > UntypedActions
static R InvokeMethod(Class *obj_ptr, MethodPtr method_ptr, const ::std::tr1::tuple< A1, A2, A3, A4, A5 > &args)
#define GMOCK_FIELD_(Tuple, N)
OnCallSpec & With(const Matcher< const ArgumentTuple & > &m)
internal::KeyMatcher< M > Key(M inner_matcher)
bool HasEdge(size_t ilhs, size_t irhs) const
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
const Matcher< const ArgumentTuple & > & extra_matcher() const
internal::WithArgsAction< InnerAction > WithoutArgs(const InnerAction &action)
EndsWithMatcher(const StringType &suffix)
virtual void DescribeNegationTo(::std::ostream *os) const
static ActionResultHolder * PerformDefaultAction(const FunctionMockerBase< F > *func_mocker, const typename Function< F >::ArgumentTuple &args, const string &call_description)
const Action< F > & repeated_action() const
TypedExpectation & InSequence(const Sequence &s1, const Sequence &s2, const Sequence &s3, const Sequence &s4)
GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex)
bool is_retired() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
TypedExpectation & After(const ExpectationSet &s1, const ExpectationSet &s2)
::std::tr1::tuple< Matcher< A1 >, Matcher< A2 >, Matcher< A3 >, Matcher< A4 >, Matcher< A5 >, Matcher< A6 >, Matcher< A7 >, Matcher< A8 > > type
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
const Matcher< const Pointee & > matcher_
EitherOfMatcher< typename AnyOfResult2< M1, M2 >::type, typename AnyOfResult3< M3, M4, M5 >::type > type
InvokeMethodWithoutArgsAction(Class *obj_ptr, MethodPtr method_ptr)
InnerMatcher AllArgs(const InnerMatcher &matcher)
void DescribeTo(::std::ostream *os) const
void DescribeTo(::std::ostream *os) const
internal::FunctionMockerBase< F > *const function_mocker_
NotMatcherImpl(const Matcher< T > &matcher)
TypeWithSize< 8 >::UInt UInt64
virtual void DescribeNegationTo(::std::ostream *os) const
bool MatchPrintAndExplain(Value &value, const Matcher< T > &matcher, MatchResultListener *listener)
virtual void DescribeNegationTo(::std::ostream *os) const
Function< F >::ArgumentTuple ArgumentTuple
virtual void DescribeTo(::std::ostream *os) const
void IncrementCallCount() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
virtual int ConservativeUpperBound() const
void DescribeNegationTo(::std::ostream *os) const
Cardinality(const CardinalityInterface *impl)
EachMatcherImpl(InnerMatcher inner_matcher)
bool IsOverSaturatedByCallCount(int call_count) const
::std::tr1::tuple< Matcher< A1 >, Matcher< A2 >, Matcher< A3 >, Matcher< A4 >, Matcher< A5 >, Matcher< A6 >, Matcher< A7 >, Matcher< A8 >, Matcher< A9 >, Matcher< A10 > > type
internal::PointwiseMatcher< TupleMatcher, GTEST_REMOVE_CONST_(Container)> Pointwise(const TupleMatcher &tuple_matcher, const Container &rhs)
internal::FloatingEqMatcher< double > NanSensitiveDoubleEq(double rhs)
QuantifierMatcherImpl(InnerMatcher inner_matcher)
bool operator==(const ExpectationSet &rhs) const
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
bool TupleMatches(const MatcherTuple &matcher_tuple, const ValueTuple &value_tuple)
::std::tr1::tuple< GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4), GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6), GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type
virtual Result Perform(const ArgumentTuple &args)
PolymorphicMatcher< internal::EndsWithMatcher< internal::string > > EndsWith(const internal::string &suffix)
virtual bool MatchAndExplain(T obj, MatchResultListener *listener) const
Result Perform(const ArgumentTuple &args) const
internal::UnorderedElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > UnorderedElementsAreArray(Iter first, Iter last)
const OnCallSpec< F > * FindOnCallSpec(const ArgumentTuple &args) const
#define GTEST_COMPILE_ASSERT_(expr, msg)
const internal::linked_ptr< const RE > regex_
NiceMock(const A1 &a1, const A2 &a2)
static Result Perform(Impl *impl, const ::std::tr1::tuple< A0, A1 > &args)
static ActionResultHolder * PerformAction(const Action< F > &action, const typename Function< F >::ArgumentTuple &args)
static const_reference ConstReference(const Element(&array)[N])
Function< F >::MakeResultVoid VoidResult
bool CaseInsensitiveCStringEquals(const wchar_t *lhs, const wchar_t *rhs)
static Result Perform(Impl *impl, const ::std::tr1::tuple< A0, A1, A2, A3, A4, A5 > &args)
Result InvokeWith(const ArgumentTuple &args) GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
name
Definition: setup.py:38
static Result Perform(Impl *impl, const ::std::tr1::tuple< A0, A1, A2, A3, A4, A5, A6, A7, A8 > &args)
::std::tr1::tuple< A1, A2, A3, A4, A5, A6, A7, A8 > ArgumentTuple
static R InvokeMethod(Class *obj_ptr, MethodPtr method_ptr, const ::std::tr1::tuple< A1, A2, A3 > &args)
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
Function< F >::ArgumentTuple ArgumentTuple
InvokeAction(FunctionImpl function_impl)
virtual void PrintAsActionResult(::std::ostream *os) const
static R Invoke(Function function, const ::std::tr1::tuple< A1, A2, A3, A4, A5, A6 > &args)
GMOCK_DECLARE_bool_(catch_leaked_mocks)
TypedExpectation & After(const ExpectationSet &s1, const ExpectationSet &s2, const ExpectationSet &s3, const ExpectationSet &s4, const ExpectationSet &s5)
FieldMatcher(FieldType Class::*field, const Matcher< const FieldType & > &matcher)
static Matcher< T > Cast(M polymorphic_matcher_or_value)
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
static R Invoke(Function function, const ::std::tr1::tuple<> &)
bool MatchAndExplainImpl(false_type, const Class &obj, MatchResultListener *listener) const
bool MatchAndExplain(T &x, MatchResultListener *) const
virtual Result Perform(const ArgumentTuple &)
virtual bool MatchAndExplain(PairType key_value, MatchResultListener *listener) const
EitherOfMatcher< typename AnyOfResult5< M1, M2, M3, M4, M5 >::type, typename AnyOfResult5< M6, M7, M8, M9, M10 >::type > type
internal::ReturnRefAction< R > ReturnRef(R &x)
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
virtual void DescribeNegationTo(::std::ostream *os) const
static void Perform(const ArgumentTuple &)
internal::AllOfResult2< M1, M2 >::type AllOf(M1 m1, M2 m2)
internal::RefMatcher< T & > Ref(T &x)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
TypedExpectation & After(const ExpectationSet &s1, const ExpectationSet &s2, const ExpectationSet &s3, const ExpectationSet &s4)
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3)
Function< F >::ArgumentTuple ArgumentTuple
internal::TupleFields< RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 >::type SelectedArgs
::std::tr1::tuple< Matcher< A1 >, Matcher< A2 >, Matcher< A3 >, Matcher< A4 >, Matcher< A5 >, Matcher< A6 > > type
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrEq(const internal::string &str)
internal::Function< F >::ArgumentTuple ArgumentTuple
::std::tr1::tuple< A1, A2, A3, A4, A5, A6, A7 > ArgumentTuple
bool operator==(const Expectation &rhs) const
EitherOfMatcher< typename AnyOfResult2< M1, M2 >::type, typename AnyOfResult2< M3, M4 >::type > type
virtual void DescribeTo(::std::ostream *os) const
::std::vector< ElementMatcherPair > ElementMatcherPairs
internal::Function< F >::MakeResultIgnoredValue OriginalFunction
void DescribeTo(::std::ostream *os) const
TypedExpectation & InSequence(const Sequence &s1, const Sequence &s2)
Impl(const SizeMatcher &size_matcher)
static R InvokeMethod(Class *obj_ptr, MethodPtr method_ptr, const ::std::tr1::tuple< A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 > &args)
internal::Function< F >::ArgumentTuple ArgumentTuple
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
static R InvokeMethod(Class *obj_ptr, MethodPtr method_ptr, const ::std::tr1::tuple<> &)
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
void DescribeNegationTo(::std::ostream *os) const
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10)
PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher)
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
GMOCK_DECLARE_KIND_(bool, kBool)
Action< F > MakeAction(ActionInterface< F > *impl)
#define MOCK_METHOD6_T(m,...)
virtual void Perform(const ArgumentTuple &args)
internal::LtMatcher< Rhs > Lt(Rhs x)
void DescribeNegationTo(::std::ostream *os) const
static Matcher< T > CastImpl(M polymorphic_matcher_or_value, BooleanConstant< true >)
Expectation::Set::const_iterator const_iterator
OnCallSpec< F > & AddNewOnCallSpec(const char *file, int line, const ArgumentMatcherTuple &m) GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
static Result Perform(Impl *impl, const ::std::tr1::tuple< A0, A1, A2, A3 > &args)
MatcherBase(const MatcherInterface< T > *impl)
int call_count() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
internal::FloatingEqMatcher< double > DoubleNear(double rhs, double max_abs_error)
MockSpec< F > & With(const Matcher< A1 > &m1, const Matcher< A2 > &m2)
FloatingEqMatcher(FloatType rhs, bool nan_eq_nan)
bool MatchAndExplain(T x, MatchResultListener *listener) const
BothOfMatcher< typename AllOfResult2< M1, M2 >::type, typename AllOfResult3< M3, M4, M5 >::type > type
MatcherTuple< ArgumentTuple >::type ArgumentMatcherTuple
internal::FloatingEqMatcher< double > DoubleEq(double rhs)
virtual int ConservativeLowerBound() const
void ReportUninterestingCall(CallReaction reaction, const string &msg)
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
void DescribeTo(::std::ostream *os) const
#define MOCK_METHOD3_T(m,...)
BothOfMatcher< typename AllOfResult5< M1, M2, M3, M4, M5 >::type, typename AllOfResult5< M6, M7, M8, M9, M10 >::type > type
SelectArgs< Result, ArgumentTuple, k1, k2, k3, k4, k5, k6, k7, k8, k9, k10 >::type InnerFunctionType
Matcher(const MatcherInterface< T > *impl)
MockSpec< F > & With(const Matcher< A1 > &m1, const Matcher< A2 > &m2, const Matcher< A3 > &m3, const Matcher< A4 > &m4, const Matcher< A5 > &m5, const Matcher< A6 > &m6, const Matcher< A7 > &m7, const Matcher< A8 > &m8, const Matcher< A9 > &m9)
virtual bool MatchAndExplain(T x, MatchResultListener *listener) const
static R InvokeMethod(Class *obj_ptr, MethodPtr method_ptr, const ::std::tr1::tuple< A1 > &args)
virtual void DescribeNegationTo(::std::ostream *os) const
internal::TypedExpectation< F > & InternalExpectedAt(const char *file, int line, const char *obj, const char *call)
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)
MatcherTuple< ArgumentTuple >::type ArgumentMatcherTuple
Expectation::Set::value_type value_type
internal::UnorderedElementsAreMatcher< std::tr1::tuple<> > UnorderedElementsAre()
#define GMOCK_FIELD_TYPE_(Tuple, i)
::std::tr1::tuple< Matcher< A1 >, Matcher< A2 >, Matcher< A3 >, Matcher< A4 > > type
void DescribeNegationTo(::std::ostream *os) const
virtual Result Perform(const ArgumentTuple &)
internal::linked_ptr< internal::ExpectationBase > expectation_base_
virtual void DescribeNegationTo(::std::ostream *os) const
Action(ActionInterface< F > *impl)
IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8, A9)
internal::Function< F >::ArgumentTuple ArgumentTuple
static R Call(Function function, A1 a1)
static Result Perform(Impl *impl, const ::std::tr1::tuple< A0, A1, A2, A3, A4, A5, A6, A7, A8, A9 > &args)
FunctionMockerBase< F > *const owner_
MatchMatrix(size_t num_elements, size_t num_matchers)
internal::LeMatcher< Rhs > Le(Rhs x)
MatchesRegexMatcher(const RE *regex, bool full_match)
TypedExpectation & InSequence(const Sequence &s)
void Expect(bool condition, const char *file, int line, const string &msg)
internal::ElementsAreMatcher< std::tr1::tuple<> > ElementsAre()
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4)
AssertionResult AssertionSuccess()
PolymorphicMatcher< Impl > MakePolymorphicMatcher(const Impl &impl)
static Result Perform(Impl *impl, const ::std::tr1::tuple< A0, A1, A2, A3, A4, A5, A6, A7 > &args)
const char kWarningVerbosity[]
void DescribeTo(::std::ostream *os) const
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrCaseNe(const internal::string &str)
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)
message
Definition: server.py:50
BothOfMatcherImpl(const Matcher< T > &matcher1, const Matcher< T > &matcher2)
Result type(GMOCK_FIELD_(ArgumentTuple, k1), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3))
const Action< F > * GetActionForArguments(const FunctionMockerBase< F > *mocker, const ArgumentTuple &args,::std::ostream *what,::std::ostream *why) GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
static void ExplainMatchFailuresTo(const MatcherTuple &, const ValueTuple &,::std::ostream *)
IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8)
IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6)
static type GetSelectedFields(const Tuple &t)
static Matcher< T > CastImpl(M value, BooleanConstant< false >)
static R InvokeMethod(Class *obj_ptr, MethodPtr method_ptr, const ::std::tr1::tuple< A1, A2 > &args)
void DescribeNegationTo(::std::ostream *os) const
void DescribeTo(::std::ostream *os) const
internal::ElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > ElementsAreArray(Iter first, Iter last)
static OutIter Run(Func f, const Tuple &t, OutIter out)
PolymorphicAction< internal::SetArgumentPointeeAction< N, T, internal::IsAProtocolMessage< T >::value > > SetArgPointee(const T &x)
PolymorphicMatcher(const Impl &an_impl)
#define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
bool operator()(const Expectation &lhs, const Expectation &rhs) const
::testing::internal::linked_ptr< const MatcherInterface< T > > impl_
ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_0_VALUE_PARAMS())
Result type(GMOCK_FIELD_(ArgumentTuple, k1), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7), GMOCK_FIELD_(ArgumentTuple, k8))
WithArgsAction(const InnerAction &action)
static R InvokeMethod(Class *obj_ptr, MethodPtr method_ptr, const ::std::tr1::tuple< A1, A2, A3, A4, A5, A6, A7 > &args)
MatchMatrix AnalyzeElements(ElementIter elem_first, ElementIter elem_last,::std::vector< string > *element_printouts, MatchResultListener *listener) const
MatchResultListener & operator<<(const T &x)
static R Invoke(Function function, const ::std::tr1::tuple< A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 > &args)
bool MatchAndExplainImpl(true_type, const Class *p, MatchResultListener *listener) const
bool MatchAndExplain(const T &value, MatchResultListener *listener) const
virtual void PrintAsActionResult(::std::ostream *) const
::std::vector< Matcher< const Element & > > MatcherVec
::std::tr1::tuple< GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4), GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6), GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8), GMOCK_FIELD_TYPE_(Tuple, k9)> type
PolymorphicMatcher< internal::HasSubstrMatcher< internal::string > > HasSubstr(const internal::string &substring)
::std::tr1::tuple< A1, A2, A3, A4, A5 > ArgumentTuple
#define MOCK_METHOD8_T(m,...)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
void DescribeNegationTo(::std::ostream *os) const
bool Value(const T &value, M matcher)
virtual bool MatchAndExplain(T x, MatchResultListener *listener) const
internal::WithArgsAction< InnerAction, k1 > WithArgs(const InnerAction &action)
void DescribeTo(::std::ostream *os) const
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
string call
Definition: codegen.py:342
void AddExpectation(const Expectation &expectation) const
void PrintIfNotEmpty(const internal::string &explanation,::std::ostream *os)
R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
virtual bool MatchAndExplain(Super &x, MatchResultListener *listener) const
MatcherTuple< ArgumentTuple >::type ArgumentMatcherTuple
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)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
::std::tr1::tuple< GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4), GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type
bool MatchAndExplain(const Pointer &p, MatchResultListener *) const
bool operator!=(const ExpectationSet &rhs) const
virtual void DescribeNegationTo(::std::ostream *os) const
Impl(const Action< VoidResult > &action1, const Action< F > &action2)
virtual void DescribeNegationTo(::std::ostream *os) const
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
bool Matches(const ArgumentTuple &args) const
static R Invoke(Function function, const ::std::tr1::tuple< A1, A2, A3, A4, A5, A6, A7, A8 > &args)
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)
virtual void DescribeTo(::std::ostream *os) const
GTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity, const char *file, int line, const string &message)
PropertyMatcher(PropertyType(Class::*property)() const, const Matcher< RefToConstProperty > &matcher)
::std::tr1::tuple< Matcher< A1 >, Matcher< A2 >, Matcher< A3 >, Matcher< A4 >, Matcher< A5 >, Matcher< A6 >, Matcher< A7 > > type
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
MatcherTuple< ArgumentTuple >::type ArgumentMatcherTuple
internal::MatcherAsPredicate< M > Matches(M matcher)
TypedExpectation & WillRepeatedly(const Action< F > &action)
virtual bool MatchAndExplain(T x, MatchResultListener *listener) const
static R Invoke(Function function, const ::std::tr1::tuple< A1, A2, A3 > &args)
Matcher< T > MakeMatcher(const MatcherInterface< T > *impl)
#define MOCK_METHOD9_T(m,...)
Matcher< T > SafeMatcherCast(const M &polymorphic_matcher)
virtual bool MatchAndExplain(LhsContainer lhs, MatchResultListener *listener) const
EitherOfMatcher< typename AnyOfResult4< M1, M2, M3, M4 >::type, typename AnyOfResult5< M5, M6, M7, M8, M9 >::type > type
UnorderedElementsAreMatcherImpl(InputIter first, InputIter last)
GTEST_API_ void Log(LogSeverity severity, const string &message, int stack_frames_to_skip)
::std::pair< size_t, size_t > ElementMatcherPair
UntypedOnCallSpecBase(const char *a_file, int a_line)
void UniversalPrint(const T &value,::std::ostream *os)
internal::FloatingEqMatcher< float > NanSensitiveFloatEq(float rhs)
virtual void DescribeTo(::std::ostream *os) const
const Matcher< RefToConstProperty > matcher_
class GTEST_API_ testing::InSequence GTEST_ATTRIBUTE_UNUSED_
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T)
void DescribeNegationTo(::std::ostream *os) const
#define GTEST_DISALLOW_ASSIGN_(type)
void DescribeTo(::std::ostream *os) const
static SelectedArgs GetSelectedArgs(ArgsTuple args)
virtual void DescribeNegationTo(::std::ostream *os) const
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
#define GTEST_REMOVE_REFERENCE_(T)
GTEST_API_ string FormatMatcherDescription(bool negation, const char *matcher_name, const Strings &param_values)
BothOfMatcher< typename AllOfResult4< M1, M2, M3, M4 >::type, typename AllOfResult5< M5, M6, M7, M8, M9 >::type > type
EitherOfMatcher< typename AnyOfResult3< M1, M2, M3 >::type, typename AnyOfResult4< M4, M5, M6, M7 >::type > type
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
virtual bool MatchAndExplain(PairType a_pair, MatchResultListener *listener) const
::std::tr1::tuple< GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4), GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6), GMOCK_FIELD_TYPE_(Tuple, k7)> type
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3)
void DescribeNegationTo(::std::ostream *os) const
virtual const ExpectationBase * UntypedFindMatchingExpectation(const void *untyped_args, const void **untyped_action, bool *is_excessive,::std::ostream *what,::std::ostream *why) GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
ArgsMatcher(const InnerMatcher &inner_matcher)
bool operator()(const ::testing::internal::linked_ptr< T > &lhs, const ::testing::internal::linked_ptr< T > &rhs) const
PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher)
Result PerformDefaultAction(const ArgumentTuple &args, const string &call_description) const
#define MOCK_METHOD10_T(m,...)
static R Call(Function function, A1 a1, A2 a2, A3 a3)
#define GTEST_REFERENCE_TO_CONST_(T)
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
Function< type >::ArgumentTuple SelectedArgs
GMOCK_DECLARE_string_(verbose)
virtual bool MatchAndExplain(LhsContainer lhs, MatchResultListener *listener) const
bool MatchAndExplain(const Pointer &p, MatchResultListener *) const
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
virtual void DescribeNegationTo(::std::ostream *os) const
::std::tr1::tuple< A1, A2, A3 > ArgumentTuple
::std::tr1::tuple< GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type
Function< F >::ArgumentTuple ArgumentTuple
const Matcher< ResultType > matcher_
void DescribeTo(::std::ostream *os) const
const Matcher< const FieldType & > matcher_
ElementsAreMatcherImpl(InputIter first, InputIter last)
::std::tr1::tuple< A1, A2, A3, A4, A5, A6, A7, A8, A9 > ArgumentTuple
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)
void Expect(bool condition, const char *file, int line)
Cardinality MakeCardinality(const CardinalityInterface *c)
virtual void DescribeTo(::std::ostream *os) const
ContainsMatcherImpl(InnerMatcher inner_matcher)
MockSpec< F > & With(const Matcher< A1 > &m1, const Matcher< A2 > &m2, const Matcher< A3 > &m3)
static Matcher< T > Cast(const Matcher< T > &matcher)
internal::Function< F >::ArgumentTuple ArgumentTuple
EitherOfMatcher< typename AnyOfResult1< M1 >::type, typename AnyOfResult2< M2, M3 >::type > type
internal::FloatingEqMatcher< float > NanSensitiveFloatNear(float rhs, float max_abs_error)
virtual void DescribeTo(::std::ostream *os) const
static bool Matches(const MatcherTuple &matcher_tuple, const ValueTuple &value_tuple)
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void,)
static ResType Invoke(ResType(*f)(ArgType), T arg)
TypedExpectation & After(const ExpectationSet &s1, const ExpectationSet &s2, const ExpectationSet &s3)
MockSpec< F > & With(const Matcher< A1 > &m1)
void DescribeTo(::std::ostream *os) const
internal::Function< F >::Result Result
Result type(GMOCK_FIELD_(ArgumentTuple, k1), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), GMOCK_FIELD_(ArgumentTuple, k6))
internal::Function< F >::ArgumentMatcherTuple ArgumentMatcherTuple
void Perform(const ArgumentTuple &args) const
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrNe(const internal::string &str)
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
GTEST_API_ Cardinality Between(int min, int max)
internal::Function< F1 >::Result Result
bool operator()(const T &lhs, const U &rhs) const
PredicateFormatterFromMatcher< M > MakePredicateFormatterFromMatcher(const M &matcher)
PolymorphicAction< internal::ReturnNullAction > ReturnNull()
void ExplainMatchFailureTupleTo(const MatcherTuple &matchers, const ValueTuple &values,::std::ostream *os)
void Retire() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
void AssertSpecProperty(bool property, const string &failure_message) const
internal::linked_ptr< Expectation > last_expectation_
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
virtual void DescribeTo(::std::ostream *os) const
R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
Matcher< const ArgumentTuple & > extra_matcher_
ExpectationSet & operator+=(const Expectation &e)
#define MOCK_METHOD4_T(m,...)
BothOfMatcher< typename AllOfResult3< M1, M2, M3 >::type, typename AllOfResult4< M4, M5, M6, M7 >::type > type
BothOfMatcher< typename AllOfResult2< M1, M2 >::type, typename AllOfResult2< M3, M4 >::type > type
ResultOfMatcher(Callable callable, const Matcher< ResultType > &matcher)
virtual void DescribeTo(::std::ostream *os) const
HasSubstrMatcher(const StringType &substring)
GTEST_API_ bool LogIsVisible(LogSeverity severity)
Function< F >::ArgumentMatcherTuple ArgumentMatcherTuple
virtual void ClearDefaultActionsLocked() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
NaggyMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
bool IsSaturated() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
EitherOfMatcher< typename AnyOfResult1< M1 >::type, typename AnyOfResult1< M2 >::type > type
GTEST_API_ Cardinality Exactly(int n)
bool IsSaturatedByCallCount(int call_count) const
void SetEdge(size_t ilhs, size_t irhs, bool b)
bool MatchAndExplain(const LhsContainer &lhs, MatchResultListener *listener) const
Matcher< Lhs > TypedEq(const Rhs &rhs)
void set_cardinality(const Cardinality &a_cardinality)
internal::Function< F >::ArgumentTuple ArgumentTuple
const_iterator end() const
Result type(GMOCK_FIELD_(ArgumentTuple, k1), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7), GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9), GMOCK_FIELD_(ArgumentTuple, k10))
#define GMOCK_KIND_OF_(type)
internal::WhenSortedByMatcher< internal::LessComparator, ContainerMatcher > WhenSorted(const ContainerMatcher &container_matcher)
MatcherTuple< ArgumentTuple >::type ArgumentMatcherTuple
internal::FloatingEqMatcher< double > NanSensitiveDoubleNear(double rhs, double max_abs_error)
internal::NamedArg< char > arg(StringRef name, const T &arg)
Definition: format.h:3918
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
FloatingEqMatcher(FloatType rhs, bool nan_eq_nan, FloatType max_abs_error)
Matcher< T > MatcherCast(M matcher)
GTEST_API_ Cardinality AnyNumber()
virtual void DescribeTo(::std::ostream *os) const
static bool Matches(const MatcherTuple &, const ValueTuple &)
ContainerView::type::size_type SizeType
const_iterator begin() const
BothOfMatcher< typename AllOfResult1< M1 >::type, typename AllOfResult1< M2 >::type > type
internal::DoDefaultAction DoDefault()
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
TypedExpectation & InSequence(const Sequence &s1, const Sequence &s2, const Sequence &s3, const Sequence &s4, const Sequence &s5)
WhenSortedByMatcher(const Comparator &comparator, const ContainerMatcher &matcher)
OnCallSpec & WillByDefault(const Action< F > &action)
void Assert(bool condition, const char *file, int line)
#define GMOCK_IMPLEMENT_COMPARISON_MATCHER_(name, op, relation, negated_relation)
Result Perform(const ArgumentTuple &args) const
::std::tr1::tuple< A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 > ArgumentTuple
TypedExpectation & After(const ExpectationSet &s)
Impl(const TupleMatcher &tuple_matcher, const RhsStlContainer &rhs)
static R Invoke(Function function, const ::std::tr1::tuple< A1, A2, A3, A4, A5, A6, A7, A8, A9 > &args)
const MatcherDescriberInterface * GetDescriber() const
ActionAdaptor(const Action< F2 > &from)
void DescribeTo(::std::ostream *os) const
void FormatUnexpectedCallMessageLocked(const ArgumentTuple &args,::std::ostream *os,::std::ostream *why) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
Matcher< T > A()
static type Copy(const RawContainer &container)
internal::StlContainerView< GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer) > LhsView
static SelectedArgs Select(const ArgumentTuple &args)
MockSpec< F > & With(const Matcher< A1 > &m1, const Matcher< A2 > &m2, const Matcher< A3 > &m3, const Matcher< A4 > &m4, const Matcher< A5 > &m5)
const Matcher< const Element & > inner_matcher_
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeTo(::std::ostream *os) const
void SetMatchers(const ArgumentMatcherTuple &matchers)
void ExplainMatchResultTo(const ArgumentTuple &args,::std::ostream *os) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
static R Invoke(Function function, const ::std::tr1::tuple< A1 > &args)
BothOfMatcher< typename AllOfResult1< M1 >::type, typename AllOfResult2< M2, M3 >::type > type
GTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix &g)
internal::EachMatcher< M > Each(M matcher)
bool IsReadableTypeName(const string &type_name)
internal::Function< F >::ArgumentTuple ArgumentTuple
PointeeOf< GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(Pointer))>::type Pointee
OutIter TransformTupleValues(Func f, const Tuple &t, OutIter out)
static ActionResultHolder * PerformDefaultAction(const FunctionMockerBase< F > *func_mocker, const typename Function< F >::ArgumentTuple &args, const string &call_description)
Function< F >::ArgumentTuple ArgumentTuple
::std::vector< Matcher< const Element & > > matchers_
::std::vector< string > Strings
internal::ReferenceWrapper< T > ByRef(T &l_value)
Matcher< Target > operator()(const Arg &a) const
Matcher< const SelectedArgs & > MonomorphicInnerMatcher
::std::tr1::tuple< GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple, k1)> type
MockSpec< F > & With(const Matcher< A1 > &m1, const Matcher< A2 > &m2, const Matcher< A3 > &m3, const Matcher< A4 > &m4, const Matcher< A5 > &m5, const Matcher< A6 > &m6, const Matcher< A7 > &m7, const Matcher< A8 > &m8, const Matcher< A9 > &m9, const Matcher< A10 > &m10)
virtual Result Perform(const ArgumentTuple &args)
static R InvokeMethod(Class *obj_ptr, MethodPtr method_ptr, const ::std::tr1::tuple< A1, A2, A3, A4, A5, A6, A7, A8, A9 > &args)
#define GTEST_REMOVE_CONST_(T)
internal::FloatingEqMatcher< float > FloatEq(float rhs)
Result Perform(const ArgumentTuple &) const
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
virtual void DescribeTo(::std::ostream *os) const
PolymorphicAction< internal::AssignAction< T1, T2 > > Assign(T1 *ptr, T2 val)
internal::DoBothAction< Action1, Action2 > DoAll(Action1 a1, Action2 a2)
const Pointer::element_type * GetRawPointer(const Pointer &p)
::std::tr1::tuple< GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4), GMOCK_FIELD_TYPE_(Tuple, k5)> type
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3)
bool_constant< false > false_type
Element * GetRawPointer(Element *p)
const Matcher< const FirstType & > first_matcher_
bool CaseInsensitiveStringEquals(const StringType &s1, const StringType &s2)
bool IsSatisfiedByCallCount(int call_count) const
void DescribeNegationTo(::std::ostream *os) const
virtual bool MatchAndExplain(T, MatchResultListener *) const
const internal::AnythingMatcher _
static Result Perform(Impl *impl, const ::std::tr1::tuple< A0, A1, A2, A3, A4 > &args)
virtual void DescribeNegationTo(::std::ostream *os) const
PointeeMatcher(const InnerMatcher &matcher)
internal::Function< F >::Result Result
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
#define MOCK_METHOD7_T(m,...)
void DescribeNegationTo(::std::ostream *os) const
bool MatchAndExplainImpl(false_type, const Class &obj, MatchResultListener *listener) const
virtual Result Perform(const ArgumentTuple &args)
static type Copy(const Element(&array)[N])
NiceMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
KeyMatcherImpl(InnerMatcher inner_matcher)
static R InvokeMethod(Class *obj_ptr, MethodPtr method_ptr, const ::std::tr1::tuple< A1, A2, A3, A4 > &args)
CallableTraits< Callable >::ResultType ResultType
Result Perform(const ArgumentTuple &args)
RemoveConstFromKey< typename LhsStlContainer::value_type >::type LhsValue
virtual bool MatchAndExplain(T x, MatchResultListener *listener) const
Result type(GMOCK_FIELD_(ArgumentTuple, k1), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5))
const ArgumentMatcherTuple & matchers() const
void Perform(const ArgumentTuple &) const
virtual void DescribeTo(::std::ostream *os) const
internal::IgnoreResultAction< A > IgnoreResult(const A &an_action)
Result type(GMOCK_FIELD_(ArgumentTuple, k1), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7))
OutIter operator()(Func f, const Tup &t, OutIter out) const
internal::GeMatcher< Rhs > Ge(Rhs x)
Iter ArrayAwareFind(Iter begin, Iter end, const Element &elem)
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrCaseEq(const internal::string &str)
PolymorphicAction< internal::SetErrnoAndReturnAction< T > > SetErrnoAndReturn(int errval, T result)
Result type(GMOCK_FIELD_(ArgumentTuple, k1), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7), GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9))
static void Print(const T &value,::std::ostream *os)
#define MOCK_METHOD1_T(m,...)
::std::tr1::tuple< Matcher< A1 >, Matcher< A2 > > type
void DescribeNegationTo(::std::ostream *os) const
::std::tr1::tuple< GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type
MockSpec< F > & With(const Matcher< A1 > &m1, const Matcher< A2 > &m2, const Matcher< A3 > &m3, const Matcher< A4 > &m4)
void ExplainSuccess(const internal::string &first_explanation, const internal::string &second_explanation, MatchResultListener *listener) const
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)
internal::StlContainerView< RawContainer > View
void DescribeNegationTo(::std::ostream *os) const
EitherOfMatcherImpl(const Matcher< T > &matcher1, const Matcher< T > &matcher2)
internal::ContainsMatcher< M > Contains(M matcher)
internal::WithArgsAction< InnerAction, k > WithArg(const InnerAction &action)
#define GTEST_CHECK_(condition)
TypedExpectation & With(const Matcher< const ArgumentTuple & > &m)
internal::Function< F >::ArgumentTuple ArgumentTuple
::std::set< Expectation, Less > Set
EitherOfMatcher< typename AnyOfResult4< M1, M2, M3, M4 >::type, typename AnyOfResult4< M5, M6, M7, M8 >::type > type
internal::Function< F >::ArgumentTuple ArgumentTuple
const Action< F > & GetCurrentAction(const FunctionMockerBase< F > *mocker, const ArgumentTuple &args) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
const Cardinality & cardinality() const
bool operator!=(const Expectation &rhs) const
void DescribeCallCountTo(::std::ostream *os) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
Impl(FloatType rhs, bool nan_eq_nan, FloatType max_abs_error)
internal::StlContainerView< Container > View
bool IsOverSaturated() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
StrictMock(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
::std::tr1::tuple< Matcher< A1 >, Matcher< A2 >, Matcher< A3 >, Matcher< A4 >, Matcher< A5 >, Matcher< A6 >, Matcher< A7 >, Matcher< A8 >, Matcher< A9 > > type
internal::ResultOfMatcher< Callable > ResultOf(Callable callable, const ResultOfMatcher &matcher)
internal::linked_ptr< ActionInterface< F > > impl_
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
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)
::std::tr1::tuple< A1, A2, A3, A4, A5, A6 > ArgumentTuple
PointwiseMatcher(const TupleMatcher &tuple_matcher, const RhsContainer &rhs)
ACTION_P(ReturnPointee, pointer)
ArgsMatcherImpl(const InnerMatcher &inner_matcher)
void DescribeDefaultActionTo(const ArgumentTuple &args,::std::ostream *os) const
TypedExpectation & InSequence(const Sequence &s1, const Sequence &s2, const Sequence &s3)
Impl(CallableStorageType callable, const Matcher< ResultType > &matcher)
StrictMock(const A1 &a1, const A2 &a2)
Action(const Action &action)
MATCHER(IsEmpty, negation?"isn't empty":"is empty")
void PrintTriedExpectationsLocked(const ArgumentTuple &args,::std::ostream *why) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
internal::ReturnRefOfCopyAction< R > ReturnRefOfCopy(const R &x)
Matcher(const MatcherInterface< internal::string > *impl)
const T & Const(const T &x)
Result type(GMOCK_FIELD_(ArgumentTuple, k1), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k4))
#define GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(name, op, relation)
void PrintTo(const ReferenceWrapper< T > &ref,::std::ostream *os)
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
::std::tr1::tuple< const LhsValue &, const RhsValue & > InnerMatcherArg
::std::tr1::tuple< GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3)> type
const internal::linked_ptr< ActionInterface< F2 > > impl_
virtual void DescribeNegationTo(::std::ostream *os) const
Function< F >::ArgumentMatcherTuple ArgumentMatcherTuple
SizeIsMatcher(const SizeMatcher &size_matcher)
virtual void DescribeNegationTo(::std::ostream *os) const
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
::std::vector< const MatcherDescriberInterface * > MatcherDescriberVec
internal::ReturnAction< R > Return(R value)
internal::WhenSortedByMatcher< Comparator, ContainerMatcher > WhenSortedBy(const Comparator &comparator, const ContainerMatcher &container_matcher)
bool MatchAndExplainImpl(bool all_elements_should_match, Container container, MatchResultListener *listener) const
static ResultType Invoke(Functor f, T arg)
virtual UntypedActionResultHolderBase * UntypedPerformDefaultAction(const void *untyped_args, const string &call_description) const
static R Invoke(Function function, const ::std::tr1::tuple< A1, A2, A3, A4 > &args)
virtual void MaybeDescribeExtraMatcherTo(::std::ostream *os)
virtual UntypedActionResultHolderBase * UntypedPerformAction(const void *untyped_action, const void *untyped_args) const
#define MOCK_METHOD2_T(m,...)
#define GTEST_LOCK_EXCLUDED_(locks)
Impl(const Comparator &comparator, const ContainerMatcher &matcher)
virtual void DescribeNegationTo(::std::ostream *os) const
const MonomorphicInnerMatcher inner_matcher_
internal::FloatingEqMatcher< float > FloatNear(float rhs, float max_abs_error)


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