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