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