Lines Matching defs:const
309 std::string str() const { return ss_.str(); }
317 StringMatchResultListener(const StringMatchResultListener&) = delete;
318 StringMatchResultListener& operator=(const StringMatchResultListener&) =
339 static Matcher<T> Cast(const M& polymorphic_matcher_or_value) {
360 static Matcher<T> CastImpl(const M& polymorphic_matcher_or_value,
377 static Matcher<T> CastImpl(const M& value,
388 // latter calls bool operator==(const Lhs& lhs, const Rhs& rhs) in the end
390 // (e.g. std::pair<const int, int> vs. std::pair<int, int>).
393 static Matcher<T> CastImpl(const M& value,
404 static Matcher<T> Cast(const Matcher<U>& source_matcher) {
411 explicit Impl(const Matcher<U>& source_matcher)
415 bool MatchAndExplain(T x, MatchResultListener* listener) const override {
433 typename std::conditional<std::is_convertible<T&, const U&>::value,
440 void DescribeTo(::std::ostream* os) const override {
444 void DescribeNegationTo(::std::ostream* os) const override {
449 const Matcher<U> source_matcher_;
458 static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; }
468 operator ::testing::Matcher<T>() const { // NOLINT(runtime/explicit)
490 operator ::testing::Matcher<F>() const { // NOLINT(runtime/explicit)
496 ::testing::Matcher<F> Apply(IndexSequence<tuple_ids...>) const {
502 const std::tuple<Ts...> params_;
512 inline Matcher<T> MatcherCast(const M& matcher) {
519 inline Matcher<T> SafeMatcherCast(const M& polymorphic_matcher_or_value) {
533 inline Matcher<T> SafeMatcherCast(const Matcher<U>& matcher) {
535 static_assert(std::is_convertible<const T&, const U&>::value,
563 inline void PrintIfNotEmpty(const std::string& explanation,
573 inline bool IsReadableTypeName(const std::string& type_name) {
583 // Value cannot be passed by const reference, because some matchers take a
584 // non-const argument.
586 bool MatchPrintAndExplain(Value& value, const Matcher<T>& matcher,
595 const bool match = matcher.MatchAndExplain(value, &inner_listener);
599 const std::string& type_name = GetTypeName<Value>();
617 static bool Matches(const MatcherTuple& matcher_tuple,
618 const ValueTuple& value_tuple) {
628 static void ExplainMatchFailuresTo(const MatcherTuple& matchers,
629 const ValueTuple& values,
639 const Value& value = std::get<N - 1>(values);
662 static bool Matches(const MatcherTuple& /* matcher_tuple */,
663 const ValueTuple& /* value_tuple */) {
668 static void ExplainMatchFailuresTo(const MatcherTuple& /* matchers */,
669 const ValueTuple& /* values */,
679 bool TupleMatches(const MatcherTuple& matcher_tuple,
680 const ValueTuple& value_tuple) {
693 void ExplainMatchFailureTupleTo(const MatcherTuple& matchers,
694 const ValueTuple& values, ::std::ostream* os) {
711 static OutIter Run(Func f, const Tuple& t, OutIter out) {
718 OutIter operator()(Func f, const Tup& t, OutIter out) const {
725 OutIter operator()(Func /* f */, const Tup& /* t */, OutIter out) const {
735 OutIter TransformTupleValues(Func f, const Tuple& t, OutIter out) {
748 bool MatchAndExplain(const T& /* x */, std::ostream* /* listener */) const {
751 void DescribeTo(std::ostream* os) const { *os << "is anything"; }
752 void DescribeNegationTo(::std::ostream* os) const {
765 bool MatchAndExplain(const Pointer& p,
766 MatchResultListener* /* listener */) const {
770 void DescribeTo(::std::ostream* os) const { *os << "is NULL"; }
771 void DescribeNegationTo(::std::ostream* os) const { *os << "isn't NULL"; }
779 bool MatchAndExplain(const Pointer& p,
780 MatchResultListener* /* listener */) const {
784 void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; }
785 void DescribeNegationTo(::std::ostream* os) const { *os << "is NULL"; }
807 // mocking any function types, including those that take non-const
809 // Super below) can be instantiated to either a const type or a
810 // non-const type.
812 // RefMatcher() takes a T& instead of const T&, as we want the
814 // non-const reference.
818 operator Matcher<Super&>() const {
822 // non-const reference, as you cannot implicitly convert a const
823 // reference to a non-const reference.
833 // MatchAndExplain() takes a Super& (as opposed to const Super&)
836 MatchResultListener* listener) const override {
837 *listener << "which is located @" << static_cast<const void*>(&x);
841 void DescribeTo(::std::ostream* os) const override {
846 void DescribeNegationTo(::std::ostream* os) const override {
852 const Super& object_;
859 inline bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs) {
863 inline bool CaseInsensitiveCStringEquals(const wchar_t* lhs,
864 const wchar_t* rhs) {
871 bool CaseInsensitiveStringEquals(const StringType& s1, const StringType& s2) {
878 const typename StringType::value_type nul = 0;
879 const size_t i1 = s1.find(nul), i2 = s2.find(nul);
902 bool MatchAndExplain(const internal::StringView& s,
903 MatchResultListener* listener) const {
906 const StringType& str = std::string(s);
912 // const char*
914 // const wchar_t*
917 bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
926 // This is a template, not just a plain function with const StringType&,
929 bool MatchAndExplain(const MatcheeStringType& s,
930 MatchResultListener* /* listener */) const {
931 const StringType s2(s);
932 const bool eq = case_sensitive_ ? s2 == string_
937 void DescribeTo(::std::ostream* os) const {
941 void DescribeNegationTo(::std::ostream* os) const {
946 void DescribeToHelper(bool expect_eq, ::std::ostream* os) const {
955 const StringType string_;
956 const bool expect_eq_;
957 const bool case_sensitive_;
966 explicit HasSubstrMatcher(const StringType& substring)
970 bool MatchAndExplain(const internal::StringView& s,
971 MatchResultListener* listener) const {
974 const StringType& str = std::string(s);
980 // const char*
982 // const wchar_t*
985 bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
991 // This is a template, not just a plain function with const StringType&,
994 bool MatchAndExplain(const MatcheeStringType& s,
995 MatchResultListener* /* listener */) const {
1000 void DescribeTo(::std::ostream* os) const {
1005 void DescribeNegationTo(::std::ostream* os) const {
1011 const StringType substring_;
1020 explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) {}
1023 bool MatchAndExplain(const internal::StringView& s,
1024 MatchResultListener* listener) const {
1027 const StringType& str = std::string(s);
1033 // const char*
1035 // const wchar_t*
1038 bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
1044 // This is a template, not just a plain function with const StringType&,
1047 bool MatchAndExplain(const MatcheeStringType& s,
1048 MatchResultListener* /* listener */) const {
1049 const StringType& s2(s);
1054 void DescribeTo(::std::ostream* os) const {
1059 void DescribeNegationTo(::std::ostream* os) const {
1065 const StringType prefix_;
1074 explicit EndsWithMatcher(const StringType& suffix) : suffix_(suffix) {}
1077 bool MatchAndExplain(const internal::StringView& s,
1078 MatchResultListener* listener) const {
1081 const StringType& str = std::string(s);
1087 // const char*
1089 // const wchar_t*
1092 bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
1098 // This is a template, not just a plain function with const StringType&,
1101 bool MatchAndExplain(const MatcheeStringType& s,
1102 MatchResultListener* /* listener */) const {
1103 const StringType& s2(s);
1108 void DescribeTo(::std::ostream* os) const {
1113 void DescribeNegationTo(::std::ostream* os) const {
1119 const StringType suffix_;
1129 const Matcher<const std::string&>& internal_matcher)
1134 bool MatchAndExplain(const MatcheeStringType& s,
1135 MatchResultListener* listener) const {
1136 const std::string s2(s); // NOLINT (needed for working with string_view).
1147 void DescribeTo(::std::ostream* os) const {
1152 void DescribeNegationTo(::std::ostream* os) const {
1158 const Matcher<const std::string&> internal_matcher_;
1166 // used to match a std::tuple<int, short>, a std::tuple<const long&, double>,
1173 operator Matcher<::std::tuple<T1, T2>>() const {
1174 return Matcher<::std::tuple<T1, T2>>(new Impl<const ::std::tuple<T1, T2>&>);
1177 operator Matcher<const ::std::tuple<T1, T2>&>() const {
1178 return MakeMatcher(new Impl<const ::std::tuple<T1, T2>&>);
1190 MatchResultListener* /* listener */) const override {
1193 void DescribeTo(::std::ostream* os) const override {
1196 void DescribeNegationTo(::std::ostream* os) const override {
1204 static const char* Desc() { return "an equal pair"; }
1208 static const char* Desc() { return "an unequal pair"; }
1212 static const char* Desc() { return "a pair where the first < the second"; }
1216 static const char* Desc() { return "a pair where the first > the second"; }
1220 static const char* Desc() { return "a pair where the first <= the second"; }
1224 static const char* Desc() { return "a pair where the first >= the second"; }
1232 class NotMatcherImpl : public MatcherInterface<const T&> {
1234 explicit NotMatcherImpl(const Matcher<T>& matcher) : matcher_(matcher) {}
1236 bool MatchAndExplain(const T& x,
1237 MatchResultListener* listener) const override {
1241 void DescribeTo(::std::ostream* os) const override {
1245 void DescribeNegationTo(::std::ostream* os) const override {
1250 const Matcher<T> matcher_;
1263 operator Matcher<T>() const {
1276 class AllOfMatcherImpl : public MatcherInterface<const T&> {
1281 void DescribeTo(::std::ostream* os) const override {
1290 void DescribeNegationTo(::std::ostream* os) const override {
1299 bool MatchAndExplain(const T& x,
1300 MatchResultListener* listener) const override {
1329 const std::vector<Matcher<T>> matchers_;
1339 VariadicMatcher(const Args&... matchers) // NOLINT
1344 VariadicMatcher(const VariadicMatcher&) = default;
1345 VariadicMatcher& operator=(const VariadicMatcher&) = delete;
1351 operator Matcher<T>() const {
1360 std::integral_constant<size_t, I>) const {
1368 std::integral_constant<size_t, sizeof...(Args)>) const {}
1381 class AnyOfMatcherImpl : public MatcherInterface<const T&> {
1386 void DescribeTo(::std::ostream* os) const override {
1395 void DescribeNegationTo(::std::ostream* os) const override {
1404 bool MatchAndExplain(const T& x,
1405 MatchResultListener* listener) const override {
1434 const std::vector<Matcher<T>> matchers_;
1452 operator Matcher<T>() const { // NOLINT(runtime/explicit)
1473 operator Matcher<U>() const { // NOLINT
1476 for (const auto& matcher : matchers_) {
1483 const ::std::vector<T> matchers_;
1505 MatchResultListener* listener) const {
1517 void DescribeTo(::std::ostream* os) const {
1521 void DescribeNegationTo(::std::ostream* os) const {
1543 bool operator()(const T& x) const {
1550 // compile when matcher_ has type Matcher<const T&>; if we write
1551 // Matcher<const T&>(matcher_).Matches(x) here, it won't compile
1556 // MatcherCast<const T&>() is necessary for making the code work
1558 return MatcherCast<const T&>(matcher_).Matches(x);
1576 AssertionResult operator()(const char* value_text, const T& x) const {
1577 // We convert matcher_ to a Matcher<const T&> *now* instead of
1583 // We write SafeMatcherCast<const T&>(matcher_) instead of
1584 // Matcher<const T&>(matcher_), as the latter won't compile when
1586 // We don't write MatcherCast<const T&> either, as that allows
1588 const Matcher<const T&> matcher = SafeMatcherCast<const T&>(matcher_);
1612 const M matcher_;
1630 bool MatchAndExplain(const FloatType& f,
1631 MatchResultListener* /* listener */) const {
1635 void DescribeTo(::std::ostream* os) const { *os << "is NaN"; }
1636 void DescribeNegationTo(::std::ostream* os) const { *os << "isn't NaN"; }
1677 MatchResultListener* listener) const override {
1678 const FloatingPoint<FloatType> actual(value), expected(expected_);
1697 const FloatType diff = value - expected_;
1711 void DescribeTo(::std::ostream* os) const override {
1715 const ::std::streamsize old_precision =
1732 void DescribeNegationTo(::std::ostream* os) const override {
1734 const ::std::streamsize old_precision =
1753 bool HasMaxAbsError() const { return max_abs_error_ >= 0; }
1755 const FloatType expected_;
1756 const bool nan_eq_nan_;
1758 const FloatType max_abs_error_;
1763 // Matcher<const float&>, or a Matcher<float&>, but nothing else.
1764 operator Matcher<FloatType>() const {
1769 operator Matcher<const FloatType&>() const {
1771 new Impl<const FloatType&>(expected_, nan_eq_nan_, max_abs_error_));
1774 operator Matcher<FloatType&>() const {
1780 const FloatType expected_;
1781 const bool nan_eq_nan_;
1783 const FloatType max_abs_error_;
1807 operator Matcher<::std::tuple<T1, T2>>() const {
1812 operator Matcher<const ::std::tuple<T1, T2>&>() const {
1814 new Impl<const ::std::tuple<T1, T2>&>(max_abs_error_, nan_eq_nan_));
1829 MatchResultListener* listener) const override {
1841 void DescribeTo(::std::ostream* os) const override {
1844 void DescribeNegationTo(::std::ostream* os) const override {
1850 const bool nan_eq_nan_;
1866 explicit PointeeMatcher(const InnerMatcher& matcher) : matcher_(matcher) {}
1877 operator Matcher<Pointer>() const {
1878 return Matcher<Pointer>(new Impl<const Pointer&>(matcher_));
1890 explicit Impl(const InnerMatcher& matcher)
1891 : matcher_(MatcherCast<const Pointee&>(matcher)) {}
1893 void DescribeTo(::std::ostream* os) const override {
1898 void DescribeNegationTo(::std::ostream* os) const override {
1904 MatchResultListener* listener) const override {
1912 const Matcher<const Pointee&> matcher_;
1915 const InnerMatcher matcher_;
1925 explicit PointerMatcher(const InnerMatcher& matcher) : matcher_(matcher) {}
1936 operator Matcher<PointerType>() const { // NOLINT
1937 return Matcher<PointerType>(new Impl<const PointerType&>(matcher_));
1946 const typename std::pointer_traits<GTEST_REMOVE_REFERENCE_AND_CONST_(
1949 explicit Impl(const InnerMatcher& matcher)
1952 void DescribeTo(::std::ostream* os) const override {
1957 void DescribeNegationTo(::std::ostream* os) const override {
1963 MatchResultListener* listener) const override {
1973 const InnerMatcher matcher_;
1986 explicit WhenDynamicCastToMatcherBase(const Matcher<To>& matcher)
1989 void DescribeTo(::std::ostream* os) const {
1994 void DescribeNegationTo(::std::ostream* os) const {
2000 const Matcher<To> matcher_;
2015 explicit WhenDynamicCastToMatcher(const Matcher<To>& matcher)
2019 bool MatchAndExplain(From from, MatchResultListener* listener) const {
2030 explicit WhenDynamicCastToMatcher(const Matcher<To&>& matcher)
2034 bool MatchAndExplain(From& from, MatchResultListener* listener) const {
2052 const Matcher<const FieldType&>& matcher)
2055 FieldMatcher(const std::string& field_name, FieldType Class::*field,
2056 const Matcher<const FieldType&>& matcher)
2061 void DescribeTo(::std::ostream* os) const {
2066 void DescribeNegationTo(::std::ostream* os) const {
2072 bool MatchAndExplain(const T& value, MatchResultListener* listener) const {
2082 const Class& obj,
2083 MatchResultListener* listener) const {
2088 bool MatchAndExplainImpl(std::true_type /* is_pointer */, const Class* p,
2089 MatchResultListener* listener) const {
2099 const FieldType Class::*field_;
2100 const Matcher<const FieldType&> matcher_;
2104 const std::string whose_field_;
2110 // Property is a const-qualified member function of Class returning
2115 typedef const PropertyType& RefToConstProperty;
2117 PropertyMatcher(Property property, const Matcher<RefToConstProperty>& matcher)
2122 PropertyMatcher(const std::string& property_name, Property property,
2123 const Matcher<RefToConstProperty>& matcher)
2128 void DescribeTo(::std::ostream* os) const {
2133 void DescribeNegationTo(::std::ostream* os) const {
2139 bool MatchAndExplain(const T& value, MatchResultListener* listener) const {
2147 const Class& obj,
2148 MatchResultListener* listener) const {
2151 // which takes a non-const reference as argument.
2156 bool MatchAndExplainImpl(std::true_type /* is_pointer */, const Class* p,
2157 MatchResultListener* listener) const {
2168 const Matcher<RefToConstProperty> matcher_;
2172 const std::string whose_property_;
2184 static auto Invoke(Functor f, const T& arg) -> decltype(f(arg)) {
2214 ResultOfMatcher(const std::string& result_description, Callable callable,
2223 operator Matcher<T>() const {
2225 new Impl<const T&>(result_description_, callable_, matcher_));
2238 Impl(const std::string& result_description,
2239 const CallableStorageType& callable, const M& matcher)
2244 void DescribeTo(::std::ostream* os) const override {
2253 void DescribeNegationTo(::std::ostream* os) const override {
2262 bool MatchAndExplain(T obj, MatchResultListener* listener) const override {
2269 // takes a non-const reference as argument.
2271 // be a non-const reference (e.g. Matcher<Uncopyable&>).
2278 const std::string result_description_;
2279 // Functors often define operator() as non-const method even though
2281 // 'this' is a const pointer. It's the user's responsibility not to
2285 const Matcher<ResultType> matcher_;
2288 const std::string result_description_;
2289 const CallableStorageType callable_;
2290 const InnerMatcher matcher_;
2297 explicit SizeIsMatcher(const SizeMatcher& size_matcher)
2301 operator Matcher<Container>() const {
2302 return Matcher<Container>(new Impl<const Container&>(size_matcher_));
2309 explicit Impl(const SizeMatcher& size_matcher)
2312 void DescribeTo(::std::ostream* os) const override {
2316 void DescribeNegationTo(::std::ostream* os) const override {
2322 MatchResultListener* listener) const override {
2325 const bool result = size_matcher_.MatchAndExplain(size, &size_listener);
2333 const Matcher<SizeType> size_matcher_;
2337 const SizeMatcher size_matcher_;
2345 explicit BeginEndDistanceIsMatcher(const DistanceMatcher& distance_matcher)
2349 operator Matcher<Container>() const {
2350 return Matcher<Container>(new Impl<const Container&>(distance_matcher_));
2362 explicit Impl(const DistanceMatcher& distance_matcher)
2365 void DescribeTo(::std::ostream* os) const override {
2369 void DescribeNegationTo(::std::ostream* os) const override {
2375 MatchResultListener* listener) const override {
2380 const bool result =
2389 const Matcher<DistanceType> distance_matcher_;
2393 const DistanceMatcher distance_matcher_;
2414 "Container type must not be const");
2420 explicit ContainerEqMatcher(const Container& expected)
2423 void DescribeTo(::std::ostream* os) const {
2427 void DescribeNegationTo(::std::ostream* os) const {
2433 bool MatchAndExplain(const LhsContainer& lhs,
2434 MatchResultListener* listener) const {
2441 ::std::ostream* const os = listener->stream();
2481 const StlContainer expected_;
2487 bool operator()(const T& lhs, const U& rhs) const {
2496 WhenSortedByMatcher(const Comparator& comparator,
2497 const ContainerMatcher& matcher)
2501 operator Matcher<LhsContainer>() const {
2513 // Transforms std::pair<const Key, Value> into std::pair<Key, Value>
2519 Impl(const Comparator& comparator, const ContainerMatcher& matcher)
2522 void DescribeTo(::std::ostream* os) const override {
2527 void DescribeNegationTo(::std::ostream* os) const override {
2533 MatchResultListener* listener) const override {
2551 const bool match =
2558 const Comparator comparator_;
2559 const Matcher<const ::std::vector<LhsValue>&> matcher_;
2561 Impl(const Impl&) = delete;
2562 Impl& operator=(const Impl&) = delete;
2566 const Comparator comparator_;
2567 const ContainerMatcher matcher_;
2571 // must be able to be safely cast to Matcher<std::tuple<const T1&, const
2586 "RhsContainer type must not be const");
2592 PointwiseMatcher(const TupleMatcher& tuple_matcher, const RhsContainer& rhs)
2596 operator Matcher<LhsContainer>() const {
2602 new Impl<const LhsContainer&>(tuple_matcher_, rhs_));
2618 typedef ::std::tuple<const LhsValue&, const RhsValue&> InnerMatcherArg;
2620 Impl(const TupleMatcher& tuple_matcher, const RhsStlContainer& rhs)
2625 void DescribeTo(::std::ostream* os) const override {
2632 void DescribeNegationTo(::std::ostream* os) const override {
2642 MatchResultListener* listener) const override {
2644 const size_t actual_size = lhs_stl_container.size();
2656 // *left and *right. Dereference or the conversion to `const T&` may
2659 InnerMatcherArg(ImplicitCast_<const LhsValue&>(*left),
2660 ImplicitCast_<const RhsValue&>(*right)),
2672 InnerMatcherArg(ImplicitCast_<const LhsValue&>(*left),
2673 ImplicitCast_<const RhsValue&>(*right))))
2682 const Matcher<InnerMatcherArg> mono_tuple_matcher_;
2683 const RhsStlContainer rhs_;
2687 const TupleMatcher tuple_matcher_;
2688 const RhsStlContainer rhs_;
2704 testing::SafeMatcherCast<const Element&>(inner_matcher)) {}
2710 MatchResultListener* listener) const {
2716 const bool matches = inner_matcher_.MatchAndExplain(*it, &inner_listener);
2728 bool MatchAndExplainImpl(const Matcher<size_t>& count_matcher,
2730 MatchResultListener* listener) const {
2737 const bool matches = inner_matcher_.MatchAndExplain(*it, &inner_listener);
2777 const Matcher<const Element&> inner_matcher_;
2790 void DescribeTo(::std::ostream* os) const override {
2795 void DescribeNegationTo(::std::ostream* os) const override {
2801 MatchResultListener* listener) const override {
2816 void DescribeTo(::std::ostream* os) const override {
2821 void DescribeNegationTo(::std::ostream* os) const override {
2827 MatchResultListener* listener) const override {
2843 void DescribeTo(::std::ostream* os) const override {
2850 void DescribeNegationTo(::std::ostream* os) const override {
2858 MatchResultListener* listener) const override {
2863 const Matcher<size_t> count_matcher_;
2874 operator Matcher<Container>() const { // NOLINT
2875 return Matcher<Container>(new ContainsTimesMatcherImpl<const Container&>(
2880 const M inner_matcher_;
2881 const Matcher<size_t> count_matcher_;
2891 operator Matcher<Container>() const { // NOLINT
2893 new ContainsMatcherImpl<const Container&>(inner_matcher_));
2896 ContainsTimesMatcher<M> Times(Matcher<size_t> count_matcher) const {
2901 const M inner_matcher_;
2911 operator Matcher<Container>() const { // NOLINT
2913 new EachMatcherImpl<const Container&>(inner_matcher_));
2917 const M inner_matcher_;
2957 testing::SafeMatcherCast<const KeyType&>(inner_matcher)) {}
2962 MatchResultListener* listener) const override {
2964 const bool match = inner_matcher_.MatchAndExplain(
2966 const std::string explanation = inner_listener.str();
2974 void DescribeTo(::std::ostream* os) const override {
2980 void DescribeNegationTo(::std::ostream* os) const override {
2986 const Matcher<const KeyType&> inner_matcher_;
2996 operator Matcher<PairType>() const {
2998 new KeyMatcherImpl<const PairType&>(matcher_for_key_));
3002 const M matcher_for_key_;
3012 operator Matcher<Type>() const { // NOLINT
3013 return Matcher<Type>(new Impl<const Type&>(matcher_));
3021 using Address = const GTEST_REMOVE_REFERENCE_AND_CONST_(Type) *;
3022 explicit Impl(const InnerMatcher& matcher)
3025 void DescribeTo(::std::ostream* os) const override {
3030 void DescribeNegationTo(::std::ostream* os) const override {
3036 MatchResultListener* listener) const override {
3043 const Matcher<Address> matcher_;
3045 const InnerMatcher matcher_;
3060 testing::SafeMatcherCast<const FirstType&>(first_matcher)),
3062 testing::SafeMatcherCast<const SecondType&>(second_matcher)) {}
3065 void DescribeTo(::std::ostream* os) const override {
3073 void DescribeNegationTo(::std::ostream* os) const override {
3083 MatchResultListener* listener) const override {
3110 void ExplainSuccess(const std::string& first_explanation,
3111 const std::string& second_explanation,
3112 MatchResultListener* listener) const {
3128 const Matcher<const FirstType&> first_matcher_;
3129 const Matcher<const SecondType&> second_matcher_;
3140 operator Matcher<PairType>() const {
3142 new PairMatcherImpl<const PairType&>(first_matcher_, second_matcher_));
3146 const FirstMatcher first_matcher_;
3147 const SecondMatcher second_matcher_;
3151 auto UnpackStructImpl(const T& t, IndexSequence<I...>, int)
3160 auto UnpackStructImpl(const T& t, MakeIndexSequence<1>, char) {
3161 const auto& [a] = t;
3165 auto UnpackStructImpl(const T& t, MakeIndexSequence<2>, char) {
3166 const auto& [a, b] = t;
3170 auto UnpackStructImpl(const T& t, MakeIndexSequence<3>, char) {
3171 const auto& [a, b, c] = t;
3175 auto UnpackStructImpl(const T& t, MakeIndexSequence<4>, char) {
3176 const auto& [a, b, c, d] = t;
3180 auto UnpackStructImpl(const T& t, MakeIndexSequence<5>, char) {
3181 const auto& [a, b, c, d, e] = t;
3185 auto UnpackStructImpl(const T& t, MakeIndexSequence<6>, char) {
3186 const auto& [a, b, c, d, e, f] = t;
3190 auto UnpackStructImpl(const T& t, MakeIndexSequence<7>, char) {
3191 const auto& [a, b, c, d, e, f, g] = t;
3195 auto UnpackStructImpl(const T& t, MakeIndexSequence<8>, char) {
3196 const auto& [a, b, c, d, e, f, g, h] = t;
3200 auto UnpackStructImpl(const T& t, MakeIndexSequence<9>, char) {
3201 const auto& [a, b, c, d, e, f, g, h, i] = t;
3205 auto UnpackStructImpl(const T& t, MakeIndexSequence<10>, char) {
3206 const auto& [a, b, c, d, e, f, g, h, i, j] = t;
3210 auto UnpackStructImpl(const T& t, MakeIndexSequence<11>, char) {
3211 const auto& [a, b, c, d, e, f, g, h, i, j, k] = t;
3215 auto UnpackStructImpl(const T& t, MakeIndexSequence<12>, char) {
3216 const auto& [a, b, c, d, e, f, g, h, i, j, k, l] = t;
3220 auto UnpackStructImpl(const T& t, MakeIndexSequence<13>, char) {
3221 const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m] = t;
3225 auto UnpackStructImpl(const T& t, MakeIndexSequence<14>, char) {
3226 const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n] = t;
3230 auto UnpackStructImpl(const T& t, MakeIndexSequence<15>, char) {
3231 const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o] = t;
3235 auto UnpackStructImpl(const T& t, MakeIndexSequence<16>, char) {
3236 const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p] = t;
3240 auto UnpackStructImpl(const T& t, MakeIndexSequence<17>, char) {
3241 const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q] = t;
3245 auto UnpackStructImpl(const T& t, MakeIndexSequence<18>, char) {
3246 const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = t;
3250 auto UnpackStructImpl(const T& t, MakeIndexSequence<19>, char) {
3251 const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s] = t;
3257 auto UnpackStruct(const T& t)
3266 void VariadicExpand(const T (&)[N]) {}
3275 decltype(UnpackStruct<sizeof...(I)>(std::declval<const Struct&>()));
3277 Matcher<const typename std::tuple_element<I, UnpackedType>::type&>...>;
3281 explicit FieldsAreMatcherImpl(const Inner& matchers)
3283 const typename std::tuple_element<I, UnpackedType>::type&>(
3286 void DescribeTo(::std::ostream* os) const override {
3287 const char* separator = "";
3293 void DescribeNegationTo(::std::ostream* os) const override {
3294 const char* separator = "";
3300 bool MatchAndExplain(Struct t, MatchResultListener* listener) const override {
3305 bool MatchInternal(UnpackedType tuple, MatchResultListener* listener) const {
3331 const char* separator = ", where";
3333 const std::string str = inner_listener[index].str();
3352 operator Matcher<Struct>() const { // NOLINT
3354 new FieldsAreMatcherImpl<const Struct&, IndexSequenceFor<Inner...>>(
3377 matchers_.push_back(MatcherCast<const Element&>(*first++));
3382 void DescribeTo(::std::ostream* os) const override {
3401 void DescribeNegationTo(::std::ostream* os) const override {
3418 MatchResultListener* listener) const override {
3422 const bool listener_interested = listener->IsInterested();
3484 const std::string& s = explanations[i];
3502 size_t count() const { return matchers_.size(); }
3504 ::std::vector<Matcher<const Element&>> matchers_;
3518 size_t LhsSize() const { return num_elements_; }
3519 size_t RhsSize() const { return num_matchers_; }
3520 bool HasEdge(size_t ilhs, size_t irhs) const {
3534 std::string DebugString() const;
3537 size_t SpaceIndex(size_t ilhs, size_t irhs) const {
3555 GTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix& g);
3577 typedef ::std::vector<const MatcherDescriberInterface*> MatcherDescriberVec;
3580 void DescribeToImpl(::std::ostream* os) const;
3583 void DescribeNegationToImpl(::std::ostream* os) const;
3585 bool VerifyMatchMatrix(const ::std::vector<std::string>& element_printouts,
3586 const MatchMatrix& matrix,
3587 MatchResultListener* listener) const;
3589 bool FindPairing(const MatchMatrix& matrix,
3590 MatchResultListener* listener) const;
3598 UnorderedMatcherRequire::Flags match_flags() const { return match_flags_; }
3623 matchers_.push_back(MatcherCast<const Element&>(*first));
3625 for (const auto& m : matchers_) {
3631 void DescribeTo(::std::ostream* os) const override {
3636 void DescribeNegationTo(::std::ostream* os) const override {
3641 MatchResultListener* listener) const override {
3656 MatchResultListener* listener) const {
3681 ::std::vector<Matcher<const Element&>> matchers_;
3689 Matcher<Target> operator()(const Arg& a) const {
3698 explicit UnorderedElementsAreMatcher(const MatcherTuple& args)
3702 operator Matcher<Container>() const {
3706 typedef ::std::vector<Matcher<const Element&>> MatcherVec;
3709 TransformTupleValues(CastAndAppendTransform<const Element&>(), matchers_,
3712 new UnorderedElementsAreMatcherImpl<const Container&>(
3718 const MatcherTuple matchers_;
3725 explicit ElementsAreMatcher(const MatcherTuple& args) : matchers_(args) {}
3728 operator Matcher<Container>() const {
3737 typedef ::std::vector<Matcher<const Element&>> MatcherVec;
3740 TransformTupleValues(CastAndAppendTransform<const Element&>(), matchers_,
3742 return Matcher<Container>(new ElementsAreMatcherImpl<const Container&>(
3747 const MatcherTuple matchers_;
3760 operator Matcher<Container>() const {
3762 new UnorderedElementsAreMatcherImpl<const Container&>(
3779 operator Matcher<Container>() const {
3784 return Matcher<Container>(new ElementsAreMatcherImpl<const Container&>(
3789 const ::std::vector<T> matchers_;
3804 BoundSecondMatcher(const Tuple2Matcher& tm, const Second& second)
3807 BoundSecondMatcher(const BoundSecondMatcher& other) = default;
3810 operator Matcher<T>() const {
3822 void operator=(const BoundSecondMatcher& /*rhs*/) {
3832 Impl(const Tuple2Matcher& tm, const Second& second)
3833 : mono_tuple2_matcher_(SafeMatcherCast<const ArgTuple&>(tm)),
3836 void DescribeTo(::std::ostream* os) const override {
3843 bool MatchAndExplain(T x, MatchResultListener* listener) const override {
3849 const Matcher<const ArgTuple&> mono_tuple2_matcher_;
3850 const Second second_value_;
3853 const Tuple2Matcher tuple2_matcher_;
3854 const Second second_value_;
3863 const Tuple2Matcher& tm, const Second& second) {
3873 bool negation, const char* matcher_name,
3874 const std::vector<const char*>& param_names, const Strings& param_values);
3880 explicit OptionalMatcher(const ValueMatcher& value_matcher)
3884 operator Matcher<Optional>() const {
3885 return Matcher<Optional>(new Impl<const Optional&>(value_matcher_));
3893 explicit Impl(const ValueMatcher& value_matcher)
3896 void DescribeTo(::std::ostream* os) const override {
3901 void DescribeNegationTo(::std::ostream* os) const override {
3907 MatchResultListener* listener) const override {
3912 const ValueType& value = *optional;
3914 const bool match = value_matcher_.MatchAndExplain(value, &value_listener);
3922 const Matcher<ValueType> value_matcher_;
3926 const ValueMatcher value_matcher_;
3940 explicit VariantMatcher(::testing::Matcher<const T&> matcher)
3944 bool MatchAndExplain(const Variant& value,
3945 ::testing::MatchResultListener* listener) const {
3956 const T& elem = get<T>(value);
3958 const bool match = matcher_.MatchAndExplain(elem, &elem_listener);
3965 void DescribeTo(std::ostream* os) const {
3971 void DescribeNegationTo(std::ostream* os) const {
3986 const ::testing::Matcher<const T&> matcher_;
4001 explicit AnyCastMatcher(const ::testing::Matcher<const T&>& matcher)
4005 bool MatchAndExplain(const AnyType& value,
4006 ::testing::MatchResultListener* listener) const {
4008 const T* ptr = any_cast<T>(&value);
4012 const T* elem = any_cast<T>(&value);
4019 const bool match = matcher_.MatchAndExplain(*elem, &elem_listener);
4026 void DescribeTo(std::ostream* os) const {
4032 void DescribeNegationTo(std::ostream* os) const {
4047 const ::testing::Matcher<const T&> matcher_;
4059 using MonomorphicInnerMatcher = Matcher<const SelectedArgs&>;
4062 explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
4063 : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
4066 MatchResultListener* listener) const override {
4069 const SelectedArgs& selected_args =
4077 const bool match =
4083 void DescribeTo(::std::ostream* os) const override {
4089 void DescribeNegationTo(::std::ostream* os) const override {
4099 const char* sep = "";
4106 const char* dummy[] = {
4122 operator Matcher<ArgsTuple>() const { // NOLINT
4156 inline auto ElementsAreArray(const T* pointer, size_t count)
4162 inline auto ElementsAreArray(const T (&array)[N])
4168 inline auto ElementsAreArray(const Container& container)
4203 const T* pointer, size_t count) {
4209 const T (&array)[N]) {
4216 UnorderedElementsAreArray(const Container& container) {
4235 const internal::AnythingMatcher _ = {};
4250 const M& value, std::false_type /* convertible_to_matcher */,
4339 const InnerMatcher& inner_matcher) {
4352 WhenDynamicCastTo(const Matcher<To>& inner_matcher) {
4364 FieldType Class::*field, const FieldMatcher& matcher) {
4366 field, MatcherCast<const FieldType&>(matcher)));
4377 const std::string& field_name, FieldType Class::*field,
4378 const FieldMatcher& matcher) {
4380 field_name, field, MatcherCast<const FieldType&>(matcher)));
4389 Class, PropertyType, PropertyType (Class::*)() const>>
4390 Property(PropertyType (Class::*property)() const,
4391 const PropertyMatcher& matcher) {
4394 PropertyType (Class::*)() const>(
4395 property, MatcherCast<const PropertyType&>(matcher)));
4406 Class, PropertyType, PropertyType (Class::*)() const>>
4407 Property(const std::string& property_name,
4408 PropertyType (Class::*property)() const,
4409 const PropertyMatcher& matcher) {
4412 PropertyType (Class::*)() const>(
4413 property_name, property, MatcherCast<const PropertyType&>(matcher)));
4419 Class, PropertyType, PropertyType (Class::*)() const&>>
4420 Property(PropertyType (Class::*property)() const&,
4421 const PropertyMatcher& matcher) {
4424 PropertyType (Class::*)() const&>(
4425 property, MatcherCast<const PropertyType&>(matcher)));
4431 Class, PropertyType, PropertyType (Class::*)() const&>>
4432 Property(const std::string& property_name,
4433 PropertyType (Class::*property)() const&,
4434 const PropertyMatcher& matcher) {
4437 PropertyType (Class::*)() const&>(
4438 property_name, property, MatcherCast<const PropertyType&>(matcher)));
4460 const std::string& result_description, Callable callable,
4471 const internal::StringLike<T>& str) {
4479 const internal::StringLike<T>& str) {
4487 const internal::StringLike<T>& str) {
4495 const internal::StringLike<T>& str) {
4504 const internal::StringLike<T>& substring) {
4512 const internal::StringLike<T>& prefix) {
4520 const internal::StringLike<T>& suffix) {
4530 const std::wstring& str) {
4537 const std::wstring& str) {
4544 const std::wstring& str) {
4551 const std::wstring& str) {
4559 const std::wstring& substring) {
4566 const std::wstring& prefix) {
4573 const std::wstring& suffix) {
4680 const SizeMatcher& size_matcher) {
4691 const DistanceMatcher& distance_matcher) {
4702 ContainerEq(const Container& rhs) {
4710 const Comparator& comparator, const ContainerMatcher& container_matcher) {
4719 WhenSorted(const ContainerMatcher& container_matcher) {
4728 // TupleMatcher must be able to be safely cast to Matcher<std::tuple<const
4729 // T1&, const T2&> >, where T1 and T2 are the types of elements in the
4734 Pointwise(const TupleMatcher& tuple_matcher, const Container& rhs) {
4742 const TupleMatcher& tuple_matcher, std::initializer_list<T> rhs) {
4751 // cast to Matcher<std::tuple<const T1&, const T2&> >, where T1 and T2 are
4763 UnorderedPointwise(const Tuple2Matcher& tuple2_matcher,
4764 const RhsContainer& rhs_container) {
4770 const RhsStlContainer& rhs_stl_container =
4788 UnorderedPointwise(const Tuple2Matcher& tuple2_matcher,
4807 // Contains(::std::pair<const int, size_t>(1, 100)));
4809 // const char* user_ids[] = { "joe", "mike", "tom" };
4867 const T* pointer, size_t count) {
4873 const T (&array)[N]) {
4880 IsSupersetOf(const Container& container) {
4924 const T* pointer, size_t count) {
4930 const T (&array)[N]) {
4937 IsSubsetOf(const Container& container) {
4972 // const char* user_ids[] = { "joe", "mike", "tom" };
5027 const InnerMatcher& inner_matcher) {
5035 const InnerMatcher& inner_matcher) {
5043 const MatcherType& internal_matcher) {
5057 inline bool Value(const T& value, M matcher) {
5064 inline bool ExplainMatchResult(M matcher, const T& value,
5066 return SafeMatcherCast<const T&>(matcher).MatchAndExplain(value, listener);
5081 std::string DescribeMatcher(const M& matcher, bool negation = false) {
5094 std::tuple<typename std::decay<const Args&>::type...>>
5095 ElementsAre(const Args&... matchers) {
5097 std::tuple<typename std::decay<const Args&>::type...>>(
5103 std::tuple<typename std::decay<const Args&>::type...>>
5104 UnorderedElementsAre(const Args&... matchers) {
5106 std::tuple<typename std::decay<const Args&>::type...>>(
5112 internal::AllOfMatcher<typename std::decay<const Args&>::type...> AllOf(
5113 const Args&... matchers) {
5114 return internal::AllOfMatcher<typename std::decay<const Args&>::type...>(
5119 internal::AnyOfMatcher<typename std::decay<const Args&>::type...> AnyOf(
5120 const Args&... matchers) {
5121 return internal::AnyOfMatcher<typename std::decay<const Args&>::type...>(
5164 inline internal::AnyOfArrayMatcher<T> AnyOfArray(const T* ptr, size_t count) {
5169 inline internal::AllOfArrayMatcher<T> AllOfArray(const T* ptr, size_t count) {
5174 inline internal::AnyOfArrayMatcher<T> AnyOfArray(const T (&array)[N]) {
5179 inline internal::AllOfArrayMatcher<T> AllOfArray(const T (&array)[N]) {
5185 const Container& container) {
5191 const Container& container) {
5225 inline InnerMatcher AllArgs(const InnerMatcher& matcher) {
5239 const ValueMatcher& value_matcher) {
5246 const Matcher<const T&>& matcher) {
5257 const Matcher<const T&>& matcher) {
5273 void DescribeTo(std::ostream* os) const {
5278 void DescribeNegationTo(std::ostream* os) const {
5284 bool MatchAndExplain(const Err& err, MatchResultListener* listener) const {
5291 const Matcher<std::string> matcher_;
5303 const char* what() const noexcept {
5313 // catch (const Err&) { /* an expected exception */ }
5314 // catch (const std::exception&) { /* exception of a wrong type */ }
5320 // catch (const std::exception&) { /* an expected exception */ }
5321 // catch (const std::exception&) { /* exception of a wrong type */ }
5327 // catch (const std::exception&) { /* an expected exception */ }
5328 // catch (const NeverThrown&) { /* exception of a wrong type */ }
5333 const NeverThrown&, const std::exception&>::type;
5336 ExceptionMatcherImpl(Matcher<const Err&> matcher)
5339 void DescribeTo(std::ostream* os) const {
5345 void DescribeNegationTo(std::ostream* os) const {
5352 bool MatchAndExplain(T&& x, MatchResultListener* listener) const {
5355 } catch (const Err& err) {
5378 const Matcher<const Err&> matcher_;
5408 internal::ExceptionMatcherImpl<Err>(A<const Err&>()));
5413 const ExceptionMatcher& exception_matcher) {
5418 SafeMatcherCast<const Err&>(exception_matcher)));
5449 class gmock_Impl : public ::testing::MatcherInterface<const arg_type&> { \
5453 const arg_type& arg, \
5454 ::testing::MatchResultListener* result_listener) const override; \
5455 void DescribeTo(::std::ostream* gmock_os) const override { \
5458 void DescribeNegationTo(::std::ostream* gmock_os) const override { \
5463 ::std::string FormatDescription(bool negation) const { \
5483 const arg_type& arg, \
5485 const
5529 class gmock_Impl : public ::testing::MatcherInterface<const arg_type&> { \
5534 const arg_type& arg, \
5535 ::testing::MatchResultListener* result_listener) const override; \
5536 void DescribeTo(::std::ostream* gmock_os) const override { \
5539 void DescribeNegationTo(::std::ostream* gmock_os) const override { \
5545 ::std::string FormatDescription(bool negation) const { \
5567 arg_type>::MatchAndExplain(const arg_type& arg, \
5570 const
5597 const arg##_type arg;