Home | History | Annotate | Download | only in gmock

Lines Matching defs:const

71 //   bool InterestedInWhy(bool result) const;
84 MatchResultListener& operator<<(const T& x) {
97 bool IsInterested() const { return stream_ != NULL; }
100 ::std::ostream* const stream_;
128 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;
135 virtual void DescribeTo(::std::ostream* os) const = 0;
143 virtual void DescribeNegationTo(::std::ostream* os) const {
179 internal::string str() const { return ss_.str(); }
195 bool MatchAndExplain(T x, MatchResultListener* listener) const {
200 bool Matches(T x) const {
206 void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }
209 void DescribeNegationTo(::std::ostream* os) const {
214 void ExplainMatchResultTo(T x, ::std::ostream* os) const {
223 explicit MatcherBase(const MatcherInterface<T>* impl)
240 ::testing::internal::linked_ptr<const MatcherInterface<T> > impl_;
247 // implementation of Matcher<T> is just a linked_ptr to const
259 explicit Matcher(const MatcherInterface<T>* impl)
271 class GTEST_API_ Matcher<const internal::string&>
272 : public internal::MatcherBase<const internal::string&> {
276 explicit Matcher(const MatcherInterface<const internal::string&>* impl)
277 : internal::MatcherBase<const internal::string&>(impl) {}
281 Matcher(const internal::string& s); // NOLINT
284 Matcher(const char* s); // NOLINT
293 explicit Matcher(const MatcherInterface<internal::string>* impl)
298 Matcher(const internal::string& s); // NOLINT
301 Matcher(const char* s); // NOLINT
312 // bool MatchAndExplain(const Value& value,
313 // MatchResultListener* listener) const;
319 explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {}
327 const Impl& impl() const { return impl_; }
330 operator Matcher<T>() const {
338 explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
340 virtual void DescribeTo(::std::ostream* os) const {
344 virtual void DescribeNegationTo(::std::ostream* os) const {
348 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
353 const Impl impl_;
369 // Matcher<const string&>(foo);
371 inline Matcher<T> MakeMatcher(const MatcherInterface<T>* impl) {
383 inline PolymorphicMatcher<Impl> MakePolymorphicMatcher(const Impl& impl) {
452 static Matcher<T> Cast(const Matcher<U>& source_matcher) {
459 explicit Impl(const Matcher<U>& source_matcher)
463 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
467 virtual void DescribeTo(::std::ostream* os) const {
471 virtual void DescribeNegationTo(::std::ostream* os) const {
476 const Matcher<U> source_matcher_;
487 static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; }
506 // template <T, U> ... (const Matcher<U>&)
528 static inline Matcher<T> Cast(const Matcher<U>& matcher) {
541 const bool kTIsOther = GMOCK_KIND_OF_(RawT) == internal::kOther;
542 const bool kUIsOther = GMOCK_KIND_OF_(RawU) == internal::kOther;
552 inline Matcher<T> SafeMatcherCast(const M& polymorphic_matcher) {
565 inline void PrintIfNotEmpty(const internal::string& explanation,
575 inline bool IsReadableTypeName(const string& type_name) {
585 // Value cannot be passed by const reference, because some matchers take a
586 // non-const argument.
588 bool MatchPrintAndExplain(Value& value, const Matcher<T>& matcher,
597 const bool match = matcher.MatchAndExplain(value, &inner_listener);
601 const string& type_name = GetTypeName<Value>();
619 static bool Matches(const MatcherTuple& matcher_tuple,
620 const ValueTuple& value_tuple) {
631 static void ExplainMatchFailuresTo(const MatcherTuple& matchers,
632 const ValueTuple& values,
670 static bool Matches(const MatcherTuple& /* matcher_tuple */,
671 const ValueTuple& /* value_tuple */) {
676 static void ExplainMatchFailuresTo(const MatcherTuple& /* matchers */,
677 const ValueTuple& /* values */,
687 bool TupleMatches(const MatcherTuple& matcher_tuple,
688 const ValueTuple& value_tuple) {
702 void ExplainMatchFailureTupleTo(const MatcherTuple& matchers,
703 const ValueTuple& values,
715 T /* x */, MatchResultListener* /* listener */) const { return true; }
716 virtual void DescribeTo(::std::ostream* os) const { *os << "is anything"; }
717 virtual void DescribeNegationTo(::std::ostream* os) const {
732 operator Matcher<T>() const { return A<T>(); }
747 // a "bare" type (i.e. neither 'const T' nor 'T&').
752 explicit name##Matcher(const Rhs& rhs) : rhs_(rhs) {} \
754 operator Matcher<Lhs>() const { \
761 explicit Impl(const Rhs& rhs) : rhs_(rhs) {} \
763 Lhs lhs, MatchResultListener* /* listener */) const { \
766 virtual void DescribeTo(::std::ostream* os) const { \
770 virtual void DescribeNegationTo(::std::ostream* os) const { \
798 bool MatchAndExplain(const Pointer& p,
799 MatchResultListener* /* listener */) const {
803 void DescribeTo(::std::ostream* os) const { *os << "is NULL"; }
804 void DescribeNegationTo(::std::ostream* os) const {
814 bool MatchAndExplain(const Pointer& p,
815 MatchResultListener* /* listener */) const {
819 void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; }
820 void DescribeNegationTo(::std::ostream* os) const {
844 // mocking any function types, including those that take non-const
846 // Super below) can be instantiated to either a const type or a
847 // non-const type.
849 // RefMatcher() takes a T& instead of const T&, as we want the
851 // non-const reference.
855 operator Matcher<Super&>() const {
859 // non-const reference, as you cannot implicitly convert a const
860 // reference to a non-const reference.
870 // MatchAndExplain() takes a Super& (as opposed to const Super&)
873 Super& x, MatchResultListener* listener) const {
874 *listener << "which is located @" << static_cast<const void*>(&x);
878 virtual void DescribeTo(::std::ostream* os) const {
883 virtual void DescribeNegationTo(::std::ostream* os) const {
889 const Super& object_;
900 inline bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs) {
904 inline bool CaseInsensitiveCStringEquals(const wchar_t* lhs,
905 const wchar_t* rhs) {
912 bool CaseInsensitiveStringEquals(const StringType& s1,
913 const StringType& s2) {
920 const typename StringType::value_type nul = 0;
921 const size_t i1 = s1.find(nul), i2 = s2.find(nul);
940 StrEqualityMatcher(const StringType& str, bool expect_eq,
947 MatchResultListener* listener) const {
954 bool MatchAndExplain(const StringType& s,
955 MatchResultListener* /* listener */) const {
956 const bool eq = case_sensitive_ ? s == string_ :
961 void DescribeTo(::std::ostream* os) const {
965 void DescribeNegationTo(::std::ostream* os) const {
970 void DescribeToHelper(bool expect_eq, ::std::ostream* os) const {
979 const StringType string_;
980 const bool expect_eq_;
981 const bool case_sensitive_;
994 explicit HasSubstrMatcher(const StringType& substring)
1001 MatchResultListener* listener) const {
1005 bool MatchAndExplain(const StringType& s,
1006 MatchResultListener* /* listener */) const {
1011 void DescribeTo(::std::ostream* os) const {
1016 void DescribeNegationTo(::std::ostream* os) const {
1022 const StringType substring_;
1035 explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) {
1042 MatchResultListener* listener) const {
1046 bool MatchAndExplain(const StringType& s,
1047 MatchResultListener* /* listener */) const {
1052 void DescribeTo(::std::ostream* os) const {
1057 void DescribeNegationTo(::std::ostream* os) const {
1063 const StringType prefix_;
1076 explicit EndsWithMatcher(const StringType& suffix) : suffix_(suffix) {}
1082 MatchResultListener* listener) const {
1086 bool MatchAndExplain(const StringType& s,
1087 MatchResultListener* /* listener */) const {
1092 void DescribeTo(::std::ostream* os) const {
1097 void DescribeNegationTo(::std::ostream* os) const {
1103 const StringType suffix_;
1113 MatchesRegexMatcher(const RE* regex, bool full_match)
1120 bool MatchAndExplain(const char* s,
1121 MatchResultListener* listener) const {
1125 bool MatchAndExplain(const internal::string& s,
1126 MatchResultListener* /* listener */) const {
1131 void DescribeTo(::std::ostream* os) const {
1137 void DescribeNegationTo(::std::ostream* os) const {
1144 const internal::linked_ptr<const RE> regex_;
1145 const bool full_match_;
1155 // used to match a tuple<int, short>, a tuple<const long&, double>,
1165 operator Matcher< ::std::tr1::tuple<T1, T2> >() const { \
1169 operator Matcher<const ::std::tr1::tuple<T1, T2>&>() const { \
1170 return MakeMatcher(new Impl<const ::std::tr1::tuple<T1, T2>&>); \
1178 MatchResultListener* /* listener */) const { \
1181 virtual void DescribeTo(::std::ostream* os) const { \
1184 virtual void DescribeNegationTo(::std::ostream* os) const { \
1211 explicit NotMatcherImpl(const Matcher<T>& matcher)
1214 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
1218 virtual void DescribeTo(::std::ostream* os) const {
1222 virtual void DescribeNegationTo(::std::ostream* os) const {
1227 const Matcher<T> matcher_;
1242 operator Matcher<T>() const {
1259 BothOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
1262 virtual void DescribeTo(::std::ostream* os) const {
1270 virtual void DescribeNegationTo(::std::ostream* os) const {
1278 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
1294 const internal::string s1 = listener1.str();
1295 const internal::string s2 = listener2.str();
1309 const Matcher<T> matcher1_;
1310 const Matcher<T> matcher2_;
1327 operator Matcher<T>() const {
1346 EitherOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
1349 virtual void DescribeTo(::std::ostream* os) const {
1357 virtual void DescribeNegationTo(::std::ostream* os) const {
1365 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
1381 const internal::string s1 = listener1.str();
1382 const internal::string s2 = listener2.str();
1396 const Matcher<T> matcher1_;
1397 const Matcher<T> matcher2_;
1415 operator Matcher<T>() const {
1440 MatchResultListener* /* listener */) const {
1452 void DescribeTo(::std::ostream* os) const {
1456 void DescribeNegationTo(::std::ostream* os) const {
1480 bool operator()(const T& x) const {
1487 // compile when matcher_ has type Matcher<const T&>; if we write
1488 // Matcher<const T&>(matcher_).Matches(x) here, it won't compile
1493 // MatcherCast<const T&>() is necessary for making the code work
1495 return MatcherCast<const T&>(matcher_).Matches(x);
1509 explicit PredicateFormatterFromMatcher(const M& m) : matcher_(m) {}
1515 AssertionResult operator()(const char* value_text, const T& x) const {
1516 // We convert matcher_ to a Matcher<const T&> *now* instead of
1522 // We write MatcherCast<const T&>(matcher_) instead of
1523 // Matcher<const T&>(matcher_), as the latter won't compile when
1525 const Matcher<const T&> matcher = MatcherCast<const T&>(matcher_);
1539 const M matcher_;
1549 MakePredicateFormatterFromMatcher(const M& matcher) {
1575 MatchResultListener* /* listener */) const {
1576 const FloatingPoint<FloatType> lhs(value), rhs(rhs_);
1586 virtual void DescribeTo(::std::ostream* os) const {
1590 const ::std::streamsize old_precision = os->precision(
1604 virtual void DescribeNegationTo(::std::ostream* os) const {
1606 const ::std::streamsize old_precision = os->precision(
1622 const FloatType rhs_;
1623 const bool nan_eq_nan_;
1630 // Matcher<const float&>, or a Matcher<float&>, but nothing else.
1632 // by non-const reference, we may see them in code not conforming to
1634 operator Matcher<FloatType>() const {
1638 operator Matcher<const FloatType&>() const {
1639 return MakeMatcher(new Impl<const FloatType&>(rhs_, nan_eq_nan_));
1642 operator Matcher<FloatType&>() const {
1647 const FloatType rhs_;
1648 const bool nan_eq_nan_;
1658 explicit PointeeMatcher(const InnerMatcher& matcher) : matcher_(matcher) {}
1669 operator Matcher<Pointer>() const {
1681 explicit Impl(const InnerMatcher& matcher)
1682 : matcher_(MatcherCast<const Pointee&>(matcher)) {}
1684 virtual void DescribeTo(::std::ostream* os) const {
1689 virtual void DescribeNegationTo(::std::ostream* os) const {
1695 MatchResultListener* listener) const {
1704 const Matcher<const Pointee&> matcher_;
1709 const InnerMatcher matcher_;
1720 const Matcher<const FieldType&>& matcher)
1723 void DescribeTo(::std::ostream* os) const {
1728 void DescribeNegationTo(::std::ostream* os) const {
1734 bool MatchAndExplain(const T& value, MatchResultListener* listener) const {
1745 bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class& obj,
1746 MatchResultListener* listener) const {
1751 bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p,
1752 MatchResultListener* listener) const {
1763 const FieldType Class::*field_;
1764 const Matcher<const FieldType&> matcher_;
1774 // The property may have a reference type, so 'const PropertyType&'
1780 PropertyMatcher(PropertyType (Class::*property)() const,
1781 const Matcher<RefToConstProperty>& matcher)
1784 void DescribeTo(::std::ostream* os) const {
1789 void DescribeNegationTo(::std::ostream* os) const {
1795 bool MatchAndExplain(const T&value, MatchResultListener* listener) const {
1806 bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class& obj,
1807 MatchResultListener* listener) const {
1810 // which takes a non-const reference as argument.
1815 bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p,
1816 MatchResultListener* listener) const {
1827 PropertyType (Class::*property_)() const;
1828 const Matcher<RefToConstProperty> matcher_;
1870 ResultOfMatcher(Callable callable, const Matcher<ResultType>& matcher)
1876 operator Matcher<T>() const {
1886 Impl(CallableStorageType callable, const Matcher<ResultType>& matcher)
1889 virtual void DescribeTo(::std::ostream* os) const {
1894 virtual void DescribeNegationTo(::std::ostream* os) const {
1899 virtual bool MatchAndExplain(T obj, MatchResultListener* listener) const {
1902 // MatchPrintAndExplain, which takes a non-const reference as argument.
1909 // Functors often define operator() as non-const method even though
1911 // 'this' is a const pointer. It's the user's responsibility not to
1915 const Matcher<ResultType> matcher_;
1920 const CallableStorageType callable_;
1921 const Matcher<ResultType> matcher_;
1945 explicit ContainerEqMatcher(const Container& rhs) : rhs_(View::Copy(rhs)) {
1947 // with a const or reference type.
1952 void DescribeTo(::std::ostream* os) const {
1956 void DescribeNegationTo(::std::ostream* os) const {
1962 bool MatchAndExplain(const LhsContainer& lhs,
1963 MatchResultListener* listener) const {
1965 // that causes LhsContainer to be a const type sometimes.
1973 ::std::ostream* const os = listener->stream();
2015 const StlContainer rhs_;
2023 bool operator()(const T& lhs, const U& rhs) const { return lhs < rhs; }
2030 WhenSortedByMatcher(const Comparator& comparator,
2031 const ContainerMatcher& matcher)
2035 operator Matcher<LhsContainer>() const {
2048 Impl(const Comparator& comparator, const ContainerMatcher& matcher)
2051 virtual void DescribeTo(::std::ostream* os) const {
2056 virtual void DescribeNegationTo(::std::ostream* os) const {
2062 MatchResultListener* listener) const {
2079 const bool match = matcher_.MatchAndExplain(sorted_container,
2086 const Comparator comparator_;
2087 const Matcher<const std::vector<LhsValue>&> matcher_;
2093 const Comparator comparator_;
2094 const ContainerMatcher matcher_;
2100 // must be able to be safely cast to Matcher<tuple<const T1&, const
2112 PointwiseMatcher(const TupleMatcher& tuple_matcher, const RhsContainer& rhs)
2115 // with a const or reference type.
2121 operator Matcher<LhsContainer>() const {
2137 typedef std::tr1::tuple<const LhsValue&, const RhsValue&> InnerMatcherArg;
2139 Impl(const TupleMatcher& tuple_matcher, const RhsStlContainer& rhs)
2144 virtual void DescribeTo(::std::ostream* os) const {
2151 virtual void DescribeNegationTo(::std::ostream* os) const {
2161 MatchResultListener* listener) const {
2163 const size_t actual_size = lhs_stl_container.size();
2172 const InnerMatcherArg value_pair(*left, *right);
2196 const Matcher<InnerMatcherArg> mono_tuple_matcher_;
2197 const RhsStlContainer rhs_;
2203 const TupleMatcher tuple_matcher_;
2204 const RhsStlContainer rhs_;
2222 testing::SafeMatcherCast<const Element&>(inner_matcher)) {}
2229 MatchResultListener* listener) const {
2235 const bool matches = inner_matcher_.MatchAndExplain(*it, &inner_listener);
2248 const Matcher<const Element&> inner_matcher_;
2263 virtual void DescribeTo(::std::ostream* os) const {
2268 virtual void DescribeNegationTo(::std::ostream* os) const {
2274 MatchResultListener* listener) const {
2292 virtual void DescribeTo(::std::ostream* os) const {
2297 virtual void DescribeNegationTo(::std::ostream* os) const {
2303 MatchResultListener* listener) const {
2318 operator Matcher<Container>() const {
2323 const M inner_matcher_;
2335 operator Matcher<Container>() const {
2340 const M inner_matcher_;
2358 testing::SafeMatcherCast<const KeyType&>(inner_matcher)) {
2363 MatchResultListener* listener) const {
2365 const bool match = inner_matcher_.MatchAndExplain(key_value.first,
2367 const internal::string explanation = inner_listener.str();
2375 virtual void DescribeTo(::std::ostream* os) const {
2381 virtual void DescribeNegationTo(::std::ostream* os) const {
2387 const Matcher<const KeyType&> inner_matcher_;
2399 operator Matcher<PairType>() const {
2404 const M matcher_for_key_;
2421 testing::SafeMatcherCast<const FirstType&>(first_matcher)),
2423 testing::SafeMatcherCast<const SecondType&>(second_matcher)) {
2427 virtual void DescribeTo(::std::ostream* os) const {
2435 virtual void DescribeNegationTo(::std::ostream* os) const {
2445 MatchResultListener* listener) const {
2472 void ExplainSuccess(const internal::string& first_explanation,
2473 const internal::string& second_explanation,
2474 MatchResultListener* listener) const {
2490 const Matcher<const FirstType&> first_matcher_;
2491 const Matcher<const SecondType&> second_matcher_;
2504 operator Matcher<PairType> () const {
2511 const FirstMatcher first_matcher_;
2512 const SecondMatcher second_matcher_;
2534 matchers_.push_back(MatcherCast<const Element&>(*it));
2539 virtual void DescribeTo(::std::ostream* os) const {
2558 virtual void DescribeNegationTo(::std::ostream* os) const {
2575 MatchResultListener* listener) const {
2577 const size_t actual_count = stl_container.size();
2609 const internal::string& s = explanations[i];
2627 size_t count() const { return matchers_.size(); }
2628 std::vector<Matcher<const Element&> > matchers_;
2639 operator Matcher<Container>() const {
2644 const Matcher<const Element&>* const matchers = NULL;
2653 ElementsAreArrayMatcher(const T* first, size_t count) :
2657 operator Matcher<Container>() const {
2666 const T* const first_;
2667 const size_t count_;
2678 const char* matcher_name,
2679 const Strings& param_values);
2692 const internal::AnythingMatcher _ = {};
2702 // Note: if the parameter of Eq() were declared as const T&, Eq("foo")
2725 inline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }
2804 const InnerMatcher& inner_matcher) {
2815 FieldType Class::*field, const FieldMatcher& matcher) {
2818 field, MatcherCast<const FieldType&>(matcher)));
2832 PropertyType (Class::*property)() const, const PropertyMatcher& matcher) {
2858 Callable callable, const ResultOfMatcher& matcher) {
2873 StrEq(const internal::string& str) {
2880 StrNe(const internal::string& str) {
2887 StrCaseEq(const internal::string& str) {
2894 StrCaseNe(const internal::string& str) {
2902 HasSubstr(const internal::string& substring) {
2909 StartsWith(const internal::string& prefix) {
2916 EndsWith(const internal::string& suffix) {
2924 const internal::RE* regex) {
2928 const internal::string& regex) {
2935 const internal::RE* regex) {
2939 const internal::string& regex) {
2948 StrEq(const internal::wstring& str) {
2955 StrNe(const internal::wstring& str) {
2962 StrCaseEq(const internal::wstring& str) {
2969 StrCaseNe(const internal::wstring& str) {
2977 HasSubstr(const internal::wstring& substring) {
2984 StartsWith(const internal::wstring& prefix) {
2991 EndsWith(const internal::wstring& suffix) {
3045 ContainerEq(const Container& rhs) {
3047 // which causes Container to be a const type sometimes.
3057 WhenSortedBy(const Comparator& comparator,
3058 const ContainerMatcher& container_matcher) {
3067 WhenSorted(const ContainerMatcher& container_matcher) {
3076 // TupleMatcher must be able to be safely cast to Matcher<tuple<const
3077 // T1&, const T2&> >, where T1 and T2 are the types of elements in the
3082 Pointwise(const TupleMatcher& tuple_matcher, const Container& rhs) {
3084 // which causes Container to be a const type sometimes.
3104 // Contains(::std::pair<const int, size_t>(1, 100)));
3106 // const char* user_ids[] = { "joe", "mike", "tom" };
3138 // const char* user_ids[] = { "joe", "mike", "tom" };
3174 inline bool Value(const T& value, M matcher) {
3182 M matcher, const T& value, MatchResultListener* listener) {
3183 return SafeMatcherCast<const T&>(matcher).MatchAndExplain(value, listener);
3194 inline InnerMatcher AllArgs(const InnerMatcher& matcher) { return matcher; }