gmock-generated-matchers.h 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179
  1. // This file was GENERATED by command:
  2. // pump.py gmock-generated-matchers.h.pump
  3. // DO NOT EDIT BY HAND!!!
  4. // Copyright 2008, Google Inc.
  5. // All rights reserved.
  6. //
  7. // Redistribution and use in source and binary forms, with or without
  8. // modification, are permitted provided that the following conditions are
  9. // met:
  10. //
  11. // * Redistributions of source code must retain the above copyright
  12. // notice, this list of conditions and the following disclaimer.
  13. // * Redistributions in binary form must reproduce the above
  14. // copyright notice, this list of conditions and the following disclaimer
  15. // in the documentation and/or other materials provided with the
  16. // distribution.
  17. // * Neither the name of Google Inc. nor the names of its
  18. // contributors may be used to endorse or promote products derived from
  19. // this software without specific prior written permission.
  20. //
  21. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. // Google Mock - a framework for writing C++ mock classes.
  33. //
  34. // This file implements some commonly used variadic matchers.
  35. #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
  36. #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
  37. #include <iterator>
  38. #include <sstream>
  39. #include <string>
  40. #include <vector>
  41. #include "gmock/gmock-matchers.h"
  42. namespace testing {
  43. namespace internal {
  44. // The type of the i-th (0-based) field of Tuple.
  45. #define GMOCK_FIELD_TYPE_(Tuple, i) \
  46. typename ::testing::tuple_element<i, Tuple>::type
  47. // TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
  48. // tuple of type Tuple. It has two members:
  49. //
  50. // type: a tuple type whose i-th field is the ki-th field of Tuple.
  51. // GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
  52. //
  53. // For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
  54. //
  55. // type is tuple<int, bool>, and
  56. // GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
  57. template <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
  58. int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
  59. int k9 = -1>
  60. class TupleFields;
  61. // This generic version is used when there are 10 selectors.
  62. template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
  63. int k7, int k8, int k9>
  64. class TupleFields {
  65. public:
  66. typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
  67. GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
  68. GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
  69. GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
  70. GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
  71. GMOCK_FIELD_TYPE_(Tuple, k9)> type;
  72. static type GetSelectedFields(const Tuple& t) {
  73. return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
  74. get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
  75. }
  76. };
  77. // The following specialization is used for 0 ~ 9 selectors.
  78. template <class Tuple>
  79. class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
  80. public:
  81. typedef ::testing::tuple<> type;
  82. static type GetSelectedFields(const Tuple& /* t */) {
  83. return type();
  84. }
  85. };
  86. template <class Tuple, int k0>
  87. class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
  88. public:
  89. typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
  90. static type GetSelectedFields(const Tuple& t) {
  91. return type(get<k0>(t));
  92. }
  93. };
  94. template <class Tuple, int k0, int k1>
  95. class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
  96. public:
  97. typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
  98. GMOCK_FIELD_TYPE_(Tuple, k1)> type;
  99. static type GetSelectedFields(const Tuple& t) {
  100. return type(get<k0>(t), get<k1>(t));
  101. }
  102. };
  103. template <class Tuple, int k0, int k1, int k2>
  104. class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
  105. public:
  106. typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
  107. GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
  108. static type GetSelectedFields(const Tuple& t) {
  109. return type(get<k0>(t), get<k1>(t), get<k2>(t));
  110. }
  111. };
  112. template <class Tuple, int k0, int k1, int k2, int k3>
  113. class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
  114. public:
  115. typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
  116. GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
  117. GMOCK_FIELD_TYPE_(Tuple, k3)> type;
  118. static type GetSelectedFields(const Tuple& t) {
  119. return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
  120. }
  121. };
  122. template <class Tuple, int k0, int k1, int k2, int k3, int k4>
  123. class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
  124. public:
  125. typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
  126. GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
  127. GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
  128. static type GetSelectedFields(const Tuple& t) {
  129. return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
  130. }
  131. };
  132. template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
  133. class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
  134. public:
  135. typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
  136. GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
  137. GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
  138. GMOCK_FIELD_TYPE_(Tuple, k5)> type;
  139. static type GetSelectedFields(const Tuple& t) {
  140. return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
  141. get<k5>(t));
  142. }
  143. };
  144. template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
  145. class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
  146. public:
  147. typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
  148. GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
  149. GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
  150. GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
  151. static type GetSelectedFields(const Tuple& t) {
  152. return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
  153. get<k5>(t), get<k6>(t));
  154. }
  155. };
  156. template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
  157. int k7>
  158. class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
  159. public:
  160. typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
  161. GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
  162. GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
  163. GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
  164. GMOCK_FIELD_TYPE_(Tuple, k7)> type;
  165. static type GetSelectedFields(const Tuple& t) {
  166. return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
  167. get<k5>(t), get<k6>(t), get<k7>(t));
  168. }
  169. };
  170. template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
  171. int k7, int k8>
  172. class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
  173. public:
  174. typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
  175. GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
  176. GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
  177. GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
  178. GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
  179. static type GetSelectedFields(const Tuple& t) {
  180. return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
  181. get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
  182. }
  183. };
  184. #undef GMOCK_FIELD_TYPE_
  185. // Implements the Args() matcher.
  186. template <class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
  187. int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
  188. int k9 = -1>
  189. class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
  190. public:
  191. // ArgsTuple may have top-level const or reference modifiers.
  192. typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;
  193. typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,
  194. k6, k7, k8, k9>::type SelectedArgs;
  195. typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
  196. template <typename InnerMatcher>
  197. explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
  198. : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
  199. virtual bool MatchAndExplain(ArgsTuple args,
  200. MatchResultListener* listener) const {
  201. const SelectedArgs& selected_args = GetSelectedArgs(args);
  202. if (!listener->IsInterested())
  203. return inner_matcher_.Matches(selected_args);
  204. PrintIndices(listener->stream());
  205. *listener << "are " << PrintToString(selected_args);
  206. StringMatchResultListener inner_listener;
  207. const bool match = inner_matcher_.MatchAndExplain(selected_args,
  208. &inner_listener);
  209. PrintIfNotEmpty(inner_listener.str(), listener->stream());
  210. return match;
  211. }
  212. virtual void DescribeTo(::std::ostream* os) const {
  213. *os << "are a tuple ";
  214. PrintIndices(os);
  215. inner_matcher_.DescribeTo(os);
  216. }
  217. virtual void DescribeNegationTo(::std::ostream* os) const {
  218. *os << "are a tuple ";
  219. PrintIndices(os);
  220. inner_matcher_.DescribeNegationTo(os);
  221. }
  222. private:
  223. static SelectedArgs GetSelectedArgs(ArgsTuple args) {
  224. return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
  225. k9>::GetSelectedFields(args);
  226. }
  227. // Prints the indices of the selected fields.
  228. static void PrintIndices(::std::ostream* os) {
  229. *os << "whose fields (";
  230. const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
  231. for (int i = 0; i < 10; i++) {
  232. if (indices[i] < 0)
  233. break;
  234. if (i >= 1)
  235. *os << ", ";
  236. *os << "#" << indices[i];
  237. }
  238. *os << ") ";
  239. }
  240. const MonomorphicInnerMatcher inner_matcher_;
  241. GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
  242. };
  243. template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
  244. int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,
  245. int k8 = -1, int k9 = -1>
  246. class ArgsMatcher {
  247. public:
  248. explicit ArgsMatcher(const InnerMatcher& inner_matcher)
  249. : inner_matcher_(inner_matcher) {}
  250. template <typename ArgsTuple>
  251. operator Matcher<ArgsTuple>() const {
  252. return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k5,
  253. k6, k7, k8, k9>(inner_matcher_));
  254. }
  255. private:
  256. const InnerMatcher inner_matcher_;
  257. GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
  258. };
  259. // A set of metafunctions for computing the result type of AllOf.
  260. // AllOf(m1, ..., mN) returns
  261. // AllOfResultN<decltype(m1), ..., decltype(mN)>::type.
  262. // Although AllOf isn't defined for one argument, AllOfResult1 is defined
  263. // to simplify the implementation.
  264. template <typename M1>
  265. struct AllOfResult1 {
  266. typedef M1 type;
  267. };
  268. template <typename M1, typename M2>
  269. struct AllOfResult2 {
  270. typedef BothOfMatcher<
  271. typename AllOfResult1<M1>::type,
  272. typename AllOfResult1<M2>::type
  273. > type;
  274. };
  275. template <typename M1, typename M2, typename M3>
  276. struct AllOfResult3 {
  277. typedef BothOfMatcher<
  278. typename AllOfResult1<M1>::type,
  279. typename AllOfResult2<M2, M3>::type
  280. > type;
  281. };
  282. template <typename M1, typename M2, typename M3, typename M4>
  283. struct AllOfResult4 {
  284. typedef BothOfMatcher<
  285. typename AllOfResult2<M1, M2>::type,
  286. typename AllOfResult2<M3, M4>::type
  287. > type;
  288. };
  289. template <typename M1, typename M2, typename M3, typename M4, typename M5>
  290. struct AllOfResult5 {
  291. typedef BothOfMatcher<
  292. typename AllOfResult2<M1, M2>::type,
  293. typename AllOfResult3<M3, M4, M5>::type
  294. > type;
  295. };
  296. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  297. typename M6>
  298. struct AllOfResult6 {
  299. typedef BothOfMatcher<
  300. typename AllOfResult3<M1, M2, M3>::type,
  301. typename AllOfResult3<M4, M5, M6>::type
  302. > type;
  303. };
  304. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  305. typename M6, typename M7>
  306. struct AllOfResult7 {
  307. typedef BothOfMatcher<
  308. typename AllOfResult3<M1, M2, M3>::type,
  309. typename AllOfResult4<M4, M5, M6, M7>::type
  310. > type;
  311. };
  312. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  313. typename M6, typename M7, typename M8>
  314. struct AllOfResult8 {
  315. typedef BothOfMatcher<
  316. typename AllOfResult4<M1, M2, M3, M4>::type,
  317. typename AllOfResult4<M5, M6, M7, M8>::type
  318. > type;
  319. };
  320. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  321. typename M6, typename M7, typename M8, typename M9>
  322. struct AllOfResult9 {
  323. typedef BothOfMatcher<
  324. typename AllOfResult4<M1, M2, M3, M4>::type,
  325. typename AllOfResult5<M5, M6, M7, M8, M9>::type
  326. > type;
  327. };
  328. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  329. typename M6, typename M7, typename M8, typename M9, typename M10>
  330. struct AllOfResult10 {
  331. typedef BothOfMatcher<
  332. typename AllOfResult5<M1, M2, M3, M4, M5>::type,
  333. typename AllOfResult5<M6, M7, M8, M9, M10>::type
  334. > type;
  335. };
  336. // A set of metafunctions for computing the result type of AnyOf.
  337. // AnyOf(m1, ..., mN) returns
  338. // AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.
  339. // Although AnyOf isn't defined for one argument, AnyOfResult1 is defined
  340. // to simplify the implementation.
  341. template <typename M1>
  342. struct AnyOfResult1 {
  343. typedef M1 type;
  344. };
  345. template <typename M1, typename M2>
  346. struct AnyOfResult2 {
  347. typedef EitherOfMatcher<
  348. typename AnyOfResult1<M1>::type,
  349. typename AnyOfResult1<M2>::type
  350. > type;
  351. };
  352. template <typename M1, typename M2, typename M3>
  353. struct AnyOfResult3 {
  354. typedef EitherOfMatcher<
  355. typename AnyOfResult1<M1>::type,
  356. typename AnyOfResult2<M2, M3>::type
  357. > type;
  358. };
  359. template <typename M1, typename M2, typename M3, typename M4>
  360. struct AnyOfResult4 {
  361. typedef EitherOfMatcher<
  362. typename AnyOfResult2<M1, M2>::type,
  363. typename AnyOfResult2<M3, M4>::type
  364. > type;
  365. };
  366. template <typename M1, typename M2, typename M3, typename M4, typename M5>
  367. struct AnyOfResult5 {
  368. typedef EitherOfMatcher<
  369. typename AnyOfResult2<M1, M2>::type,
  370. typename AnyOfResult3<M3, M4, M5>::type
  371. > type;
  372. };
  373. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  374. typename M6>
  375. struct AnyOfResult6 {
  376. typedef EitherOfMatcher<
  377. typename AnyOfResult3<M1, M2, M3>::type,
  378. typename AnyOfResult3<M4, M5, M6>::type
  379. > type;
  380. };
  381. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  382. typename M6, typename M7>
  383. struct AnyOfResult7 {
  384. typedef EitherOfMatcher<
  385. typename AnyOfResult3<M1, M2, M3>::type,
  386. typename AnyOfResult4<M4, M5, M6, M7>::type
  387. > type;
  388. };
  389. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  390. typename M6, typename M7, typename M8>
  391. struct AnyOfResult8 {
  392. typedef EitherOfMatcher<
  393. typename AnyOfResult4<M1, M2, M3, M4>::type,
  394. typename AnyOfResult4<M5, M6, M7, M8>::type
  395. > type;
  396. };
  397. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  398. typename M6, typename M7, typename M8, typename M9>
  399. struct AnyOfResult9 {
  400. typedef EitherOfMatcher<
  401. typename AnyOfResult4<M1, M2, M3, M4>::type,
  402. typename AnyOfResult5<M5, M6, M7, M8, M9>::type
  403. > type;
  404. };
  405. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  406. typename M6, typename M7, typename M8, typename M9, typename M10>
  407. struct AnyOfResult10 {
  408. typedef EitherOfMatcher<
  409. typename AnyOfResult5<M1, M2, M3, M4, M5>::type,
  410. typename AnyOfResult5<M6, M7, M8, M9, M10>::type
  411. > type;
  412. };
  413. } // namespace internal
  414. // Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
  415. // fields of it matches a_matcher. C++ doesn't support default
  416. // arguments for function templates, so we have to overload it.
  417. template <typename InnerMatcher>
  418. inline internal::ArgsMatcher<InnerMatcher>
  419. Args(const InnerMatcher& matcher) {
  420. return internal::ArgsMatcher<InnerMatcher>(matcher);
  421. }
  422. template <int k1, typename InnerMatcher>
  423. inline internal::ArgsMatcher<InnerMatcher, k1>
  424. Args(const InnerMatcher& matcher) {
  425. return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
  426. }
  427. template <int k1, int k2, typename InnerMatcher>
  428. inline internal::ArgsMatcher<InnerMatcher, k1, k2>
  429. Args(const InnerMatcher& matcher) {
  430. return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
  431. }
  432. template <int k1, int k2, int k3, typename InnerMatcher>
  433. inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
  434. Args(const InnerMatcher& matcher) {
  435. return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
  436. }
  437. template <int k1, int k2, int k3, int k4, typename InnerMatcher>
  438. inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
  439. Args(const InnerMatcher& matcher) {
  440. return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
  441. }
  442. template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
  443. inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
  444. Args(const InnerMatcher& matcher) {
  445. return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
  446. }
  447. template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
  448. inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
  449. Args(const InnerMatcher& matcher) {
  450. return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
  451. }
  452. template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
  453. typename InnerMatcher>
  454. inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
  455. Args(const InnerMatcher& matcher) {
  456. return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
  457. k7>(matcher);
  458. }
  459. template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
  460. typename InnerMatcher>
  461. inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
  462. Args(const InnerMatcher& matcher) {
  463. return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
  464. k8>(matcher);
  465. }
  466. template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
  467. int k9, typename InnerMatcher>
  468. inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
  469. Args(const InnerMatcher& matcher) {
  470. return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
  471. k9>(matcher);
  472. }
  473. template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
  474. int k9, int k10, typename InnerMatcher>
  475. inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
  476. k10>
  477. Args(const InnerMatcher& matcher) {
  478. return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
  479. k9, k10>(matcher);
  480. }
  481. // ElementsAre(e_1, e_2, ... e_n) matches an STL-style container with
  482. // n elements, where the i-th element in the container must
  483. // match the i-th argument in the list. Each argument of
  484. // ElementsAre() can be either a value or a matcher. We support up to
  485. // 10 arguments.
  486. //
  487. // The use of DecayArray in the implementation allows ElementsAre()
  488. // to accept string literals, whose type is const char[N], but we
  489. // want to treat them as const char*.
  490. //
  491. // NOTE: Since ElementsAre() cares about the order of the elements, it
  492. // must not be used with containers whose elements's order is
  493. // undefined (e.g. hash_map).
  494. inline internal::ElementsAreMatcher<
  495. ::testing::tuple<> >
  496. ElementsAre() {
  497. typedef ::testing::tuple<> Args;
  498. return internal::ElementsAreMatcher<Args>(Args());
  499. }
  500. template <typename T1>
  501. inline internal::ElementsAreMatcher<
  502. ::testing::tuple<
  503. typename internal::DecayArray<T1>::type> >
  504. ElementsAre(const T1& e1) {
  505. typedef ::testing::tuple<
  506. typename internal::DecayArray<T1>::type> Args;
  507. return internal::ElementsAreMatcher<Args>(Args(e1));
  508. }
  509. template <typename T1, typename T2>
  510. inline internal::ElementsAreMatcher<
  511. ::testing::tuple<
  512. typename internal::DecayArray<T1>::type,
  513. typename internal::DecayArray<T2>::type> >
  514. ElementsAre(const T1& e1, const T2& e2) {
  515. typedef ::testing::tuple<
  516. typename internal::DecayArray<T1>::type,
  517. typename internal::DecayArray<T2>::type> Args;
  518. return internal::ElementsAreMatcher<Args>(Args(e1, e2));
  519. }
  520. template <typename T1, typename T2, typename T3>
  521. inline internal::ElementsAreMatcher<
  522. ::testing::tuple<
  523. typename internal::DecayArray<T1>::type,
  524. typename internal::DecayArray<T2>::type,
  525. typename internal::DecayArray<T3>::type> >
  526. ElementsAre(const T1& e1, const T2& e2, const T3& e3) {
  527. typedef ::testing::tuple<
  528. typename internal::DecayArray<T1>::type,
  529. typename internal::DecayArray<T2>::type,
  530. typename internal::DecayArray<T3>::type> Args;
  531. return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3));
  532. }
  533. template <typename T1, typename T2, typename T3, typename T4>
  534. inline internal::ElementsAreMatcher<
  535. ::testing::tuple<
  536. typename internal::DecayArray<T1>::type,
  537. typename internal::DecayArray<T2>::type,
  538. typename internal::DecayArray<T3>::type,
  539. typename internal::DecayArray<T4>::type> >
  540. ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
  541. typedef ::testing::tuple<
  542. typename internal::DecayArray<T1>::type,
  543. typename internal::DecayArray<T2>::type,
  544. typename internal::DecayArray<T3>::type,
  545. typename internal::DecayArray<T4>::type> Args;
  546. return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4));
  547. }
  548. template <typename T1, typename T2, typename T3, typename T4, typename T5>
  549. inline internal::ElementsAreMatcher<
  550. ::testing::tuple<
  551. typename internal::DecayArray<T1>::type,
  552. typename internal::DecayArray<T2>::type,
  553. typename internal::DecayArray<T3>::type,
  554. typename internal::DecayArray<T4>::type,
  555. typename internal::DecayArray<T5>::type> >
  556. ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
  557. const T5& e5) {
  558. typedef ::testing::tuple<
  559. typename internal::DecayArray<T1>::type,
  560. typename internal::DecayArray<T2>::type,
  561. typename internal::DecayArray<T3>::type,
  562. typename internal::DecayArray<T4>::type,
  563. typename internal::DecayArray<T5>::type> Args;
  564. return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));
  565. }
  566. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  567. typename T6>
  568. inline internal::ElementsAreMatcher<
  569. ::testing::tuple<
  570. typename internal::DecayArray<T1>::type,
  571. typename internal::DecayArray<T2>::type,
  572. typename internal::DecayArray<T3>::type,
  573. typename internal::DecayArray<T4>::type,
  574. typename internal::DecayArray<T5>::type,
  575. typename internal::DecayArray<T6>::type> >
  576. ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
  577. const T5& e5, const T6& e6) {
  578. typedef ::testing::tuple<
  579. typename internal::DecayArray<T1>::type,
  580. typename internal::DecayArray<T2>::type,
  581. typename internal::DecayArray<T3>::type,
  582. typename internal::DecayArray<T4>::type,
  583. typename internal::DecayArray<T5>::type,
  584. typename internal::DecayArray<T6>::type> Args;
  585. return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6));
  586. }
  587. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  588. typename T6, typename T7>
  589. inline internal::ElementsAreMatcher<
  590. ::testing::tuple<
  591. typename internal::DecayArray<T1>::type,
  592. typename internal::DecayArray<T2>::type,
  593. typename internal::DecayArray<T3>::type,
  594. typename internal::DecayArray<T4>::type,
  595. typename internal::DecayArray<T5>::type,
  596. typename internal::DecayArray<T6>::type,
  597. typename internal::DecayArray<T7>::type> >
  598. ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
  599. const T5& e5, const T6& e6, const T7& e7) {
  600. typedef ::testing::tuple<
  601. typename internal::DecayArray<T1>::type,
  602. typename internal::DecayArray<T2>::type,
  603. typename internal::DecayArray<T3>::type,
  604. typename internal::DecayArray<T4>::type,
  605. typename internal::DecayArray<T5>::type,
  606. typename internal::DecayArray<T6>::type,
  607. typename internal::DecayArray<T7>::type> Args;
  608. return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7));
  609. }
  610. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  611. typename T6, typename T7, typename T8>
  612. inline internal::ElementsAreMatcher<
  613. ::testing::tuple<
  614. typename internal::DecayArray<T1>::type,
  615. typename internal::DecayArray<T2>::type,
  616. typename internal::DecayArray<T3>::type,
  617. typename internal::DecayArray<T4>::type,
  618. typename internal::DecayArray<T5>::type,
  619. typename internal::DecayArray<T6>::type,
  620. typename internal::DecayArray<T7>::type,
  621. typename internal::DecayArray<T8>::type> >
  622. ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
  623. const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
  624. typedef ::testing::tuple<
  625. typename internal::DecayArray<T1>::type,
  626. typename internal::DecayArray<T2>::type,
  627. typename internal::DecayArray<T3>::type,
  628. typename internal::DecayArray<T4>::type,
  629. typename internal::DecayArray<T5>::type,
  630. typename internal::DecayArray<T6>::type,
  631. typename internal::DecayArray<T7>::type,
  632. typename internal::DecayArray<T8>::type> Args;
  633. return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
  634. e8));
  635. }
  636. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  637. typename T6, typename T7, typename T8, typename T9>
  638. inline internal::ElementsAreMatcher<
  639. ::testing::tuple<
  640. typename internal::DecayArray<T1>::type,
  641. typename internal::DecayArray<T2>::type,
  642. typename internal::DecayArray<T3>::type,
  643. typename internal::DecayArray<T4>::type,
  644. typename internal::DecayArray<T5>::type,
  645. typename internal::DecayArray<T6>::type,
  646. typename internal::DecayArray<T7>::type,
  647. typename internal::DecayArray<T8>::type,
  648. typename internal::DecayArray<T9>::type> >
  649. ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
  650. const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
  651. typedef ::testing::tuple<
  652. typename internal::DecayArray<T1>::type,
  653. typename internal::DecayArray<T2>::type,
  654. typename internal::DecayArray<T3>::type,
  655. typename internal::DecayArray<T4>::type,
  656. typename internal::DecayArray<T5>::type,
  657. typename internal::DecayArray<T6>::type,
  658. typename internal::DecayArray<T7>::type,
  659. typename internal::DecayArray<T8>::type,
  660. typename internal::DecayArray<T9>::type> Args;
  661. return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
  662. e8, e9));
  663. }
  664. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  665. typename T6, typename T7, typename T8, typename T9, typename T10>
  666. inline internal::ElementsAreMatcher<
  667. ::testing::tuple<
  668. typename internal::DecayArray<T1>::type,
  669. typename internal::DecayArray<T2>::type,
  670. typename internal::DecayArray<T3>::type,
  671. typename internal::DecayArray<T4>::type,
  672. typename internal::DecayArray<T5>::type,
  673. typename internal::DecayArray<T6>::type,
  674. typename internal::DecayArray<T7>::type,
  675. typename internal::DecayArray<T8>::type,
  676. typename internal::DecayArray<T9>::type,
  677. typename internal::DecayArray<T10>::type> >
  678. ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
  679. const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
  680. const T10& e10) {
  681. typedef ::testing::tuple<
  682. typename internal::DecayArray<T1>::type,
  683. typename internal::DecayArray<T2>::type,
  684. typename internal::DecayArray<T3>::type,
  685. typename internal::DecayArray<T4>::type,
  686. typename internal::DecayArray<T5>::type,
  687. typename internal::DecayArray<T6>::type,
  688. typename internal::DecayArray<T7>::type,
  689. typename internal::DecayArray<T8>::type,
  690. typename internal::DecayArray<T9>::type,
  691. typename internal::DecayArray<T10>::type> Args;
  692. return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
  693. e8, e9, e10));
  694. }
  695. // UnorderedElementsAre(e_1, e_2, ..., e_n) is an ElementsAre extension
  696. // that matches n elements in any order. We support up to n=10 arguments.
  697. inline internal::UnorderedElementsAreMatcher<
  698. ::testing::tuple<> >
  699. UnorderedElementsAre() {
  700. typedef ::testing::tuple<> Args;
  701. return internal::UnorderedElementsAreMatcher<Args>(Args());
  702. }
  703. template <typename T1>
  704. inline internal::UnorderedElementsAreMatcher<
  705. ::testing::tuple<
  706. typename internal::DecayArray<T1>::type> >
  707. UnorderedElementsAre(const T1& e1) {
  708. typedef ::testing::tuple<
  709. typename internal::DecayArray<T1>::type> Args;
  710. return internal::UnorderedElementsAreMatcher<Args>(Args(e1));
  711. }
  712. template <typename T1, typename T2>
  713. inline internal::UnorderedElementsAreMatcher<
  714. ::testing::tuple<
  715. typename internal::DecayArray<T1>::type,
  716. typename internal::DecayArray<T2>::type> >
  717. UnorderedElementsAre(const T1& e1, const T2& e2) {
  718. typedef ::testing::tuple<
  719. typename internal::DecayArray<T1>::type,
  720. typename internal::DecayArray<T2>::type> Args;
  721. return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2));
  722. }
  723. template <typename T1, typename T2, typename T3>
  724. inline internal::UnorderedElementsAreMatcher<
  725. ::testing::tuple<
  726. typename internal::DecayArray<T1>::type,
  727. typename internal::DecayArray<T2>::type,
  728. typename internal::DecayArray<T3>::type> >
  729. UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3) {
  730. typedef ::testing::tuple<
  731. typename internal::DecayArray<T1>::type,
  732. typename internal::DecayArray<T2>::type,
  733. typename internal::DecayArray<T3>::type> Args;
  734. return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3));
  735. }
  736. template <typename T1, typename T2, typename T3, typename T4>
  737. inline internal::UnorderedElementsAreMatcher<
  738. ::testing::tuple<
  739. typename internal::DecayArray<T1>::type,
  740. typename internal::DecayArray<T2>::type,
  741. typename internal::DecayArray<T3>::type,
  742. typename internal::DecayArray<T4>::type> >
  743. UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
  744. typedef ::testing::tuple<
  745. typename internal::DecayArray<T1>::type,
  746. typename internal::DecayArray<T2>::type,
  747. typename internal::DecayArray<T3>::type,
  748. typename internal::DecayArray<T4>::type> Args;
  749. return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4));
  750. }
  751. template <typename T1, typename T2, typename T3, typename T4, typename T5>
  752. inline internal::UnorderedElementsAreMatcher<
  753. ::testing::tuple<
  754. typename internal::DecayArray<T1>::type,
  755. typename internal::DecayArray<T2>::type,
  756. typename internal::DecayArray<T3>::type,
  757. typename internal::DecayArray<T4>::type,
  758. typename internal::DecayArray<T5>::type> >
  759. UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
  760. const T5& e5) {
  761. typedef ::testing::tuple<
  762. typename internal::DecayArray<T1>::type,
  763. typename internal::DecayArray<T2>::type,
  764. typename internal::DecayArray<T3>::type,
  765. typename internal::DecayArray<T4>::type,
  766. typename internal::DecayArray<T5>::type> Args;
  767. return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));
  768. }
  769. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  770. typename T6>
  771. inline internal::UnorderedElementsAreMatcher<
  772. ::testing::tuple<
  773. typename internal::DecayArray<T1>::type,
  774. typename internal::DecayArray<T2>::type,
  775. typename internal::DecayArray<T3>::type,
  776. typename internal::DecayArray<T4>::type,
  777. typename internal::DecayArray<T5>::type,
  778. typename internal::DecayArray<T6>::type> >
  779. UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
  780. const T5& e5, const T6& e6) {
  781. typedef ::testing::tuple<
  782. typename internal::DecayArray<T1>::type,
  783. typename internal::DecayArray<T2>::type,
  784. typename internal::DecayArray<T3>::type,
  785. typename internal::DecayArray<T4>::type,
  786. typename internal::DecayArray<T5>::type,
  787. typename internal::DecayArray<T6>::type> Args;
  788. return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
  789. e6));
  790. }
  791. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  792. typename T6, typename T7>
  793. inline internal::UnorderedElementsAreMatcher<
  794. ::testing::tuple<
  795. typename internal::DecayArray<T1>::type,
  796. typename internal::DecayArray<T2>::type,
  797. typename internal::DecayArray<T3>::type,
  798. typename internal::DecayArray<T4>::type,
  799. typename internal::DecayArray<T5>::type,
  800. typename internal::DecayArray<T6>::type,
  801. typename internal::DecayArray<T7>::type> >
  802. UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
  803. const T5& e5, const T6& e6, const T7& e7) {
  804. typedef ::testing::tuple<
  805. typename internal::DecayArray<T1>::type,
  806. typename internal::DecayArray<T2>::type,
  807. typename internal::DecayArray<T3>::type,
  808. typename internal::DecayArray<T4>::type,
  809. typename internal::DecayArray<T5>::type,
  810. typename internal::DecayArray<T6>::type,
  811. typename internal::DecayArray<T7>::type> Args;
  812. return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
  813. e6, e7));
  814. }
  815. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  816. typename T6, typename T7, typename T8>
  817. inline internal::UnorderedElementsAreMatcher<
  818. ::testing::tuple<
  819. typename internal::DecayArray<T1>::type,
  820. typename internal::DecayArray<T2>::type,
  821. typename internal::DecayArray<T3>::type,
  822. typename internal::DecayArray<T4>::type,
  823. typename internal::DecayArray<T5>::type,
  824. typename internal::DecayArray<T6>::type,
  825. typename internal::DecayArray<T7>::type,
  826. typename internal::DecayArray<T8>::type> >
  827. UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
  828. const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
  829. typedef ::testing::tuple<
  830. typename internal::DecayArray<T1>::type,
  831. typename internal::DecayArray<T2>::type,
  832. typename internal::DecayArray<T3>::type,
  833. typename internal::DecayArray<T4>::type,
  834. typename internal::DecayArray<T5>::type,
  835. typename internal::DecayArray<T6>::type,
  836. typename internal::DecayArray<T7>::type,
  837. typename internal::DecayArray<T8>::type> Args;
  838. return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
  839. e6, e7, e8));
  840. }
  841. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  842. typename T6, typename T7, typename T8, typename T9>
  843. inline internal::UnorderedElementsAreMatcher<
  844. ::testing::tuple<
  845. typename internal::DecayArray<T1>::type,
  846. typename internal::DecayArray<T2>::type,
  847. typename internal::DecayArray<T3>::type,
  848. typename internal::DecayArray<T4>::type,
  849. typename internal::DecayArray<T5>::type,
  850. typename internal::DecayArray<T6>::type,
  851. typename internal::DecayArray<T7>::type,
  852. typename internal::DecayArray<T8>::type,
  853. typename internal::DecayArray<T9>::type> >
  854. UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
  855. const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
  856. typedef ::testing::tuple<
  857. typename internal::DecayArray<T1>::type,
  858. typename internal::DecayArray<T2>::type,
  859. typename internal::DecayArray<T3>::type,
  860. typename internal::DecayArray<T4>::type,
  861. typename internal::DecayArray<T5>::type,
  862. typename internal::DecayArray<T6>::type,
  863. typename internal::DecayArray<T7>::type,
  864. typename internal::DecayArray<T8>::type,
  865. typename internal::DecayArray<T9>::type> Args;
  866. return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
  867. e6, e7, e8, e9));
  868. }
  869. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  870. typename T6, typename T7, typename T8, typename T9, typename T10>
  871. inline internal::UnorderedElementsAreMatcher<
  872. ::testing::tuple<
  873. typename internal::DecayArray<T1>::type,
  874. typename internal::DecayArray<T2>::type,
  875. typename internal::DecayArray<T3>::type,
  876. typename internal::DecayArray<T4>::type,
  877. typename internal::DecayArray<T5>::type,
  878. typename internal::DecayArray<T6>::type,
  879. typename internal::DecayArray<T7>::type,
  880. typename internal::DecayArray<T8>::type,
  881. typename internal::DecayArray<T9>::type,
  882. typename internal::DecayArray<T10>::type> >
  883. UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
  884. const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
  885. const T10& e10) {
  886. typedef ::testing::tuple<
  887. typename internal::DecayArray<T1>::type,
  888. typename internal::DecayArray<T2>::type,
  889. typename internal::DecayArray<T3>::type,
  890. typename internal::DecayArray<T4>::type,
  891. typename internal::DecayArray<T5>::type,
  892. typename internal::DecayArray<T6>::type,
  893. typename internal::DecayArray<T7>::type,
  894. typename internal::DecayArray<T8>::type,
  895. typename internal::DecayArray<T9>::type,
  896. typename internal::DecayArray<T10>::type> Args;
  897. return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
  898. e6, e7, e8, e9, e10));
  899. }
  900. // AllOf(m1, m2, ..., mk) matches any value that matches all of the given
  901. // sub-matchers. AllOf is called fully qualified to prevent ADL from firing.
  902. template <typename M1, typename M2>
  903. inline typename internal::AllOfResult2<M1, M2>::type
  904. AllOf(M1 m1, M2 m2) {
  905. return typename internal::AllOfResult2<M1, M2>::type(
  906. m1,
  907. m2);
  908. }
  909. template <typename M1, typename M2, typename M3>
  910. inline typename internal::AllOfResult3<M1, M2, M3>::type
  911. AllOf(M1 m1, M2 m2, M3 m3) {
  912. return typename internal::AllOfResult3<M1, M2, M3>::type(
  913. m1,
  914. ::testing::AllOf(m2, m3));
  915. }
  916. template <typename M1, typename M2, typename M3, typename M4>
  917. inline typename internal::AllOfResult4<M1, M2, M3, M4>::type
  918. AllOf(M1 m1, M2 m2, M3 m3, M4 m4) {
  919. return typename internal::AllOfResult4<M1, M2, M3, M4>::type(
  920. ::testing::AllOf(m1, m2),
  921. ::testing::AllOf(m3, m4));
  922. }
  923. template <typename M1, typename M2, typename M3, typename M4, typename M5>
  924. inline typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type
  925. AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
  926. return typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type(
  927. ::testing::AllOf(m1, m2),
  928. ::testing::AllOf(m3, m4, m5));
  929. }
  930. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  931. typename M6>
  932. inline typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type
  933. AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
  934. return typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type(
  935. ::testing::AllOf(m1, m2, m3),
  936. ::testing::AllOf(m4, m5, m6));
  937. }
  938. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  939. typename M6, typename M7>
  940. inline typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
  941. AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
  942. return typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
  943. ::testing::AllOf(m1, m2, m3),
  944. ::testing::AllOf(m4, m5, m6, m7));
  945. }
  946. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  947. typename M6, typename M7, typename M8>
  948. inline typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
  949. AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
  950. return typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
  951. ::testing::AllOf(m1, m2, m3, m4),
  952. ::testing::AllOf(m5, m6, m7, m8));
  953. }
  954. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  955. typename M6, typename M7, typename M8, typename M9>
  956. inline typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
  957. AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
  958. return typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
  959. M9>::type(
  960. ::testing::AllOf(m1, m2, m3, m4),
  961. ::testing::AllOf(m5, m6, m7, m8, m9));
  962. }
  963. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  964. typename M6, typename M7, typename M8, typename M9, typename M10>
  965. inline typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
  966. M10>::type
  967. AllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
  968. return typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
  969. M10>::type(
  970. ::testing::AllOf(m1, m2, m3, m4, m5),
  971. ::testing::AllOf(m6, m7, m8, m9, m10));
  972. }
  973. // AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
  974. // sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
  975. template <typename M1, typename M2>
  976. inline typename internal::AnyOfResult2<M1, M2>::type
  977. AnyOf(M1 m1, M2 m2) {
  978. return typename internal::AnyOfResult2<M1, M2>::type(
  979. m1,
  980. m2);
  981. }
  982. template <typename M1, typename M2, typename M3>
  983. inline typename internal::AnyOfResult3<M1, M2, M3>::type
  984. AnyOf(M1 m1, M2 m2, M3 m3) {
  985. return typename internal::AnyOfResult3<M1, M2, M3>::type(
  986. m1,
  987. ::testing::AnyOf(m2, m3));
  988. }
  989. template <typename M1, typename M2, typename M3, typename M4>
  990. inline typename internal::AnyOfResult4<M1, M2, M3, M4>::type
  991. AnyOf(M1 m1, M2 m2, M3 m3, M4 m4) {
  992. return typename internal::AnyOfResult4<M1, M2, M3, M4>::type(
  993. ::testing::AnyOf(m1, m2),
  994. ::testing::AnyOf(m3, m4));
  995. }
  996. template <typename M1, typename M2, typename M3, typename M4, typename M5>
  997. inline typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type
  998. AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
  999. return typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type(
  1000. ::testing::AnyOf(m1, m2),
  1001. ::testing::AnyOf(m3, m4, m5));
  1002. }
  1003. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  1004. typename M6>
  1005. inline typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type
  1006. AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
  1007. return typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type(
  1008. ::testing::AnyOf(m1, m2, m3),
  1009. ::testing::AnyOf(m4, m5, m6));
  1010. }
  1011. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  1012. typename M6, typename M7>
  1013. inline typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
  1014. AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
  1015. return typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
  1016. ::testing::AnyOf(m1, m2, m3),
  1017. ::testing::AnyOf(m4, m5, m6, m7));
  1018. }
  1019. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  1020. typename M6, typename M7, typename M8>
  1021. inline typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
  1022. AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
  1023. return typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
  1024. ::testing::AnyOf(m1, m2, m3, m4),
  1025. ::testing::AnyOf(m5, m6, m7, m8));
  1026. }
  1027. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  1028. typename M6, typename M7, typename M8, typename M9>
  1029. inline typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
  1030. AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
  1031. return typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
  1032. M9>::type(
  1033. ::testing::AnyOf(m1, m2, m3, m4),
  1034. ::testing::AnyOf(m5, m6, m7, m8, m9));
  1035. }
  1036. template <typename M1, typename M2, typename M3, typename M4, typename M5,
  1037. typename M6, typename M7, typename M8, typename M9, typename M10>
  1038. inline typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
  1039. M10>::type
  1040. AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
  1041. return typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
  1042. M10>::type(
  1043. ::testing::AnyOf(m1, m2, m3, m4, m5),
  1044. ::testing::AnyOf(m6, m7, m8, m9, m10));
  1045. }
  1046. } // namespace testing
  1047. // The MATCHER* family of macros can be used in a namespace scope to
  1048. // define custom matchers easily.
  1049. //
  1050. // Basic Usage
  1051. // ===========
  1052. //
  1053. // The syntax
  1054. //
  1055. // MATCHER(name, description_string) { statements; }
  1056. //
  1057. // defines a matcher with the given name that executes the statements,
  1058. // which must return a bool to indicate if the match succeeds. Inside
  1059. // the statements, you can refer to the value being matched by 'arg',
  1060. // and refer to its type by 'arg_type'.
  1061. //
  1062. // The description string documents what the matcher does, and is used
  1063. // to generate the failure message when the match fails. Since a
  1064. // MATCHER() is usually defined in a header file shared by multiple
  1065. // C++ source files, we require the description to be a C-string
  1066. // literal to avoid possible side effects. It can be empty, in which
  1067. // case we'll use the sequence of words in the matcher name as the
  1068. // description.
  1069. //
  1070. // For example:
  1071. //
  1072. // MATCHER(IsEven, "") { return (arg % 2) == 0; }
  1073. //
  1074. // allows you to write
  1075. //
  1076. // // Expects mock_foo.Bar(n) to be called where n is even.
  1077. // EXPECT_CALL(mock_foo, Bar(IsEven()));
  1078. //
  1079. // or,
  1080. //
  1081. // // Verifies that the value of some_expression is even.
  1082. // EXPECT_THAT(some_expression, IsEven());
  1083. //
  1084. // If the above assertion fails, it will print something like:
  1085. //
  1086. // Value of: some_expression
  1087. // Expected: is even
  1088. // Actual: 7
  1089. //
  1090. // where the description "is even" is automatically calculated from the
  1091. // matcher name IsEven.
  1092. //
  1093. // Argument Type
  1094. // =============
  1095. //
  1096. // Note that the type of the value being matched (arg_type) is
  1097. // determined by the context in which you use the matcher and is
  1098. // supplied to you by the compiler, so you don't need to worry about
  1099. // declaring it (nor can you). This allows the matcher to be
  1100. // polymorphic. For example, IsEven() can be used to match any type
  1101. // where the value of "(arg % 2) == 0" can be implicitly converted to
  1102. // a bool. In the "Bar(IsEven())" example above, if method Bar()
  1103. // takes an int, 'arg_type' will be int; if it takes an unsigned long,
  1104. // 'arg_type' will be unsigned long; and so on.
  1105. //
  1106. // Parameterizing Matchers
  1107. // =======================
  1108. //
  1109. // Sometimes you'll want to parameterize the matcher. For that you
  1110. // can use another macro:
  1111. //
  1112. // MATCHER_P(name, param_name, description_string) { statements; }
  1113. //
  1114. // For example:
  1115. //
  1116. // MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
  1117. //
  1118. // will allow you to write:
  1119. //
  1120. // EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
  1121. //
  1122. // which may lead to this message (assuming n is 10):
  1123. //
  1124. // Value of: Blah("a")
  1125. // Expected: has absolute value 10
  1126. // Actual: -9
  1127. //
  1128. // Note that both the matcher description and its parameter are
  1129. // printed, making the message human-friendly.
  1130. //
  1131. // In the matcher definition body, you can write 'foo_type' to
  1132. // reference the type of a parameter named 'foo'. For example, in the
  1133. // body of MATCHER_P(HasAbsoluteValue, value) above, you can write
  1134. // 'value_type' to refer to the type of 'value'.
  1135. //
  1136. // We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
  1137. // support multi-parameter matchers.
  1138. //
  1139. // Describing Parameterized Matchers
  1140. // =================================
  1141. //
  1142. // The last argument to MATCHER*() is a string-typed expression. The
  1143. // expression can reference all of the matcher's parameters and a
  1144. // special bool-typed variable named 'negation'. When 'negation' is
  1145. // false, the expression should evaluate to the matcher's description;
  1146. // otherwise it should evaluate to the description of the negation of
  1147. // the matcher. For example,
  1148. //
  1149. // using testing::PrintToString;
  1150. //
  1151. // MATCHER_P2(InClosedRange, low, hi,
  1152. // string(negation ? "is not" : "is") + " in range [" +
  1153. // PrintToString(low) + ", " + PrintToString(hi) + "]") {
  1154. // return low <= arg && arg <= hi;
  1155. // }
  1156. // ...
  1157. // EXPECT_THAT(3, InClosedRange(4, 6));
  1158. // EXPECT_THAT(3, Not(InClosedRange(2, 4)));
  1159. //
  1160. // would generate two failures that contain the text:
  1161. //
  1162. // Expected: is in range [4, 6]
  1163. // ...
  1164. // Expected: is not in range [2, 4]
  1165. //
  1166. // If you specify "" as the description, the failure message will
  1167. // contain the sequence of words in the matcher name followed by the
  1168. // parameter values printed as a tuple. For example,
  1169. //
  1170. // MATCHER_P2(InClosedRange, low, hi, "") { ... }
  1171. // ...
  1172. // EXPECT_THAT(3, InClosedRange(4, 6));
  1173. // EXPECT_THAT(3, Not(InClosedRange(2, 4)));
  1174. //
  1175. // would generate two failures that contain the text:
  1176. //
  1177. // Expected: in closed range (4, 6)
  1178. // ...
  1179. // Expected: not (in closed range (2, 4))
  1180. //
  1181. // Types of Matcher Parameters
  1182. // ===========================
  1183. //
  1184. // For the purpose of typing, you can view
  1185. //
  1186. // MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
  1187. //
  1188. // as shorthand for
  1189. //
  1190. // template <typename p1_type, ..., typename pk_type>
  1191. // FooMatcherPk<p1_type, ..., pk_type>
  1192. // Foo(p1_type p1, ..., pk_type pk) { ... }
  1193. //
  1194. // When you write Foo(v1, ..., vk), the compiler infers the types of
  1195. // the parameters v1, ..., and vk for you. If you are not happy with
  1196. // the result of the type inference, you can specify the types by
  1197. // explicitly instantiating the template, as in Foo<long, bool>(5,
  1198. // false). As said earlier, you don't get to (or need to) specify
  1199. // 'arg_type' as that's determined by the context in which the matcher
  1200. // is used. You can assign the result of expression Foo(p1, ..., pk)
  1201. // to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
  1202. // can be useful when composing matchers.
  1203. //
  1204. // While you can instantiate a matcher template with reference types,
  1205. // passing the parameters by pointer usually makes your code more
  1206. // readable. If, however, you still want to pass a parameter by
  1207. // reference, be aware that in the failure message generated by the
  1208. // matcher you will see the value of the referenced object but not its
  1209. // address.
  1210. //
  1211. // Explaining Match Results
  1212. // ========================
  1213. //
  1214. // Sometimes the matcher description alone isn't enough to explain why
  1215. // the match has failed or succeeded. For example, when expecting a
  1216. // long string, it can be very helpful to also print the diff between
  1217. // the expected string and the actual one. To achieve that, you can
  1218. // optionally stream additional information to a special variable
  1219. // named result_listener, whose type is a pointer to class
  1220. // MatchResultListener:
  1221. //
  1222. // MATCHER_P(EqualsLongString, str, "") {
  1223. // if (arg == str) return true;
  1224. //
  1225. // *result_listener << "the difference: "
  1226. /// << DiffStrings(str, arg);
  1227. // return false;
  1228. // }
  1229. //
  1230. // Overloading Matchers
  1231. // ====================
  1232. //
  1233. // You can overload matchers with different numbers of parameters:
  1234. //
  1235. // MATCHER_P(Blah, a, description_string1) { ... }
  1236. // MATCHER_P2(Blah, a, b, description_string2) { ... }
  1237. //
  1238. // Caveats
  1239. // =======
  1240. //
  1241. // When defining a new matcher, you should also consider implementing
  1242. // MatcherInterface or using MakePolymorphicMatcher(). These
  1243. // approaches require more work than the MATCHER* macros, but also
  1244. // give you more control on the types of the value being matched and
  1245. // the matcher parameters, which may leads to better compiler error
  1246. // messages when the matcher is used wrong. They also allow
  1247. // overloading matchers based on parameter types (as opposed to just
  1248. // based on the number of parameters).
  1249. //
  1250. // MATCHER*() can only be used in a namespace scope. The reason is
  1251. // that C++ doesn't yet allow function-local types to be used to
  1252. // instantiate templates. The up-coming C++0x standard will fix this.
  1253. // Once that's done, we'll consider supporting using MATCHER*() inside
  1254. // a function.
  1255. //
  1256. // More Information
  1257. // ================
  1258. //
  1259. // To learn more about using these macros, please search for 'MATCHER'
  1260. // on http://code.google.com/p/googlemock/wiki/CookBook.
  1261. #define MATCHER(name, description)\
  1262. class name##Matcher {\
  1263. public:\
  1264. template <typename arg_type>\
  1265. class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
  1266. public:\
  1267. gmock_Impl()\
  1268. {}\
  1269. virtual bool MatchAndExplain(\
  1270. arg_type arg, ::testing::MatchResultListener* result_listener) const;\
  1271. virtual void DescribeTo(::std::ostream* gmock_os) const {\
  1272. *gmock_os << FormatDescription(false);\
  1273. }\
  1274. virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
  1275. *gmock_os << FormatDescription(true);\
  1276. }\
  1277. private:\
  1278. ::testing::internal::string FormatDescription(bool negation) const {\
  1279. const ::testing::internal::string gmock_description = (description);\
  1280. if (!gmock_description.empty())\
  1281. return gmock_description;\
  1282. return ::testing::internal::FormatMatcherDescription(\
  1283. negation, #name, \
  1284. ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
  1285. ::testing::tuple<>()));\
  1286. }\
  1287. GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
  1288. };\
  1289. template <typename arg_type>\
  1290. operator ::testing::Matcher<arg_type>() const {\
  1291. return ::testing::Matcher<arg_type>(\
  1292. new gmock_Impl<arg_type>());\
  1293. }\
  1294. name##Matcher() {\
  1295. }\
  1296. private:\
  1297. GTEST_DISALLOW_ASSIGN_(name##Matcher);\
  1298. };\
  1299. inline name##Matcher name() {\
  1300. return name##Matcher();\
  1301. }\
  1302. template <typename arg_type>\
  1303. bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
  1304. arg_type arg, \
  1305. ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
  1306. const
  1307. #define MATCHER_P(name, p0, description)\
  1308. template <typename p0##_type>\
  1309. class name##MatcherP {\
  1310. public:\
  1311. template <typename arg_type>\
  1312. class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
  1313. public:\
  1314. explicit gmock_Impl(p0##_type gmock_p0)\
  1315. : p0(gmock_p0) {}\
  1316. virtual bool MatchAndExplain(\
  1317. arg_type arg, ::testing::MatchResultListener* result_listener) const;\
  1318. virtual void DescribeTo(::std::ostream* gmock_os) const {\
  1319. *gmock_os << FormatDescription(false);\
  1320. }\
  1321. virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
  1322. *gmock_os << FormatDescription(true);\
  1323. }\
  1324. p0##_type p0;\
  1325. private:\
  1326. ::testing::internal::string FormatDescription(bool negation) const {\
  1327. const ::testing::internal::string gmock_description = (description);\
  1328. if (!gmock_description.empty())\
  1329. return gmock_description;\
  1330. return ::testing::internal::FormatMatcherDescription(\
  1331. negation, #name, \
  1332. ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
  1333. ::testing::tuple<p0##_type>(p0)));\
  1334. }\
  1335. GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
  1336. };\
  1337. template <typename arg_type>\
  1338. operator ::testing::Matcher<arg_type>() const {\
  1339. return ::testing::Matcher<arg_type>(\
  1340. new gmock_Impl<arg_type>(p0));\
  1341. }\
  1342. explicit name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
  1343. }\
  1344. p0##_type p0;\
  1345. private:\
  1346. GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
  1347. };\
  1348. template <typename p0##_type>\
  1349. inline name##MatcherP<p0##_type> name(p0##_type p0) {\
  1350. return name##MatcherP<p0##_type>(p0);\
  1351. }\
  1352. template <typename p0##_type>\
  1353. template <typename arg_type>\
  1354. bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
  1355. arg_type arg, \
  1356. ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
  1357. const
  1358. #define MATCHER_P2(name, p0, p1, description)\
  1359. template <typename p0##_type, typename p1##_type>\
  1360. class name##MatcherP2 {\
  1361. public:\
  1362. template <typename arg_type>\
  1363. class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
  1364. public:\
  1365. gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
  1366. : p0(gmock_p0), p1(gmock_p1) {}\
  1367. virtual bool MatchAndExplain(\
  1368. arg_type arg, ::testing::MatchResultListener* result_listener) const;\
  1369. virtual void DescribeTo(::std::ostream* gmock_os) const {\
  1370. *gmock_os << FormatDescription(false);\
  1371. }\
  1372. virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
  1373. *gmock_os << FormatDescription(true);\
  1374. }\
  1375. p0##_type p0;\
  1376. p1##_type p1;\
  1377. private:\
  1378. ::testing::internal::string FormatDescription(bool negation) const {\
  1379. const ::testing::internal::string gmock_description = (description);\
  1380. if (!gmock_description.empty())\
  1381. return gmock_description;\
  1382. return ::testing::internal::FormatMatcherDescription(\
  1383. negation, #name, \
  1384. ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
  1385. ::testing::tuple<p0##_type, p1##_type>(p0, p1)));\
  1386. }\
  1387. GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
  1388. };\
  1389. template <typename arg_type>\
  1390. operator ::testing::Matcher<arg_type>() const {\
  1391. return ::testing::Matcher<arg_type>(\
  1392. new gmock_Impl<arg_type>(p0, p1));\
  1393. }\
  1394. name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
  1395. p1(gmock_p1) {\
  1396. }\
  1397. p0##_type p0;\
  1398. p1##_type p1;\
  1399. private:\
  1400. GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
  1401. };\
  1402. template <typename p0##_type, typename p1##_type>\
  1403. inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
  1404. p1##_type p1) {\
  1405. return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
  1406. }\
  1407. template <typename p0##_type, typename p1##_type>\
  1408. template <typename arg_type>\
  1409. bool name##MatcherP2<p0##_type, \
  1410. p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
  1411. arg_type arg, \
  1412. ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
  1413. const
  1414. #define MATCHER_P3(name, p0, p1, p2, description)\
  1415. template <typename p0##_type, typename p1##_type, typename p2##_type>\
  1416. class name##MatcherP3 {\
  1417. public:\
  1418. template <typename arg_type>\
  1419. class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
  1420. public:\
  1421. gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
  1422. : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
  1423. virtual bool MatchAndExplain(\
  1424. arg_type arg, ::testing::MatchResultListener* result_listener) const;\
  1425. virtual void DescribeTo(::std::ostream* gmock_os) const {\
  1426. *gmock_os << FormatDescription(false);\
  1427. }\
  1428. virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
  1429. *gmock_os << FormatDescription(true);\
  1430. }\
  1431. p0##_type p0;\
  1432. p1##_type p1;\
  1433. p2##_type p2;\
  1434. private:\
  1435. ::testing::internal::string FormatDescription(bool negation) const {\
  1436. const ::testing::internal::string gmock_description = (description);\
  1437. if (!gmock_description.empty())\
  1438. return gmock_description;\
  1439. return ::testing::internal::FormatMatcherDescription(\
  1440. negation, #name, \
  1441. ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
  1442. ::testing::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
  1443. p2)));\
  1444. }\
  1445. GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
  1446. };\
  1447. template <typename arg_type>\
  1448. operator ::testing::Matcher<arg_type>() const {\
  1449. return ::testing::Matcher<arg_type>(\
  1450. new gmock_Impl<arg_type>(p0, p1, p2));\
  1451. }\
  1452. name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
  1453. p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
  1454. }\
  1455. p0##_type p0;\
  1456. p1##_type p1;\
  1457. p2##_type p2;\
  1458. private:\
  1459. GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
  1460. };\
  1461. template <typename p0##_type, typename p1##_type, typename p2##_type>\
  1462. inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
  1463. p1##_type p1, p2##_type p2) {\
  1464. return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
  1465. }\
  1466. template <typename p0##_type, typename p1##_type, typename p2##_type>\
  1467. template <typename arg_type>\
  1468. bool name##MatcherP3<p0##_type, p1##_type, \
  1469. p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
  1470. arg_type arg, \
  1471. ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
  1472. const
  1473. #define MATCHER_P4(name, p0, p1, p2, p3, description)\
  1474. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1475. typename p3##_type>\
  1476. class name##MatcherP4 {\
  1477. public:\
  1478. template <typename arg_type>\
  1479. class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
  1480. public:\
  1481. gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
  1482. p3##_type gmock_p3)\
  1483. : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\
  1484. virtual bool MatchAndExplain(\
  1485. arg_type arg, ::testing::MatchResultListener* result_listener) const;\
  1486. virtual void DescribeTo(::std::ostream* gmock_os) const {\
  1487. *gmock_os << FormatDescription(false);\
  1488. }\
  1489. virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
  1490. *gmock_os << FormatDescription(true);\
  1491. }\
  1492. p0##_type p0;\
  1493. p1##_type p1;\
  1494. p2##_type p2;\
  1495. p3##_type p3;\
  1496. private:\
  1497. ::testing::internal::string FormatDescription(bool negation) const {\
  1498. const ::testing::internal::string gmock_description = (description);\
  1499. if (!gmock_description.empty())\
  1500. return gmock_description;\
  1501. return ::testing::internal::FormatMatcherDescription(\
  1502. negation, #name, \
  1503. ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
  1504. ::testing::tuple<p0##_type, p1##_type, p2##_type, \
  1505. p3##_type>(p0, p1, p2, p3)));\
  1506. }\
  1507. GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
  1508. };\
  1509. template <typename arg_type>\
  1510. operator ::testing::Matcher<arg_type>() const {\
  1511. return ::testing::Matcher<arg_type>(\
  1512. new gmock_Impl<arg_type>(p0, p1, p2, p3));\
  1513. }\
  1514. name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
  1515. p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
  1516. p2(gmock_p2), p3(gmock_p3) {\
  1517. }\
  1518. p0##_type p0;\
  1519. p1##_type p1;\
  1520. p2##_type p2;\
  1521. p3##_type p3;\
  1522. private:\
  1523. GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
  1524. };\
  1525. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1526. typename p3##_type>\
  1527. inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
  1528. p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
  1529. p3##_type p3) {\
  1530. return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
  1531. p1, p2, p3);\
  1532. }\
  1533. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1534. typename p3##_type>\
  1535. template <typename arg_type>\
  1536. bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
  1537. p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
  1538. arg_type arg, \
  1539. ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
  1540. const
  1541. #define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
  1542. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1543. typename p3##_type, typename p4##_type>\
  1544. class name##MatcherP5 {\
  1545. public:\
  1546. template <typename arg_type>\
  1547. class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
  1548. public:\
  1549. gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
  1550. p3##_type gmock_p3, p4##_type gmock_p4)\
  1551. : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
  1552. p4(gmock_p4) {}\
  1553. virtual bool MatchAndExplain(\
  1554. arg_type arg, ::testing::MatchResultListener* result_listener) const;\
  1555. virtual void DescribeTo(::std::ostream* gmock_os) const {\
  1556. *gmock_os << FormatDescription(false);\
  1557. }\
  1558. virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
  1559. *gmock_os << FormatDescription(true);\
  1560. }\
  1561. p0##_type p0;\
  1562. p1##_type p1;\
  1563. p2##_type p2;\
  1564. p3##_type p3;\
  1565. p4##_type p4;\
  1566. private:\
  1567. ::testing::internal::string FormatDescription(bool negation) const {\
  1568. const ::testing::internal::string gmock_description = (description);\
  1569. if (!gmock_description.empty())\
  1570. return gmock_description;\
  1571. return ::testing::internal::FormatMatcherDescription(\
  1572. negation, #name, \
  1573. ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
  1574. ::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
  1575. p4##_type>(p0, p1, p2, p3, p4)));\
  1576. }\
  1577. GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
  1578. };\
  1579. template <typename arg_type>\
  1580. operator ::testing::Matcher<arg_type>() const {\
  1581. return ::testing::Matcher<arg_type>(\
  1582. new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\
  1583. }\
  1584. name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
  1585. p2##_type gmock_p2, p3##_type gmock_p3, \
  1586. p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
  1587. p3(gmock_p3), p4(gmock_p4) {\
  1588. }\
  1589. p0##_type p0;\
  1590. p1##_type p1;\
  1591. p2##_type p2;\
  1592. p3##_type p3;\
  1593. p4##_type p4;\
  1594. private:\
  1595. GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
  1596. };\
  1597. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1598. typename p3##_type, typename p4##_type>\
  1599. inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
  1600. p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
  1601. p4##_type p4) {\
  1602. return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
  1603. p4##_type>(p0, p1, p2, p3, p4);\
  1604. }\
  1605. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1606. typename p3##_type, typename p4##_type>\
  1607. template <typename arg_type>\
  1608. bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
  1609. p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
  1610. arg_type arg, \
  1611. ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
  1612. const
  1613. #define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
  1614. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1615. typename p3##_type, typename p4##_type, typename p5##_type>\
  1616. class name##MatcherP6 {\
  1617. public:\
  1618. template <typename arg_type>\
  1619. class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
  1620. public:\
  1621. gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
  1622. p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
  1623. : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
  1624. p4(gmock_p4), p5(gmock_p5) {}\
  1625. virtual bool MatchAndExplain(\
  1626. arg_type arg, ::testing::MatchResultListener* result_listener) const;\
  1627. virtual void DescribeTo(::std::ostream* gmock_os) const {\
  1628. *gmock_os << FormatDescription(false);\
  1629. }\
  1630. virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
  1631. *gmock_os << FormatDescription(true);\
  1632. }\
  1633. p0##_type p0;\
  1634. p1##_type p1;\
  1635. p2##_type p2;\
  1636. p3##_type p3;\
  1637. p4##_type p4;\
  1638. p5##_type p5;\
  1639. private:\
  1640. ::testing::internal::string FormatDescription(bool negation) const {\
  1641. const ::testing::internal::string gmock_description = (description);\
  1642. if (!gmock_description.empty())\
  1643. return gmock_description;\
  1644. return ::testing::internal::FormatMatcherDescription(\
  1645. negation, #name, \
  1646. ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
  1647. ::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
  1648. p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
  1649. }\
  1650. GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
  1651. };\
  1652. template <typename arg_type>\
  1653. operator ::testing::Matcher<arg_type>() const {\
  1654. return ::testing::Matcher<arg_type>(\
  1655. new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\
  1656. }\
  1657. name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
  1658. p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
  1659. p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
  1660. p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
  1661. }\
  1662. p0##_type p0;\
  1663. p1##_type p1;\
  1664. p2##_type p2;\
  1665. p3##_type p3;\
  1666. p4##_type p4;\
  1667. p5##_type p5;\
  1668. private:\
  1669. GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
  1670. };\
  1671. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1672. typename p3##_type, typename p4##_type, typename p5##_type>\
  1673. inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
  1674. p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
  1675. p3##_type p3, p4##_type p4, p5##_type p5) {\
  1676. return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
  1677. p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
  1678. }\
  1679. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1680. typename p3##_type, typename p4##_type, typename p5##_type>\
  1681. template <typename arg_type>\
  1682. bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
  1683. p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
  1684. arg_type arg, \
  1685. ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
  1686. const
  1687. #define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
  1688. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1689. typename p3##_type, typename p4##_type, typename p5##_type, \
  1690. typename p6##_type>\
  1691. class name##MatcherP7 {\
  1692. public:\
  1693. template <typename arg_type>\
  1694. class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
  1695. public:\
  1696. gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
  1697. p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
  1698. p6##_type gmock_p6)\
  1699. : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
  1700. p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
  1701. virtual bool MatchAndExplain(\
  1702. arg_type arg, ::testing::MatchResultListener* result_listener) const;\
  1703. virtual void DescribeTo(::std::ostream* gmock_os) const {\
  1704. *gmock_os << FormatDescription(false);\
  1705. }\
  1706. virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
  1707. *gmock_os << FormatDescription(true);\
  1708. }\
  1709. p0##_type p0;\
  1710. p1##_type p1;\
  1711. p2##_type p2;\
  1712. p3##_type p3;\
  1713. p4##_type p4;\
  1714. p5##_type p5;\
  1715. p6##_type p6;\
  1716. private:\
  1717. ::testing::internal::string FormatDescription(bool negation) const {\
  1718. const ::testing::internal::string gmock_description = (description);\
  1719. if (!gmock_description.empty())\
  1720. return gmock_description;\
  1721. return ::testing::internal::FormatMatcherDescription(\
  1722. negation, #name, \
  1723. ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
  1724. ::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
  1725. p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
  1726. p6)));\
  1727. }\
  1728. GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
  1729. };\
  1730. template <typename arg_type>\
  1731. operator ::testing::Matcher<arg_type>() const {\
  1732. return ::testing::Matcher<arg_type>(\
  1733. new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\
  1734. }\
  1735. name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
  1736. p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
  1737. p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
  1738. p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
  1739. p6(gmock_p6) {\
  1740. }\
  1741. p0##_type p0;\
  1742. p1##_type p1;\
  1743. p2##_type p2;\
  1744. p3##_type p3;\
  1745. p4##_type p4;\
  1746. p5##_type p5;\
  1747. p6##_type p6;\
  1748. private:\
  1749. GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
  1750. };\
  1751. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1752. typename p3##_type, typename p4##_type, typename p5##_type, \
  1753. typename p6##_type>\
  1754. inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
  1755. p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
  1756. p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
  1757. p6##_type p6) {\
  1758. return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
  1759. p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
  1760. }\
  1761. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1762. typename p3##_type, typename p4##_type, typename p5##_type, \
  1763. typename p6##_type>\
  1764. template <typename arg_type>\
  1765. bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
  1766. p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
  1767. arg_type arg, \
  1768. ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
  1769. const
  1770. #define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
  1771. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1772. typename p3##_type, typename p4##_type, typename p5##_type, \
  1773. typename p6##_type, typename p7##_type>\
  1774. class name##MatcherP8 {\
  1775. public:\
  1776. template <typename arg_type>\
  1777. class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
  1778. public:\
  1779. gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
  1780. p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
  1781. p6##_type gmock_p6, p7##_type gmock_p7)\
  1782. : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
  1783. p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
  1784. virtual bool MatchAndExplain(\
  1785. arg_type arg, ::testing::MatchResultListener* result_listener) const;\
  1786. virtual void DescribeTo(::std::ostream* gmock_os) const {\
  1787. *gmock_os << FormatDescription(false);\
  1788. }\
  1789. virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
  1790. *gmock_os << FormatDescription(true);\
  1791. }\
  1792. p0##_type p0;\
  1793. p1##_type p1;\
  1794. p2##_type p2;\
  1795. p3##_type p3;\
  1796. p4##_type p4;\
  1797. p5##_type p5;\
  1798. p6##_type p6;\
  1799. p7##_type p7;\
  1800. private:\
  1801. ::testing::internal::string FormatDescription(bool negation) const {\
  1802. const ::testing::internal::string gmock_description = (description);\
  1803. if (!gmock_description.empty())\
  1804. return gmock_description;\
  1805. return ::testing::internal::FormatMatcherDescription(\
  1806. negation, #name, \
  1807. ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
  1808. ::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
  1809. p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
  1810. p3, p4, p5, p6, p7)));\
  1811. }\
  1812. GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
  1813. };\
  1814. template <typename arg_type>\
  1815. operator ::testing::Matcher<arg_type>() const {\
  1816. return ::testing::Matcher<arg_type>(\
  1817. new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\
  1818. }\
  1819. name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
  1820. p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
  1821. p5##_type gmock_p5, p6##_type gmock_p6, \
  1822. p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
  1823. p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
  1824. p7(gmock_p7) {\
  1825. }\
  1826. p0##_type p0;\
  1827. p1##_type p1;\
  1828. p2##_type p2;\
  1829. p3##_type p3;\
  1830. p4##_type p4;\
  1831. p5##_type p5;\
  1832. p6##_type p6;\
  1833. p7##_type p7;\
  1834. private:\
  1835. GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
  1836. };\
  1837. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1838. typename p3##_type, typename p4##_type, typename p5##_type, \
  1839. typename p6##_type, typename p7##_type>\
  1840. inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
  1841. p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
  1842. p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
  1843. p6##_type p6, p7##_type p7) {\
  1844. return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
  1845. p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
  1846. p6, p7);\
  1847. }\
  1848. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1849. typename p3##_type, typename p4##_type, typename p5##_type, \
  1850. typename p6##_type, typename p7##_type>\
  1851. template <typename arg_type>\
  1852. bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
  1853. p5##_type, p6##_type, \
  1854. p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
  1855. arg_type arg, \
  1856. ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
  1857. const
  1858. #define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
  1859. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1860. typename p3##_type, typename p4##_type, typename p5##_type, \
  1861. typename p6##_type, typename p7##_type, typename p8##_type>\
  1862. class name##MatcherP9 {\
  1863. public:\
  1864. template <typename arg_type>\
  1865. class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
  1866. public:\
  1867. gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
  1868. p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
  1869. p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
  1870. : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
  1871. p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
  1872. p8(gmock_p8) {}\
  1873. virtual bool MatchAndExplain(\
  1874. arg_type arg, ::testing::MatchResultListener* result_listener) const;\
  1875. virtual void DescribeTo(::std::ostream* gmock_os) const {\
  1876. *gmock_os << FormatDescription(false);\
  1877. }\
  1878. virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
  1879. *gmock_os << FormatDescription(true);\
  1880. }\
  1881. p0##_type p0;\
  1882. p1##_type p1;\
  1883. p2##_type p2;\
  1884. p3##_type p3;\
  1885. p4##_type p4;\
  1886. p5##_type p5;\
  1887. p6##_type p6;\
  1888. p7##_type p7;\
  1889. p8##_type p8;\
  1890. private:\
  1891. ::testing::internal::string FormatDescription(bool negation) const {\
  1892. const ::testing::internal::string gmock_description = (description);\
  1893. if (!gmock_description.empty())\
  1894. return gmock_description;\
  1895. return ::testing::internal::FormatMatcherDescription(\
  1896. negation, #name, \
  1897. ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
  1898. ::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
  1899. p4##_type, p5##_type, p6##_type, p7##_type, \
  1900. p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
  1901. }\
  1902. GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
  1903. };\
  1904. template <typename arg_type>\
  1905. operator ::testing::Matcher<arg_type>() const {\
  1906. return ::testing::Matcher<arg_type>(\
  1907. new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
  1908. }\
  1909. name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
  1910. p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
  1911. p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
  1912. p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
  1913. p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
  1914. p8(gmock_p8) {\
  1915. }\
  1916. p0##_type p0;\
  1917. p1##_type p1;\
  1918. p2##_type p2;\
  1919. p3##_type p3;\
  1920. p4##_type p4;\
  1921. p5##_type p5;\
  1922. p6##_type p6;\
  1923. p7##_type p7;\
  1924. p8##_type p8;\
  1925. private:\
  1926. GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
  1927. };\
  1928. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1929. typename p3##_type, typename p4##_type, typename p5##_type, \
  1930. typename p6##_type, typename p7##_type, typename p8##_type>\
  1931. inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
  1932. p4##_type, p5##_type, p6##_type, p7##_type, \
  1933. p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
  1934. p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
  1935. p8##_type p8) {\
  1936. return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
  1937. p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
  1938. p3, p4, p5, p6, p7, p8);\
  1939. }\
  1940. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1941. typename p3##_type, typename p4##_type, typename p5##_type, \
  1942. typename p6##_type, typename p7##_type, typename p8##_type>\
  1943. template <typename arg_type>\
  1944. bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
  1945. p5##_type, p6##_type, p7##_type, \
  1946. p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
  1947. arg_type arg, \
  1948. ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
  1949. const
  1950. #define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
  1951. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  1952. typename p3##_type, typename p4##_type, typename p5##_type, \
  1953. typename p6##_type, typename p7##_type, typename p8##_type, \
  1954. typename p9##_type>\
  1955. class name##MatcherP10 {\
  1956. public:\
  1957. template <typename arg_type>\
  1958. class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
  1959. public:\
  1960. gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
  1961. p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
  1962. p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
  1963. p9##_type gmock_p9)\
  1964. : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
  1965. p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
  1966. p8(gmock_p8), p9(gmock_p9) {}\
  1967. virtual bool MatchAndExplain(\
  1968. arg_type arg, ::testing::MatchResultListener* result_listener) const;\
  1969. virtual void DescribeTo(::std::ostream* gmock_os) const {\
  1970. *gmock_os << FormatDescription(false);\
  1971. }\
  1972. virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
  1973. *gmock_os << FormatDescription(true);\
  1974. }\
  1975. p0##_type p0;\
  1976. p1##_type p1;\
  1977. p2##_type p2;\
  1978. p3##_type p3;\
  1979. p4##_type p4;\
  1980. p5##_type p5;\
  1981. p6##_type p6;\
  1982. p7##_type p7;\
  1983. p8##_type p8;\
  1984. p9##_type p9;\
  1985. private:\
  1986. ::testing::internal::string FormatDescription(bool negation) const {\
  1987. const ::testing::internal::string gmock_description = (description);\
  1988. if (!gmock_description.empty())\
  1989. return gmock_description;\
  1990. return ::testing::internal::FormatMatcherDescription(\
  1991. negation, #name, \
  1992. ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
  1993. ::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
  1994. p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
  1995. p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
  1996. }\
  1997. GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
  1998. };\
  1999. template <typename arg_type>\
  2000. operator ::testing::Matcher<arg_type>() const {\
  2001. return ::testing::Matcher<arg_type>(\
  2002. new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
  2003. }\
  2004. name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
  2005. p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
  2006. p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
  2007. p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
  2008. p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
  2009. p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
  2010. }\
  2011. p0##_type p0;\
  2012. p1##_type p1;\
  2013. p2##_type p2;\
  2014. p3##_type p3;\
  2015. p4##_type p4;\
  2016. p5##_type p5;\
  2017. p6##_type p6;\
  2018. p7##_type p7;\
  2019. p8##_type p8;\
  2020. p9##_type p9;\
  2021. private:\
  2022. GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
  2023. };\
  2024. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  2025. typename p3##_type, typename p4##_type, typename p5##_type, \
  2026. typename p6##_type, typename p7##_type, typename p8##_type, \
  2027. typename p9##_type>\
  2028. inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
  2029. p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
  2030. p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
  2031. p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
  2032. p9##_type p9) {\
  2033. return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
  2034. p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
  2035. p1, p2, p3, p4, p5, p6, p7, p8, p9);\
  2036. }\
  2037. template <typename p0##_type, typename p1##_type, typename p2##_type, \
  2038. typename p3##_type, typename p4##_type, typename p5##_type, \
  2039. typename p6##_type, typename p7##_type, typename p8##_type, \
  2040. typename p9##_type>\
  2041. template <typename arg_type>\
  2042. bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
  2043. p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
  2044. p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
  2045. arg_type arg, \
  2046. ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
  2047. const
  2048. #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_