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