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