Lines Matching refs:Matcher

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
248 // An internal class for implementing Matcher<T>, which will derive
249 // from it. We put functionalities common to all Matcher<T>
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
324 explicit Matcher() {} // NOLINT
327 explicit Matcher(const MatcherInterface<T>* impl)
332 Matcher(T value); // NOLINT
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
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
443 operator Matcher<T>() const {
444 return Matcher<T>(new MonomorphicImpl<T>(impl_));
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);
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) {
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
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
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
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)
589 const Matcher<U> source_matcher_;
598 class MatcherCastImpl<T, Matcher<T> > {
600 static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; }
607 // matcher m and returns a Matcher<T>. It compiles only when T can be
610 inline Matcher<T> MatcherCast(const M& 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) {
665 inline Matcher<T> SafeMatcherCast(const M& polymorphic_matcher) {
671 Matcher<T> A();
701 bool MatchPrintAndExplain(Value& value, const Matcher<T>& matcher,
874 // conversion operator to make it appearing as a Matcher<T> for any
879 operator Matcher<T>() const { return A<T>(); }
897 operator Matcher<Lhs>() const {
1026 // Matcher<int> m1 = Ref(n); // This won't compile.
1027 // Matcher<int&> m2 = Ref(n); // This will compile.
1045 operator Matcher<Super&>() const {
1184 // can be used as a Matcher<T> as long as T can be converted to a
1231 // can be used as a Matcher<T> as long as T can be converted to a
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
1384 operator Matcher< ::testing::tuple<T1, T2> >() const {
1388 operator Matcher<const ::testing::tuple<T1, T2>&>() const {
1446 explicit NotMatcherImpl(const Matcher<T>& matcher)
1462 const Matcher<T> matcher_;
1477 operator Matcher<T>() const {
1478 return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_)));
1494 BothOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
1544 const Matcher<T> matcher1_;
1545 const Matcher<T> matcher2_;
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 {
1647 operator Matcher<T>() const {
1648 return Matcher<T>(new BothOfMatcherImpl<T>(SafeMatcherCast<T>(matcher1_),
1666 EitherOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
1716 const Matcher<T> matcher1_;
1717 const Matcher<T> matcher2_;
1742 operator Matcher<T>() const {
1743 return Matcher<T>(new EitherOfMatcherImpl<T>(
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
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>()).
1854 const Matcher<const T&> matcher = SafeMatcherCast<const T&>(matcher_);
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 {
2056 operator Matcher<Pointer>() const {
2091 const Matcher<const Pointee&> matcher_;
2110 explicit WhenDynamicCastToMatcherBase(const Matcher<To>& matcher)
2124 const Matcher<To> matcher_;
2147 explicit WhenDynamicCastToMatcher(const Matcher<To>& matcher)
2163 explicit WhenDynamicCastToMatcher(const Matcher<To&>& matcher)
2184 const Matcher<const FieldType&>& matcher)
2228 const Matcher<const FieldType&> matcher_;
2245 const Matcher<RefToConstProperty>& matcher)
2299 const Matcher<RefToConstProperty> matcher_;
2341 ResultOfMatcher(Callable callable, const Matcher<ResultType>& matcher)
2347 operator Matcher<T>() const {
2348 return Matcher<T>(new Impl<T>(callable_, matcher_));
2357 Impl(CallableStorageType callable, const Matcher<ResultType>& matcher)
2386 const Matcher<ResultType> matcher_;
2392 const Matcher<ResultType> matcher_;
2406 operator Matcher<Container>() const {
2440 const Matcher<SizeType> size_matcher_;
2458 operator Matcher<Container>() const {
2501 const Matcher<DistanceType> distance_matcher_;
2620 operator Matcher<LhsContainer>() const {
2676 const Matcher<const ::std::vector<LhsValue>&> matcher_;
2689 // must be able to be safely cast to Matcher<tuple<const T1&, const
2710 operator Matcher<LhsContainer>() const {
2785 const Matcher<InnerMatcherArg> mono_tuple_matcher_;
2837 const Matcher<const Element&> inner_matcher_;
2907 operator Matcher<Container>() const {
2924 operator Matcher<Container>() const {
2976 const Matcher<const KeyType&> inner_matcher_;
2988 operator Matcher<PairType>() const {
3079 const Matcher<const FirstType&> first_matcher_;
3080 const Matcher<const SecondType&> second_matcher_;
3093 operator Matcher<PairType> () const {
3248 ::std::vector<Matcher<const Element&> > matchers_;
3406 typedef ::std::vector<Matcher<const Element&> > MatcherVec;
3444 Matcher<Target> operator()(const Arg& a) const {
3457 operator Matcher<Container>() const {
3461 typedef ::std::vector<Matcher<const Element&> > MatcherVec;
3482 operator Matcher<Container>() const {
3486 typedef ::std::vector<Matcher<const Element&> > MatcherVec;
3511 operator Matcher<Container>() const {
3531 operator Matcher<Container>() const {
3558 operator Matcher<T>() const {
3597 const Matcher<const ArgTuple&> mono_tuple2_matcher_;
3732 inline Matcher<T> A() { return MakeMatcher(new internal::AnyMatcherImpl<T>()); }
3736 inline Matcher<T> An() { return A<T>(); }
3744 // Constructs a Matcher<T> from a 'value' of type T. The constructed
3747 Matcher<T>::Matcher(T value) { *this = Eq(value); }
3753 // TypedEq<T>(x) is just a convenient short-hand for Matcher<T>(Eq(x))
3754 // or Matcher<T>(x), but more readable than the latter.
3759 // can always write Matcher<T>(Lt(5)) to be explicit about the type,
3762 inline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }
3885 WhenDynamicCastTo(const Matcher<To>& inner_matcher) {
4181 // TupleMatcher must be able to be safely cast to Matcher<tuple<const
4212 // cast to Matcher<tuple<const T1&, const T2&> >, where T1 and T2 are