Home | History | Annotate | Download | only in gmock

Lines Matching defs:Matcher

61 // To implement a matcher Foo for type T, define:
64 // 2. a factory function that creates a Matcher<T> object from a
68 // to write "v" instead of "Eq(v)" where a Matcher is expected, which
70 // ownership management as Matcher objects can now be copied like
74 // used by a matcher to explain why a value matches or doesn't match.
101 // the match result. A matcher's MatchAndExplain() method can use
116 // matcher.
121 // Describes this matcher to an ostream. The function should print
123 // matcher should have. The subject of the verb phrase is the value
125 // matcher prints "is greater than 7".
128 // Describes the negation of this matcher to an ostream. For
129 // example, if the description of this matcher is "is greater than
132 // MatcherInterface, but it is highly advised so that your matcher
141 // The implementation of a matcher.
145 // Returns true iff the matcher matches x; also explains the match
149 // MatchAndExplain() method of the Pointee(...) matcher should
155 // print-out of x and the matcher's description. Whether the match
158 // when the match succeeds (e.g. when the matcher is used inside
161 // For example, a "has at least 10 elements" matcher should explain
164 // "is empty" matcher probably only needs to explain what the actual
168 // You should override this method when defining a new matcher.
171 // that 'listener' is not NULL. This helps to simplify a matcher's
248 // An internal class for implementing Matcher<T>, which will derive
249 // from it. We put functionalities common to all Matcher<T>
254 // Returns true iff the matcher matches x; also explains the match
260 // Returns true iff this matcher matches x.
266 // Describes this matcher to an ostream.
269 // Describes the negation of this matcher to an ostream.
274 // Explains why x matches, or doesn't match, the matcher.
280 // Returns the describer for this matcher object; retains ownership
282 // this matcher object is alive.
290 // Constructs a matcher from its implementation.
313 // A Matcher<T> is a copyable and IMMUTABLE (except by assignment)
315 // implementation of Matcher<T> is just a linked_ptr to const
317 // from Matcher!
319 class Matcher : public internal::MatcherBase<T> {
321 // Constructs a null matcher. Needed for storing Matcher objects in STL
322 // containers. A default-constructed matcher is not yet initialized. You
324 explicit Matcher() {} // NOLINT
326 // Constructs a matcher from its implementation.
327 explicit Matcher(const MatcherInterface<T>* impl)
332 Matcher(T value); // NOLINT
337 // matcher is expected.
339 class GTEST_API_ Matcher<const internal::string&>
342 Matcher() {}
344 explicit Matcher(const MatcherInterface<const internal::string&>* impl)
349 Matcher(const internal::string& s); // NOLINT
352 Matcher(const char* s); // NOLINT
356 class GTEST_API_ Matcher<internal::string>
359 Matcher() {}
361 explicit Matcher(const MatcherInterface<internal::string>* impl)
366 Matcher(const internal::string& s); // NOLINT
369 Matcher(const char* s); // NOLINT
375 // matcher is expected.
377 class GTEST_API_ Matcher<const StringPiece&>
380 Matcher() {}
382 explicit Matcher(const MatcherInterface<const StringPiece&>* impl)
387 Matcher(const internal::string& s); // NOLINT
390 Matcher(const char* s); // NOLINT
393 Matcher(StringPiece s); // NOLINT
397 class GTEST_API_ Matcher<StringPiece>
400 Matcher() {}
402 explicit Matcher(const MatcherInterface<StringPiece>* impl)
407 Matcher(const internal::string& s); // NOLINT
410 Matcher(const char* s); // NOLINT
413 Matcher(StringPiece s); // NOLINT
418 // polymorphic matcher (i.e. a matcher that can match values of more
421 // To define a polymorphic matcher, a user should provide an Impl
434 // Returns a mutable reference to the underlying matcher
438 // Returns an immutable reference to the underlying matcher
443 operator Matcher<T>() const {
444 return Matcher<T>(new MonomorphicImpl<T>(impl_));
476 // Creates a matcher from its implementation. This is easier to use
477 // than the Matcher<T> constructor as it doesn't require you to
482 // Matcher<const string&>(foo);
484 inline Matcher<T> MakeMatcher(const MatcherInterface<T>* impl) {
485 return Matcher<T>(impl);
488 // Creates a polymorphic matcher from its implementation. This is
511 // polymorphic matcher (i.e. something that can be converted to a
512 // Matcher but is not one yet; for example, Eq(value)) or a value (for
517 static Matcher<T> Cast(const M& polymorphic_matcher_or_value) {
518 // M can be a polymorhic matcher, in which case we want to use
519 // its conversion operator to create Matcher<T>. Or it can be a value
520 // that should be passed to the Matcher<T>'s constructor.
522 // We can't call Matcher<T>(polymorphic_matcher_or_value) when M is a
523 // polymorphic matcher because it'll be ambiguous if T has an implicit
528 // polymorphic_matcher_or_value to Matcher<T> because it won't trigger
534 internal::ImplicitlyConvertible<M, Matcher<T> >::value>());
538 static Matcher<T> CastImpl(const M& value, BooleanConstant<false>) {
539 // M can't be implicitly converted to Matcher<T>, so M isn't a polymorphic
540 // matcher. It must be a value then. Use direct initialization to create
541 // a matcher.
542 return Matcher<T>(ImplicitCast_<T>(value));
545 static Matcher<T> CastImpl(const M& polymorphic_matcher_or_value,
547 // M is implicitly convertible to Matcher<T>, which means that either
548 // M is a polymorhpic matcher or Matcher<T> has an implicit constructor
550 // matcher.
553 // creating Matcher<T> would require a chain of two user-defined conversions
554 // (first to create T from M and then to create Matcher<T> from T).
560 // is already a Matcher. This only compiles when type T can be
563 class MatcherCastImpl<T, Matcher<U> > {
565 static Matcher<T> Cast(const Matcher<U>& source_matcher) {
566 return Matcher<T>(new Impl(source_matcher));
572 explicit Impl(const Matcher<U>& source_matcher)
575 // We delegate the matching logic to the source matcher.
589 const Matcher<U> source_matcher_;
596 // a matcher to its own type.
598 class MatcherCastImpl<T, Matcher<T> > {
600 static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; }
605 // In order to be safe and clear, casting between different matcher
607 // matcher m and returns a Matcher<T>. It compiles only when T can be
610 inline Matcher<T> MatcherCast(const M& matcher) {
611 return internal::MatcherCastImpl<T, M>::Cast(matcher);
619 // template <T, U> ... (const Matcher<U>&)
627 static inline Matcher<T> Cast(const M& polymorphic_matcher_or_value) {
634 // safely convert a Matcher<U> to a Matcher<T> (i.e. Matcher is
635 // contravariant): just keep a copy of the original Matcher<U>, convert the
636 // argument from type T to U, and then pass it to the underlying Matcher<U>.
638 // underlying Matcher<U> may be interested in the argument's address, which
641 static inline Matcher<T> Cast(const Matcher<U>& matcher) {
660 return MatcherCast<T>(matcher);
665 inline Matcher<T> SafeMatcherCast(const M& polymorphic_matcher) {
669 // A<T>() returns a matcher that matches any value of type T.
671 Matcher<T> A();
695 // Matches the value against the given matcher, prints the value and explains
701 bool MatchPrintAndExplain(Value& value, const Matcher<T>& matcher,
706 return matcher.Matches(value);
710 const bool match = matcher.MatchAndExplain(value, &inner_listener);
751 typename tuple_element<N - 1, MatcherTuple>::type matcher =
756 if (!matcher.MatchAndExplain(value, &listener)) {
765 // matcher's MatchAndExplain() method handles the case when
872 // Implements _, a matcher that matches any value of any
873 // type. This is a polymorphic matcher, so we need a template type
874 // conversion operator to make it appearing as a Matcher
879 operator Matcher<T>() const { return A<T>(); }
882 // Implements a matcher that compares a given value with a
886 // The matcher defined here is polymorphic (for example, Eq(5) can be
897 operator Matcher<Lhs>() const {
975 // Implements the polymorphic IsNull() matcher, which matches any raw or smart
995 // Implements the polymorphic NotNull() matcher, which matches any raw or smart
1016 // 'variable'. This matcher is polymorphic as it can match any
1026 // Matcher<int> m1 = Ref(n); // This won't compile.
1027 // Matcher<int&> m2 = Ref(n); // This will compile.
1040 // compiler to catch using Ref(const_value) as a matcher for a
1045 operator Matcher<Super&>() const {
1048 // this catches using Ref(const_value) as a matcher for a
1183 // Implements the polymorphic HasSubstr(substring) matcher, which
1184 // can be used as a Matcher<T> as long as T can be converted to a
1213 // Describes what this matcher matches.
1230 // Implements the polymorphic StartsWith(substring) matcher, which
1231 // can be used as a Matcher<T> as long as T can be converted to a
1277 // Implements the polymorphic EndsWith(substring) matcher, which
1278 // can be used as a Matcher<T> as long as T can be converted to a
1324 // ContainsRegex(regex), which can be used as a Matcher<T> as long as
1372 // Implements a matcher that compares the two fields of a 2-tuple
1376 // The matcher defined here is polymorphic (for example, Eq() can be
1384 operator Matcher< ::testing::tuple<T1, T2> >() const {
1388 operator Matcher<const ::testing::tuple<T1, T2>&>() const {
1439 // Implements the Not(...) matcher for a particular argument type T.
1446 explicit NotMatcherImpl(const Matcher<T>& matcher)
1447 : matcher_(matcher) {}
1462 const Matcher<T> matcher_;
1467 // Implements the Not(m) matcher, which matches a value that doesn't
1468 // match matcher m.
1472 explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {}
1477 operator Matcher<T>() const {
1478 return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_)));
1487 // Implements the AllOf(m1, m2) matcher for a particular argument type
1494 BothOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
1544 const Matcher<T> matcher1_;
1545 const Matcher<T> matcher2_;
1552 // a list structure (ListType) and creating a combining matcher from such a
1556 // * Head is the type of the first matcher of the list.
1567 static ListType BuildList(const Head& matcher, const Tail&... tail) {
1568 return ListType(matcher, MatcherListTail::BuildList(tail...));
1571 // CreateMatcher<T> creates a Matcher<T> from a given list of matchers (built
1574 // constructor taking two Matcher<T>s as input.
1576 static Matcher<T> CreateMatcher(const ListType& matchers) {
1577 return Matcher<T>(new CombiningMatcher<T>(
1596 static Matcher<T> CreateMatcher(const ListType& matchers) {
1597 return Matcher<T>(new CombiningMatcher<T>(
1617 operator Matcher<T>() const {
1635 // Used for implementing the AllOf(m_1, ..., m_n) matcher, which
1647 operator Matcher<T>() const {
1648 return Matcher<T>(new BothOfMatcherImpl<T>(SafeMatcherCast<T>(matcher1_),
1659 // Implements the AnyOf(m1, m2) matcher for a particular argument type
1666 EitherOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
1716 const Matcher<T> matcher1_;
1717 const Matcher<T> matcher2_;
1729 // Used for implementing the AnyOf(m_1, ..., m_n) matcher, which
1742 operator Matcher<T>() const {
1743 return Matcher<T>(new EitherOfMatcherImpl<T>(
1755 // matcher.
1761 // This method template allows Truly(pred) to be used as a matcher
1793 // Used for implementing Matches(matcher), which turns a matcher into
1798 explicit MatcherAsPredicate(M matcher) : matcher_(matcher) {}
1801 // predicate on type T where m is a matcher on type T.
1804 // some matcher may be interested in its address (e.g. as in
1810 // allows us to write Matches(m) where m is a polymorphic matcher
1813 // If we write Matcher<T>(matcher_).Matches(x) here, it won't
1814 // compile when matcher_ has type Matcher<const T&>; if we write
1815 // Matcher<const T&>(matcher_).Matches(x) here, it won't compile
1816 // when matcher_ has type Matcher<T>; if we just write
1832 // argument M must be a type that can be converted to a matcher.
1843 // We convert matcher_ to a Matcher<const T&> *now* instead of
1850 // Matcher<const T&>(matcher_), as the latter won't compile when
1851 // matcher_ has type Matcher<T> (e.g. An<int>()).
1853 // potentially unsafe downcasting of the matcher argument.
1854 const Matcher<const T&> matcher = SafeMatcherCast<const T&>(matcher_);
1856 if (MatchPrintAndExplain(x, matcher, &listener))
1862 matcher.DescribeTo(&ss);
1873 // A helper function for converting a matcher to a predicate-formatter
1876 // Implementation detail: 'matcher' is received by-value to force decaying.
1879 MakePredicateFormatterFromMatcher(M matcher) {
1880 return PredicateFormatterFromMatcher<M>(internal::move(matcher));
1883 // Implements the polymorphic floating point equality matcher, which matches
1891 // The matcher's input will be compared with expected. The matcher treats two
1912 // Implements floating point equality matcher as a Matcher<T>.
2011 // NanSensitiveFloatEq(expected) to be used as a Matcher<float>, a
2012 // Matcher<const float&>, or a Matcher<float&>, but nothing else.
2016 operator Matcher<FloatType>() const {
2021 operator Matcher<const FloatType&>() const {
2026 operator Matcher<FloatType&>() const {
2040 // Implements the Pointee(m) matcher for matching a pointer whose
2041 // pointee matches matcher m. The pointer can be either raw or smart.
2045 explicit PointeeMatcher(const InnerMatcher& matcher) : matcher_(matcher) {}
2048 // used as a matcher for any pointer type whose pointee type is
2049 // compatible with the inner matcher, where type Pointer can be
2056 operator Matcher<Pointer>() const {
2068 explicit Impl(const InnerMatcher& matcher)
2069 : matcher_(MatcherCast<const Pointee&>(matcher)) {}
2091 const Matcher<const Pointee&> matcher_;
2101 // Implements the WhenDynamicCastTo<T>(m) matcher that matches a pointer or
2103 // The result of dynamic_cast<To> is forwarded to the inner matcher.
2104 // If To is a pointer and the cast fails, the inner matcher will receive NULL.
2105 // If To is a reference and the cast fails, this matcher returns false
2110 explicit WhenDynamicCastToMatcherBase(const Matcher<To>& matcher)
2111 : matcher_(matcher) {}
2124 const Matcher<To> matcher_;
2147 explicit WhenDynamicCastToMatcher(const Matcher<To>& matcher)
2148 : WhenDynamicCastToMatcherBase<To>(matcher) {}
2163 explicit WhenDynamicCastToMatcher(const Matcher<To&>& matcher)
2164 : WhenDynamicCastToMatcherBase<To&>(matcher) {}
2178 // Implements the Field() matcher for matching a field (i.e. member
2184 const Matcher<const FieldType&>& matcher)
2185 : field_(field), matcher_(matcher) {}
2208 // true_type iff the Field() matcher is used to match a pointer.
2228 const Matcher<const FieldType&> matcher_;
2233 // Implements the Property() matcher for matching a property
2245 const Matcher<RefToConstProperty>& matcher)
2246 : property_(property), matcher_(matcher) {}
2269 // true_type iff the Property() matcher is used to match a pointer.
2299 const Matcher<RefToConstProperty> matcher_;
2334 // Implements the ResultOf() matcher for matching a return value of a
2341 Matcher<ResultType>& matcher)
2342 : callable_(callable), matcher_(matcher) {
2347 operator Matcher<T>() const {
2348 return Matcher<T>(new Impl<T>(callable_, matcher_));
2357 Impl(CallableStorageType callable, const Matcher<ResultType>& matcher)
2358 : callable_(callable), matcher_(matcher) {}
2386 const Matcher<ResultType> matcher_;
2392 const Matcher<ResultType> matcher_;
2397 // Implements a matcher that checks the size of an STL-style container.
2406 operator Matcher<Container>() const {
2440 const Matcher<SizeType> size_matcher_;
2449 // Implements a matcher that checks the begin()..end() distance of an STL-style
2458 operator Matcher<Container>() const {
2501 const Matcher<DistanceType> distance_matcher_;
2510 // Implements an equality matcher for any STL-style container whose elements
2511 // support ==. This matcher is like Eq(), but its failure explanations provide
2528 // after this matcher is created.
2616 const ContainerMatcher& matcher)
2617 : comparator_(comparator), matcher_(matcher) {}
2620 operator Matcher<LhsContainer>() const {
2636 Impl(const Comparator& comparator, const ContainerMatcher& matcher)
2637 : comparator_(comparator), matcher_(matcher) {}
2676 const Matcher<const ::std::vector<LhsValue>&> matcher_;
2689 // must be able to be safely cast to Matcher<tuple<const T1&, const
2700 // it are modified after this matcher is created.
2710 operator Matcher<LhsContainer>() const {
2722 // We pass the LHS value and the RHS value to the inner matcher by
2729 // mono_tuple_matcher_ holds a monomorphic version of the tuple matcher.
2785 const Matcher<InnerMatcherArg> mono_tuple_matcher_;
2837 const Matcher<const Element&> inner_matcher_;
2851 // Describes what this matcher does.
2880 // Describes what this matcher does.
2907 operator Matcher<Container>() const {
2924 operator Matcher<Container>() const {
2950 // Returns true iff 'key_value.first' (the key) matches the inner matcher.
2963 // Describes what this matcher does.
2969 // Describes what the negation of this matcher does.
2976 const Matcher<const KeyType&> inner_matcher_;
2988 operator Matcher<PairType>() const {
3015 // Describes what this matcher does.
3023 // Describes what the negation of this matcher does.
3079 const Matcher<const FirstType&> first_matcher_;
3080 const Matcher<const SecondType&> second_matcher_;
3093 operator Matcher<PairType> () const {
3116 // Constructs the matcher from a sequence of element values or
3125 // Describes what this matcher does.
3144 // Describes what the negation of this matcher does.
3179 bool match; // Does the current element match the current matcher?
3248 ::std::vector<Matcher<const Element&> > matchers_;
3301 // The matching is represented as a vector of {element, matcher} pairs.
3313 // A vector of matcher describers, one for each element matcher.
3318 // Describes this UnorderedElementsAre matcher.
3321 // Describes the negation of this UnorderedElementsAre matcher.
3355 // Constructs the matcher from a sequence of element values or
3365 // Describes what this matcher does.
3370 // Describes what the negation of this matcher does.
3405 typedef ::std::vector<Matcher<const Element&> > MatcherVec;
3443 Matcher<Target> operator()(const Arg& a) const {
3456 operator Matcher<Container>() const {
3460 typedef ::std::vector<Matcher<const Element&> > MatcherVec;
3481 operator Matcher<Container>() const {
3485 typedef ::std::vector<Matcher<const Element&> > MatcherVec;
3510 operator Matcher<Container>() const {
3530 operator Matcher<Container>() const {
3541 // Given a 2-tuple matcher tm of type Tuple2Matcher and a value second
3543 // second) is a polymorphic matcher that matches a value x iff tm
3557 operator Matcher<T>() const {
3596 const Matcher<const ArgTuple&> mono_tuple2_matcher_;
3606 // Given a 2-tuple matcher tm and a value second,
3607 // MatcherBindSecond(tm, second) returns a matcher that matches a
3616 // Returns the description for a matcher defined using the MATCHER*()
3619 // negation of the matcher. 'param_values' contains a list of strings
3620 // that are the print-out of the matcher's parameters.
3640 // All forms of ElementsAreArray() make a copy of the input matcher sequence.
3719 // _ is a matcher that matches anything of any type.
3729 // Creates a matcher that matches any value of the given type T.
3731 inline Matcher<T> A() { return MakeMatcher(new internal::AnyMatcherImpl<T>()); }
3733 // Creates a matcher that matches any value of the given type T.
3735 inline Matcher<T> An() { return A<T>(); }
3737 // Creates a polymorphic matcher that matches anything equal to x.
3743 // Constructs a Matcher<T> from a 'value' of type T. The constructed
3744 // matcher matches any value that's equal to 'value'.
3746 Matcher<T>::Matcher(T value) { *this = Eq(value); }
3748 // Creates a monomorphic matcher that matches anything with type Lhs
3752 // TypedEq<T>(x) is just a convenient short-hand for Matcher<T>(Eq(x))
3753 // or Matcher<T>(x), but more readable than the latter.
3758 // can always write Matcher<T>(Lt(5)) to be explicit about the type,
3761 inline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }
3763 // Creates a polymorphic matcher that matches anything >= x.
3769 // Creates a polymorphic matcher that matches anything > x.
3775 // Creates a polymorphic matcher that matches anything <= x.
3781 // Creates a polymorphic matcher that matches anything < x.
3787 // Creates a polymorphic matcher that matches anything != x.
3793 // Creates a polymorphic matcher that matches any NULL pointer.
3798 // Creates a polymorphic matcher that matches any non-NULL pointer.
3805 // Creates a polymorphic matcher that matches any argument that
3812 // Creates a matcher that matches any double argument approximately
3818 // Creates a matcher that matches any double argument approximately
3824 // Creates a matcher that matches any double argument approximately equal to
3832 // Creates a matcher that matches any double argument approximately equal to
3840 // Creates a matcher that matches any float argument approximately
3846 // Creates a matcher that matches any float argument approximately
3852 // Creates a matcher that matches any float argument approximately equal to
3860 // Creates a matcher that matches any float argument approximately equal to
3868 // Creates a matcher that matches a pointer (raw or smart) that points
3876 // Creates a matcher that matches a pointer or reference that matches
3878 // The result of dynamic_cast<To> is forwarded to the inner matcher.
3879 // If To is a pointer and the cast fails, the inner matcher will receive NULL.
3880 // If To is a reference and the cast fails, this matcher returns false
3884 WhenDynamicCastTo(const Matcher<To>& inner_matcher) {
3889 // Creates a matcher that matches an object whose given field matches
3890 // 'matcher'. For example,
3896 FieldType Class::*field, const FieldMatcher& matcher) {
3899 field, MatcherCast<const FieldType&>(matcher)));
3903 // to compile where bar is an int32 and m is a matcher for int64.
3906 // Creates a matcher that matches an object whose given property
3907 // matches 'matcher'. For example,
3913 PropertyType (Class::*property)() const, const PropertyMatcher& matcher) {
3917 MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
3921 // to compile where bar() returns an int32 and m is a matcher for int64.
3924 // Creates a matcher that matches an object iff the result of applying
3925 // a callable to x matches 'matcher'.
3939 Callable callable, const ResultOfMatcher& matcher) {
3943 matcher));
3947 // to compile where Function() returns an int32 and m is a matcher for int64.
3980 // Creates a matcher that matches any string, std::string, or C string
4002 // The matcher takes ownership of 'regex'.
4013 // The matcher takes ownership of 'regex'.
4054 // Creates a matcher that matches any wstring, std::wstring, or C wide string
4078 // Creates a polymorphic matcher that matches a 2-tuple where the
4082 // Creates a polymorphic matcher that matches a 2-tuple where the
4086 // Creates a polymorphic matcher that matches a 2-tuple where the
4090 // Creates a polymorphic matcher that matches a 2-tuple where the
4094 // Creates a polymorphic matcher that matches a 2-tuple where the
4098 // Creates a polymorphic matcher that matches a 2-tuple where the
4102 // Creates a matcher that matches any value of type T that m doesn't
4109 // Returns a matcher that matches anything that satisfies the given
4118 // Returns a matcher that matches the container size. The container must
4121 // matcher. For instance:
4130 // Returns a matcher that matches the distance between the container's begin()
4131 // iterator and its end() iterator, i.e. the size of the container. This matcher
4141 // Returns a matcher that matches an equal container.
4142 // This matcher behaves like Eq(), but in the event of mismatch lists the
4156 // Returns a matcher that matches a container that, when sorted using
4166 // Returns a matcher that matches a container that, when sorted using
4178 // i-th element (as a pair) satisfy the given pair matcher, for all i.
4179 // TupleMatcher must be able to be safely cast to Matcher<tuple<const
4209 // pair matcher, for all i. Tuple2Matcher must be able to be safely
4210 // cast to Matcher<tuple<const T1&, const T2&> >, where T1 and T2 are
4236 // Create a matcher for each element in rhs_container.
4262 // least one element matching the given value or matcher.
4280 inline internal::ContainsMatcher<M> Contains(M matcher) {
4281 return internal::ContainsMatcher<M>(matcher);
4285 // elements matching the given value or matcher.
4312 inline internal::EachMatcher<M> Each(M matcher) {
4313 return internal::EachMatcher<M>(matcher);
4337 // given matcher.
4339 inline internal::MatcherAsPredicate<M> Matches(M matcher) {
4340 return internal::MatcherAsPredicate<M>(matcher);
4343 // Returns true iff the value matches the matcher.
4345 inline bool Value(const T& value, M matcher) {
4346 return testing::Matches(matcher)(value);
4349 // Matches the value against the given matcher and explains the match
4353 M matcher, const T& value, MatchResultListener* listener) {
4354 return SafeMatcherCast<const T&>(matcher).MatchAndExplain(value, listener);
4358 // Define variadic matcher versions. They are overloaded in
4380 inline InnerMatcher AllArgs(const InnerMatcher& matcher) { return matcher; }
4383 // tests. ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher)
4384 // succeed iff the value matches the matcher. If the assertion fails,
4385 // the value and the description of the matcher will be printed.
4386 #define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\
4387 ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
4388 #define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\
4389 ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)