gmock-generated-matchers.h 89 KB

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