38 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ 39 #define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ 53 #include "gtest/gtest.h" 56 #include <initializer_list> 81 class MatchResultListener
111 ::std::ostream *
const stream_;
132 virtual void DescribeTo(::std::ostream * os)
const = 0;
149 template <
typename T>
204 ::std::stringstream ss_;
238 template <
typename T>
246 return impl_->MatchAndExplain(x, listener);
253 return MatchAndExplain(x, &dummy);
257 void DescribeTo(::std::ostream * os)
const { impl_->DescribeTo(os); }
262 impl_->DescribeNegationTo(os);
269 MatchAndExplain(x, &listener);
311 template <
typename T>
322 : internal::MatcherBase<T>(impl) {}
340 : internal::MatcherBase<const internal::
string & >(impl) {}
347 Matcher(
const char * s);
358 : internal::MatcherBase<internal::
string>(impl) {}
365 Matcher(
const char * s);
368 #if GTEST_HAS_STRING_PIECE_ 387 Matcher(
const char * s);
390 Matcher(StringPiece s);
408 Matcher(
const char * s);
411 Matcher(StringPiece s);
413 #endif // GTEST_HAS_STRING_PIECE_ 427 template <
class Impl>
439 const Impl &
impl()
const {
return impl_; }
441 template <
typename T>
448 template <
typename T>
456 impl_.DescribeTo(os);
461 impl_.DescribeNegationTo(os);
466 return impl_.MatchAndExplain(x, listener);
487 template <
typename T>
500 template <
class Impl>
521 template <
typename T,
typename M>
522 class MatcherCastImpl
541 polymorphic_matcher_or_value,
566 return polymorphic_matcher_or_value;
573 template <
typename T,
typename U>
587 : source_matcher_(source_matcher) {}
592 return source_matcher_.MatchAndExplain(static_cast<U>(x), listener);
597 source_matcher_.DescribeTo(os);
602 source_matcher_.DescribeNegationTo(os);
614 template <
typename T>
627 template <
typename T,
typename M>
640 template <
typename T>
646 template <
typename M>
661 template <
typename U>
666 T_must_be_implicitly_convertible_to_U);
671 cannot_convert_non_referentce_arg_to_reference);
679 kTIsOther || kUIsOther ||
680 (internal::LosslessArithmeticConvertible<RawT, RawU>::value),
681 conversion_of_arithmetic_types_must_be_lossless);
682 return MatcherCast<T>(matcher);
686 template <
typename T,
typename M>
693 template <
typename T>
705 if (explanation !=
"" && os != NULL)
707 *os <<
", " << explanation;
718 return (type_name.length() <= 20 ||
719 type_name.find_first_of(
"<(") == string::npos);
727 template <
typename Value,
typename T>
731 if (!listener->IsInterested())
743 const string & type_name = GetTypeName<Value>();
746 { *listener->stream() <<
" (of type " << type_name <<
")"; }
763 template <
typename MatcherTuple,
typename ValueTuple>
765 const ValueTuple & value_tuple)
769 &&
get < N - 1 > (matcher_tuple).
Matches(get < N - 1 > (value_tuple));
776 template <
typename MatcherTuple,
typename ValueTuple>
778 const ValueTuple & values,
781 using ::std::tr1::tuple_element;
785 TuplePrefix < N - 1 >::ExplainMatchFailuresTo(matchers, values, os);
789 typename tuple_element < N - 1,
MatcherTuple >::type matcher =
790 get < N - 1 > (matchers);
791 typedef typename tuple_element < N - 1, ValueTuple >::type
Value;
792 Value value =
get < N - 1 > (values);
795 if (!matcher.MatchAndExplain(value, &listener))
799 *os <<
" Expected arg #" << N - 1 <<
": ";
800 get < N - 1 > (matchers).DescribeTo(os);
801 *os <<
"\n Actual: ";
819 template <
typename MatcherTuple,
typename ValueTuple>
826 template <
typename MatcherTuple,
typename ValueTuple>
829 ::std::ostream * ) {}
837 template <
typename MatcherTuple,
typename ValueTuple>
839 const ValueTuple & value_tuple)
841 using ::std::tr1::tuple_size;
845 tuple_size<ValueTuple>::value,
846 matcher_and_value_have_different_numbers_of_fields);
848 Matches(matcher_tuple, value_tuple);
853 template <
typename MatcherTuple,
typename ValueTuple>
855 const ValueTuple & values,
858 using ::std::tr1::tuple_size;
860 matchers, values, os);
867 template <
typename Tuple,
typename Func,
typename OutIter>
871 typedef typename ::std::tr1::tuple_size<Tuple>
TupleSize;
876 static OutIter
Run(Func f,
const Tuple & t, OutIter out)
882 template <
typename Tup,
size_t kRemainingSize>
887 *out++ = f(::std::tr1::get < TupleSize::value - kRemainingSize > (t));
891 template <
typename Tup>
904 template <
typename Tuple,
typename Func,
typename OutIter>
911 template <
typename T>
917 virtual void DescribeTo(::std::ostream * os)
const { *os <<
"is anything"; }
923 *os <<
"never matches";
934 template <
typename T>
951 #define GMOCK_IMPLEMENT_COMPARISON_MATCHER_( \ 952 name, op, relation, negated_relation) \ 953 template <typename Rhs> class name##Matcher { \ 955 explicit name##Matcher(const Rhs& rhs) : rhs_(rhs) {} \ 956 template <typename Lhs> \ 957 operator Matcher<Lhs>() const { \ 958 return MakeMatcher(new Impl<Lhs>(rhs_)); \ 961 template <typename Lhs> \ 962 class Impl : public MatcherInterface<Lhs> { \ 964 explicit Impl(const Rhs& rhs) : rhs_(rhs) {} \ 965 virtual bool MatchAndExplain(\ 966 Lhs lhs, MatchResultListener* ) const { \ 967 return lhs op rhs_; \ 969 virtual void DescribeTo(::std::ostream* os) const { \ 970 *os << relation " "; \ 971 UniversalPrint(rhs_, os); \ 973 virtual void DescribeNegationTo(::std::ostream* os) const { \ 974 *os << negated_relation " "; \ 975 UniversalPrint(rhs_, os); \ 979 GTEST_DISALLOW_ASSIGN_(Impl); \ 982 GTEST_DISALLOW_ASSIGN_(name##Matcher); \ 994 #undef GMOCK_IMPLEMENT_COMPARISON_MATCHER_ 1001 template <
typename Po
inter>
1011 *os <<
"isn't NULL";
1020 template <
typename Po
inter>
1027 void DescribeTo(::std::ostream * os)
const { *os <<
"isn't NULL"; }
1047 template <
typename T>
1050 template <
typename T>
1064 template <
typename Super>
1076 template <
typename Super>
1080 explicit Impl(Super & x) : object_(x) {}
1087 *listener <<
"which is located @" <<
static_cast<const void *
>(&x);
1088 return &x == &object_;
1093 *os <<
"references the variable ";
1099 *os <<
"does not reference the variable ";
1104 const Super & object_;
1121 const wchar_t * rhs)
1123 return String::CaseInsensitiveWideCStringEquals(lhs, rhs);
1128 template <
typename StringType>
1130 const StringType & s2)
1139 const typename StringType::value_type nul = 0;
1140 const size_t i1 = s1.find(nul), i2 = s2.find(nul);
1143 if (i1 == StringType::npos || i2 == StringType::npos)
1155 template <
typename StringType>
1160 bool case_sensitive)
1161 : string_(str), expect_eq_(expect_eq), case_sensitive_(case_sensitive) {}
1168 template <
typename CharType>
1176 return MatchAndExplain(StringType(s), listener);
1183 template <
typename MatcheeStringType>
1187 const StringType & s2(s);
1188 const bool eq = case_sensitive_ ? s2 == string_ :
1190 return expect_eq_ == eq;
1195 DescribeToHelper(expect_eq_, os);
1200 DescribeToHelper(!expect_eq_, os);
1206 *os << (expect_eq ?
"is " :
"isn't ");
1209 if (!case_sensitive_)
1211 *os <<
"(ignoring case) ";
1217 const StringType string_;
1218 const bool expect_eq_;
1219 const bool case_sensitive_;
1227 template <
typename StringType>
1232 : substring_(substring) {}
1239 template <
typename CharType>
1242 return s != NULL && MatchAndExplain(StringType(s), listener);
1249 template <
typename MatcheeStringType>
1253 const StringType & s2(s);
1254 return s2.find(substring_) != StringType::npos;
1260 *os <<
"has substring ";
1266 *os <<
"has no substring ";
1271 const StringType substring_;
1279 template <
typename StringType>
1292 template <
typename CharType>
1295 return s != NULL && MatchAndExplain(StringType(s), listener);
1302 template <
typename MatcheeStringType>
1306 const StringType & s2(s);
1307 return s2.length() >= prefix_.length() &&
1308 s2.substr(0, prefix_.length()) == prefix_;
1313 *os <<
"starts with ";
1319 *os <<
"doesn't start with ";
1324 const StringType prefix_;
1332 template <
typename StringType>
1343 template <
typename CharType>
1346 return s != NULL && MatchAndExplain(StringType(s), listener);
1353 template <
typename MatcheeStringType>
1357 const StringType & s2(s);
1358 return s2.length() >= suffix_.length() &&
1359 s2.substr(s2.length() - suffix_.length()) == suffix_;
1364 *os <<
"ends with ";
1370 *os <<
"doesn't end with ";
1375 const StringType suffix_;
1387 : regex_(regex), full_match_(full_match) {}
1394 template <
typename CharType>
1404 template <
class MatcheeStringType>
1409 return full_match_ ? RE::FullMatch(s2, *regex_) :
1410 RE::PartialMatch(s2, *regex_);
1415 *os << (full_match_ ?
"matches" :
"contains")
1416 <<
" regular expression ";
1422 *os <<
"doesn't " << (full_match_ ?
"match" :
"contain")
1423 <<
" regular expression ";
1429 const bool full_match_;
1445 #define GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(name, op, relation) \ 1446 class name##2Matcher { \ 1448 template <typename T1, typename T2> \ 1449 operator Matcher< ::std::tr1::tuple<T1, T2> >() const { \ 1450 return MakeMatcher(new Impl< ::std::tr1::tuple<T1, T2> >); \ 1452 template <typename T1, typename T2> \ 1453 operator Matcher<const ::std::tr1::tuple<T1, T2>&>() const { \ 1454 return MakeMatcher(new Impl<const ::std::tr1::tuple<T1, T2>&>); \ 1457 template <typename Tuple> \ 1458 class Impl : public MatcherInterface<Tuple> { \ 1460 virtual bool MatchAndExplain( \ 1462 MatchResultListener* ) const { \ 1463 return ::std::tr1::get<0>(args) op ::std::tr1::get<1>(args); \ 1465 virtual void DescribeTo(::std::ostream* os) const { \ 1466 *os << "are " relation; \ 1468 virtual void DescribeNegationTo(::std::ostream* os) const { \ 1469 *os << "aren't " relation; \ 1477 Ge, >=,
"a pair where the first >= the second");
1479 Gt, >,
"a pair where the first > the second");
1481 Le, <=,
"a pair where the first <= the second");
1483 Lt, <,
"a pair where the first < the second");
1486 #undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER_ 1492 template <
typename T>
1493 class NotMatcherImpl :
public MatcherInterface<T>
1497 : matcher_(matcher) {}
1501 return !matcher_.MatchAndExplain(x, listener);
1506 matcher_.DescribeNegationTo(os);
1511 matcher_.DescribeTo(os);
1522 template <
typename InnerMatcher>
1530 template <
typename T>
1537 InnerMatcher matcher_;
1546 template <
typename T>
1551 : matcher1_(matcher1), matcher2_(matcher2) {}
1556 matcher1_.DescribeTo(os);
1558 matcher2_.DescribeTo(os);
1565 matcher1_.DescribeNegationTo(os);
1567 matcher2_.DescribeNegationTo(os);
1577 if (!matcher1_.MatchAndExplain(x, &listener1))
1579 *listener << listener1.
str();
1585 if (!matcher2_.MatchAndExplain(x, &listener2))
1587 *listener << listener2.
str();
1606 *listener <<
", and " << s2;
1620 #if GTEST_LANG_CXX11 1628 template <
int kSize,
typename Head,
typename... Tail>
1631 typedef MatcherList < kSize - 1, Tail... > MatcherListTail;
1632 typedef ::std::pair<Head, typename MatcherListTail::ListType> ListType;
1638 static ListType BuildList(
const Head & matcher,
const Tail & ... tail)
1640 return ListType(matcher, MatcherListTail::BuildList(tail...));
1647 template <
typename T,
template <
typename >
class CombiningMatcher>
1648 static Matcher<T> CreateMatcher(const ListType & matchers)
1651 SafeMatcherCast<T>(matchers.first),
1652 MatcherListTail::template CreateMatcher<T, CombiningMatcher>(
1659 template <
typename Matcher1,
typename Matcher2>
1660 struct MatcherList<2, Matcher1, Matcher2>
1662 typedef ::std::pair<Matcher1, Matcher2> ListType;
1664 static ListType BuildList(
const Matcher1 & matcher1,
1665 const Matcher2 & matcher2)
1667 return ::std::pair<Matcher1, Matcher2>(matcher1, matcher2);
1670 template <
typename T,
template <
typename >
class CombiningMatcher>
1671 static Matcher<T> CreateMatcher(const ListType & matchers)
1674 SafeMatcherCast<T>(matchers.first),
1675 SafeMatcherCast<T>(matchers.second)));
1683 template <
template <
typename T>
class CombiningMatcher,
typename...
Args>
1684 class VariadicMatcher
1687 VariadicMatcher(
const Args & ... matchers)
1688 : matchers_(MatcherListType::BuildList(matchers...)) {}
1693 template <
typename T>
1696 return MatcherListType::template CreateMatcher<T, CombiningMatcher>(
1701 typedef MatcherList<
sizeof...(Args),
Args...> MatcherListType;
1703 const typename MatcherListType::ListType matchers_;
1708 template <
typename...
Args>
1711 #endif // GTEST_LANG_CXX11 1715 template <
typename Matcher1,
typename Matcher2>
1720 : matcher1_(matcher1), matcher2_(matcher2) {}
1725 template <
typename T>
1729 SafeMatcherCast<T>(matcher2_)));
1743 template <
typename T>
1748 : matcher1_(matcher1), matcher2_(matcher2) {}
1753 matcher1_.DescribeTo(os);
1755 matcher2_.DescribeTo(os);
1762 matcher1_.DescribeNegationTo(os);
1764 matcher2_.DescribeNegationTo(os);
1774 if (matcher1_.MatchAndExplain(x, &listener1))
1776 *listener << listener1.
str();
1782 if (matcher2_.MatchAndExplain(x, &listener2))
1784 *listener << listener2.
str();
1803 *listener <<
", and " << s2;
1817 #if GTEST_LANG_CXX11 1819 template <
typename...
Args>
1822 #endif // GTEST_LANG_CXX11 1827 template <
typename Matcher1,
typename Matcher2>
1832 : matcher1_(matcher1), matcher2_(matcher2) {}
1837 template <
typename T>
1841 SafeMatcherCast<T>(matcher1_), SafeMatcherCast<T>(matcher2_)));
1853 template <
typename Predicate>
1863 template <
typename T>
1881 *os <<
"satisfies the given predicate";
1886 *os <<
"doesn't satisfy the given predicate";
1890 Predicate predicate_;
1897 template <
typename M>
1909 template <
typename T>
1926 return MatcherCast<const T &>(matcher_).
Matches(x);
1937 template <
typename M>
1946 template <
typename T>
1966 ::std::stringstream ss;
1967 ss <<
"Value of: " << value_text <<
"\n" 1970 ss <<
"\n Actual: " << listener.str();
1983 template <
typename M>
1994 template <
typename FloatType>
2005 rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(-1)
2013 rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(max_abs_error)
2016 <<
", where max_abs_error is" << max_abs_error;
2020 template <
typename T>
2024 Impl(FloatType rhs,
bool nan_eq_nan, FloatType max_abs_error) :
2025 rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(max_abs_error) {}
2033 if (lhs.is_nan() || rhs.
is_nan())
2035 if (lhs.is_nan() && rhs.
is_nan())
2044 if (HasMaxAbsError())
2050 return value == rhs_ || fabs(value - rhs_) <= max_abs_error_;
2055 return lhs.AlmostEquals(rhs);
2064 const ::std::streamsize old_precision = os->precision(
2065 ::std::numeric_limits<FloatType>::digits10 + 2);
2076 *os <<
"never matches";
2082 *os <<
"is approximately " << rhs_;
2084 if (HasMaxAbsError())
2086 *os <<
" (absolute error <= " << max_abs_error_ <<
")";
2090 os->precision(old_precision);
2096 const ::std::streamsize old_precision = os->precision(
2097 ::std::numeric_limits<FloatType>::digits10 + 2);
2108 *os <<
"is anything";
2114 *os <<
"isn't approximately " << rhs_;
2116 if (HasMaxAbsError())
2118 *os <<
" (absolute error > " << max_abs_error_ <<
")";
2123 os->precision(old_precision);
2129 return max_abs_error_ >= 0;
2132 const FloatType rhs_;
2133 const bool nan_eq_nan_;
2135 const FloatType max_abs_error_;
2163 const FloatType rhs_;
2164 const bool nan_eq_nan_;
2166 const FloatType max_abs_error_;
2173 template <
typename InnerMatcher>
2187 template <
typename Po
inter>
2195 template <
typename Po
inter>
2202 explicit Impl(
const InnerMatcher & matcher)
2203 : matcher_(
MatcherCast<const Pointee & >(matcher)) {}
2207 *os <<
"points to a value that ";
2208 matcher_.DescribeTo(os);
2213 *os <<
"does not point to a value that ";
2214 matcher_.DescribeTo(os);
2223 *listener <<
"which points to ";
2233 const InnerMatcher matcher_;
2240 template <
typename Class,
typename FieldType>
2246 : field_(field), matcher_(matcher) {}
2250 *os <<
"is an object whose given field ";
2251 matcher_.DescribeTo(os);
2256 *os <<
"is an object whose given field ";
2257 matcher_.DescribeNegationTo(os);
2260 template <
typename T>
2263 return MatchAndExplainImpl(
2264 typename ::testing::internal::
2276 *listener <<
"whose given field is ";
2286 *listener <<
"which points to an object ";
2290 return MatchAndExplainImpl(
false_type(), *p, listener);
2293 const FieldType Class::* field_;
2301 template <
typename Class,
typename PropertyType>
2313 : property_(property), matcher_(matcher) {}
2317 *os <<
"is an object whose given property ";
2318 matcher_.DescribeTo(os);
2323 *os <<
"is an object whose given property ";
2324 matcher_.DescribeNegationTo(os);
2327 template <
typename T>
2330 return MatchAndExplainImpl(
2331 typename ::testing::internal::
2343 *listener <<
"whose given property is ";
2346 RefToConstProperty result = (obj.*property_)();
2356 *listener <<
"which points to an object ";
2360 return MatchAndExplainImpl(
false_type(), *p, listener);
2363 PropertyType(Class::*property_)()
const;
2373 template <
typename Functor>
2380 template <
typename T>
2381 static ResultType
Invoke(Functor f, T
arg) {
return f(arg); }
2385 template <
typename ArgType,
typename ResType>
2389 typedef ResType(*StorageType)(ArgType);
2394 <<
"NULL function pointer is passed into ResultOf().";
2396 template <
typename T>
2405 template <
typename Callable>
2412 : callable_(callable), matcher_(matcher)
2417 template <
typename T>
2426 template <
typename T>
2431 : callable_(callable), matcher_(matcher) {}
2435 *os <<
"is mapped by the given callable to a value that ";
2436 matcher_.DescribeTo(os);
2441 *os <<
"is mapped by the given callable to a value that ";
2442 matcher_.DescribeNegationTo(os);
2447 *listener <<
"which is mapped by the given callable to ";
2461 mutable CallableStorageType callable_;
2467 const CallableStorageType callable_;
2474 template <
typename SizeMatcher>
2479 : size_matcher_(size_matcher)
2483 template <
typename Container>
2489 template <
typename Container>
2495 typedef typename ContainerView::type::size_type
SizeType;
2496 explicit Impl(
const SizeMatcher & size_matcher)
2497 : size_matcher_(
MatcherCast<SizeType>(size_matcher)) {}
2502 size_matcher_.DescribeTo(os);
2507 size_matcher_.DescribeNegationTo(os);
2513 SizeType size = container.size();
2515 const bool result = size_matcher_.MatchAndExplain(size, &size_listener);
2517 <<
"whose size " << size << (result ?
" matches" :
" doesn't match");
2528 const SizeMatcher size_matcher_;
2542 template <
typename Container>
2567 *os <<
"does not equal ";
2571 template <
typename LhsContainer>
2579 typedef typename LhsView::type LhsStlContainer;
2580 StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
2582 if (lhs_stl_container == rhs_)
2585 ::std::ostream *
const os = listener->stream();
2590 bool printed_header =
false;
2592 for (
typename LhsStlContainer::const_iterator it =
2593 lhs_stl_container.begin();
2594 it != lhs_stl_container.end(); ++it)
2606 *os <<
"which has these unexpected elements: ";
2607 printed_header =
true;
2615 bool printed_header2 =
false;
2617 for (
typename StlContainer::const_iterator it = rhs_.begin();
2618 it != rhs_.end(); ++it)
2621 lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
2622 lhs_stl_container.end())
2624 if (printed_header2)
2631 *os << (printed_header ?
",\nand" :
"which")
2632 <<
" doesn't have these expected elements: ";
2633 printed_header2 =
true;
2645 const StlContainer rhs_;
2653 template <
typename T,
typename U>
2654 bool operator()(
const T & lhs,
const U & rhs)
const {
return lhs < rhs; }
2658 template <
typename Comparator,
typename ContainerMatcher>
2663 const ContainerMatcher & matcher)
2664 : comparator_(comparator), matcher_(matcher) {}
2666 template <
typename LhsContainer>
2672 template <
typename LhsContainer>
2685 Impl(
const Comparator & comparator,
const ContainerMatcher & matcher)
2686 : comparator_(comparator), matcher_(matcher) {}
2690 *os <<
"(when sorted) ";
2691 matcher_.DescribeTo(os);
2696 *os <<
"(when sorted) ";
2697 matcher_.DescribeNegationTo(os);
2703 LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
2704 ::std::vector<LhsValue> sorted_container(lhs_stl_container.begin(),
2705 lhs_stl_container.end());
2707 sorted_container.begin(), sorted_container.end(), comparator_);
2709 if (!listener->IsInterested())
2713 return matcher_.Matches(sorted_container);
2716 *listener <<
"which is ";
2718 *listener <<
" when sorted";
2721 const bool match = matcher_.MatchAndExplain(sorted_container,
2728 const Comparator comparator_;
2735 const Comparator comparator_;
2736 const ContainerMatcher matcher_;
2745 template <
typename TupleMatcher,
typename RhsContainer>
2756 : tuple_matcher_(tuple_matcher), rhs_(RhsView::Copy(rhs))
2764 template <
typename LhsContainer>
2770 template <
typename LhsContainer>
2785 Impl(
const TupleMatcher & tuple_matcher,
const RhsStlContainer & rhs)
2787 : mono_tuple_matcher_(
SafeMatcherCast<InnerMatcherArg>(tuple_matcher)),
2792 *os <<
"contains " << rhs_.size()
2793 <<
" values, where each value and its corresponding value in ";
2796 mono_tuple_matcher_.DescribeTo(os);
2800 *os <<
"doesn't contain exactly " << rhs_.size()
2801 <<
" values, or contains a value x at some index i" 2802 <<
" where x and the i-th value of ";
2805 mono_tuple_matcher_.DescribeNegationTo(os);
2811 LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
2812 const size_t actual_size = lhs_stl_container.size();
2814 if (actual_size != rhs_.size())
2816 *listener <<
"which contains " << actual_size <<
" values";
2820 typename LhsStlContainer::const_iterator left = lhs_stl_container.begin();
2821 typename RhsStlContainer::const_iterator right = rhs_.begin();
2823 for (
size_t i = 0; i != actual_size; ++i, ++left, ++right)
2825 const InnerMatcherArg value_pair(*left, *right);
2827 if (listener->IsInterested())
2831 if (!mono_tuple_matcher_.MatchAndExplain(
2832 value_pair, &inner_listener))
2834 *listener <<
"where the value pair (";
2838 *listener <<
") at index #" << i <<
" don't match";
2846 if (!mono_tuple_matcher_.Matches(value_pair))
2856 const RhsStlContainer rhs_;
2862 const TupleMatcher tuple_matcher_;
2863 const RhsStlContainer rhs_;
2869 template <
typename Container>
2877 typedef typename StlContainer::value_type
Element;
2879 template <
typename InnerMatcher>
2888 Container container,
2891 StlContainerReference stl_container = View::ConstReference(container);
2894 for (
typename StlContainer::const_iterator it = stl_container.begin();
2895 it != stl_container.end(); ++it, ++i)
2898 const bool matches = inner_matcher_.MatchAndExplain(*it, &inner_listener);
2900 if (matches != all_elements_should_match)
2902 *listener <<
"whose element #" << i
2903 << (matches ?
" matches" :
" doesn't match");
2905 return !all_elements_should_match;
2909 return all_elements_should_match;
2920 template <
typename Container>
2924 template <
typename InnerMatcher>
2931 *os <<
"contains at least one element that ";
2932 this->inner_matcher_.DescribeTo(os);
2937 *os <<
"doesn't contain any element that ";
2938 this->inner_matcher_.DescribeTo(os);
2944 return this->MatchAndExplainImpl(
false, container, listener);
2953 template <
typename Container>
2957 template <
typename InnerMatcher>
2964 *os <<
"only contains elements that ";
2965 this->inner_matcher_.DescribeTo(os);
2970 *os <<
"contains some element that ";
2971 this->inner_matcher_.DescribeNegationTo(os);
2977 return this->MatchAndExplainImpl(
true, container, listener);
2985 template <
typename M>
2991 template <
typename Container>
2998 const M inner_matcher_;
3004 template <
typename M>
3010 template <
typename Container>
3017 const M inner_matcher_;
3026 template <
typename PairType>
3033 template <
typename InnerMatcher>
3045 const bool match = inner_matcher_.MatchAndExplain(key_value.first,
3049 if (explanation !=
"")
3051 *listener <<
"whose first field is a value " << explanation;
3060 *os <<
"has a key that ";
3061 inner_matcher_.DescribeTo(os);
3067 *os <<
"doesn't have a key that ";
3068 inner_matcher_.DescribeTo(os);
3078 template <
typename M>
3084 template <
typename PairType>
3091 const M matcher_for_key_;
3098 template <
typename PairType>
3106 template <
typename FirstMatcher,
typename SecondMatcher>
3118 *os <<
"has a first field that ";
3119 first_matcher_.DescribeTo(os);
3120 *os <<
", and has a second field that ";
3121 second_matcher_.DescribeTo(os);
3127 *os <<
"has a first field that ";
3128 first_matcher_.DescribeNegationTo(os);
3129 *os <<
", or has a second field that ";
3130 second_matcher_.DescribeNegationTo(os);
3138 if (!listener->IsInterested())
3142 return first_matcher_.Matches(a_pair.first) &&
3143 second_matcher_.Matches(a_pair.second);
3148 if (!first_matcher_.MatchAndExplain(a_pair.first,
3149 &first_inner_listener))
3151 *listener <<
"whose first field does not match";
3158 if (!second_matcher_.MatchAndExplain(a_pair.second,
3159 &second_inner_listener))
3161 *listener <<
"whose second field does not match";
3166 ExplainSuccess(first_inner_listener.
str(), second_inner_listener.
str(),
3176 *listener <<
"whose both fields match";
3178 if (first_explanation !=
"")
3180 *listener <<
", where the first field is a value " << first_explanation;
3183 if (second_explanation !=
"")
3187 if (first_explanation !=
"")
3189 *listener <<
"and ";
3194 *listener <<
"where ";
3197 *listener <<
"the second field is a value " << second_explanation;
3208 template <
typename FirstMatcher,
typename SecondMatcher>
3213 : first_matcher_(first_matcher), second_matcher_(second_matcher) {}
3215 template <
typename PairType>
3220 first_matcher_, second_matcher_));
3224 const FirstMatcher first_matcher_;
3225 const SecondMatcher second_matcher_;
3231 template <
typename Container>
3239 typedef typename StlContainer::value_type
Element;
3243 template <
typename InputIter>
3246 while (first != last)
3248 matchers_.push_back(MatcherCast<const Element &>(*first++));
3260 else if (
count() == 1)
3262 *os <<
"has 1 element that ";
3263 matchers_[0].DescribeTo(os);
3268 *os <<
"has " << Elements(
count()) <<
" where\n";
3270 for (
size_t i = 0; i !=
count(); ++i)
3272 *os <<
"element #" << i <<
" ";
3273 matchers_[i].DescribeTo(os);
3275 if (i + 1 <
count())
3288 *os <<
"isn't empty";
3292 *os <<
"doesn't have " << Elements(
count()) <<
", or\n";
3294 for (
size_t i = 0; i !=
count(); ++i)
3296 *os <<
"element #" << i <<
" ";
3297 matchers_[i].DescribeNegationTo(os);
3299 if (i + 1 <
count())
3312 const bool listener_interested = listener->IsInterested();
3315 ::std::vector<internal::string> explanations(
count());
3316 StlContainerReference stl_container = View::ConstReference(container);
3317 typename StlContainer::const_iterator it = stl_container.begin();
3318 size_t exam_pos = 0;
3319 bool mismatch_found =
false;
3324 for (; it != stl_container.end() && exam_pos !=
count(); ++it, ++exam_pos)
3328 if (listener_interested)
3331 match = matchers_[exam_pos].MatchAndExplain(*it, &s);
3332 explanations[exam_pos] = s.
str();
3337 match = matchers_[exam_pos].Matches(*it);
3342 mismatch_found =
true;
3352 size_t actual_count = exam_pos;
3354 for (; it != stl_container.end(); ++it)
3359 if (actual_count !=
count())
3365 if (listener_interested && (actual_count != 0))
3367 *listener <<
"which has " << Elements(actual_count);
3376 if (listener_interested)
3378 *listener <<
"whose element #" << exam_pos <<
" doesn't match";
3387 if (listener_interested)
3389 bool reason_printed =
false;
3391 for (
size_t i = 0; i !=
count(); ++i)
3399 *listener <<
",\nand ";
3402 *listener <<
"whose element #" << i <<
" matches, " << s;
3403 reason_printed =
true;
3414 return Message() << count << (count == 1 ?
" element" :
" elements");
3417 size_t count()
const {
return matchers_.size(); }
3419 ::std::vector<Matcher<const Element &> > matchers_;
3432 : num_elements_(num_elements),
3433 num_matchers_(num_matchers),
3434 matched_(num_elements_ * num_matchers_, 0)
3442 return matched_[SpaceIndex(ilhs, irhs)] == 1;
3446 matched_[SpaceIndex(ilhs, irhs)] = b ? 1 : 0;
3456 string DebugString()
const;
3461 return ilhs * num_matchers_ + irhs;
3464 size_t num_elements_;
3465 size_t num_matchers_;
3470 ::std::vector<char> matched_;
3487 class GTEST_API_ UnorderedElementsAreMatcherImplBase
3496 void DescribeToImpl(::std::ostream * os)
const;
3499 void DescribeNegationToImpl(::std::ostream * os)
const;
3501 bool VerifyAllElementsAndMatchersAreMatched(
3502 const ::std::vector<string> & element_printouts,
3503 const MatchMatrix & matrix,
3508 return matcher_describers_;
3513 return Message() << n <<
" element" << (n == 1 ?
"" :
"s");
3517 MatcherDescriberVec matcher_describers_;
3523 template <
typename Container>
3526 public UnorderedElementsAreMatcherImplBase
3534 typedef typename StlContainer::value_type
Element;
3538 template <
typename InputIter>
3541 for (; first != last; ++first)
3543 matchers_.push_back(MatcherCast<const Element &>(*first));
3544 matcher_describers().push_back(matchers_.back().GetDescriber());
3551 return UnorderedElementsAreMatcherImplBase::DescribeToImpl(os);
3557 return UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl(os);
3563 StlContainerReference stl_container = View::ConstReference(container);
3564 ::std::vector<string> element_printouts;
3565 MatchMatrix matrix = AnalyzeElements(stl_container.begin(),
3566 stl_container.end(),
3570 const size_t actual_count = matrix.
LhsSize();
3572 if (actual_count == 0 && matchers_.empty())
3577 if (actual_count != matchers_.size())
3583 if (actual_count != 0 && listener->IsInterested())
3585 *listener <<
"which has " << Elements(actual_count);
3591 return VerifyAllElementsAndMatchersAreMatched(element_printouts,
3592 matrix, listener) &&
3599 template <
typename ElementIter>
3601 ::std::vector<string> * element_printouts,
3604 element_printouts->clear();
3605 ::std::vector<char> did_match;
3606 size_t num_elements = 0;
3608 for (; elem_first != elem_last; ++num_elements, ++elem_first)
3610 if (listener->IsInterested())
3615 for (
size_t irhs = 0; irhs != matchers_.size(); ++irhs)
3617 did_match.push_back(
Matches(matchers_[irhs])(*elem_first));
3621 MatchMatrix matrix(num_elements, matchers_.size());
3622 ::std::vector<char>::const_iterator did_match_iter = did_match.begin();
3624 for (
size_t ilhs = 0; ilhs != num_elements; ++ilhs)
3626 for (
size_t irhs = 0; irhs != matchers_.size(); ++irhs)
3628 matrix.
SetEdge(ilhs, irhs, *did_match_iter++ != 0);
3635 MatcherVec matchers_;
3642 template <
typename Target>
3645 template <
typename Arg>
3648 return MatcherCast<Target>(a);
3653 template <
typename MatcherTuple>
3658 : matchers_(args) {}
3660 template <
typename Container>
3665 typedef typename View::value_type Element;
3666 typedef ::std::vector<Matcher<const Element &> > MatcherVec;
3667 MatcherVec matchers;
3670 ::std::back_inserter(matchers));
3672 matchers.begin(), matchers.end()));
3681 template <
typename MatcherTuple>
3687 template <
typename Container>
3692 typedef typename View::value_type Element;
3693 typedef ::std::vector<Matcher<const Element &> > MatcherVec;
3694 MatcherVec matchers;
3697 ::std::back_inserter(matchers));
3699 matchers.begin(), matchers.end()));
3708 template <
typename T>
3714 template <
typename Iter>
3716 : matchers_(first, last) {}
3718 template <
typename Container>
3727 ::std::vector<T> matchers_;
3733 template <
typename T>
3737 template <
typename Iter>
3740 template <
typename Container>
3744 matchers_.begin(), matchers_.end()));
3748 const ::std::vector<T> matchers_;
3759 const char * matcher_name,
3760 const Strings & param_values);
3779 template <
typename Iter>
3781 typename ::std::iterator_traits<Iter>::value_type >
3784 typedef typename ::std::iterator_traits<Iter>::value_type T;
3788 template <
typename T>
3790 const T * pointer,
size_t count)
3795 template <
typename T,
size_t N>
3802 template <
typename T,
typename A>
3804 const ::std::vector<T, A> & vec)
3809 #if GTEST_LANG_CXX11 3810 template <
typename T>
3826 template <
typename Iter>
3828 typename ::std::iterator_traits<Iter>::value_type >
3831 typedef typename ::std::iterator_traits<Iter>::value_type T;
3835 template <
typename T>
3842 template <
typename T,
size_t N>
3849 template <
typename T,
typename A>
3856 #if GTEST_LANG_CXX11 3857 template <
typename T>
3876 template <
typename T>
3880 template <
typename T>
3886 template <
typename T>
3887 inline internal::EqMatcher<T>
Eq(T x) {
return internal::EqMatcher<T>(x); }
3891 template <
typename T>
3906 template <
typename Lhs,
typename Rhs>
3910 template <
typename Rhs>
3911 inline internal::GeMatcher<Rhs>
Ge(Rhs x)
3913 return internal::GeMatcher<Rhs>(x);
3917 template <
typename Rhs>
3918 inline internal::GtMatcher<Rhs>
Gt(Rhs x)
3920 return internal::GtMatcher<Rhs>(x);
3924 template <
typename Rhs>
3925 inline internal::LeMatcher<Rhs>
Le(Rhs x)
3927 return internal::LeMatcher<Rhs>(x);
3931 template <
typename Rhs>
3932 inline internal::LtMatcher<Rhs>
Lt(Rhs x)
3934 return internal::LtMatcher<Rhs>(x);
3938 template <
typename Rhs>
3939 inline internal::NeMatcher<Rhs>
Ne(Rhs x)
3941 return internal::NeMatcher<Rhs>(x);
3960 template <
typename T>
3984 double rhs,
double max_abs_error)
3993 double rhs,
double max_abs_error)
4016 float rhs,
float max_abs_error)
4025 float rhs,
float max_abs_error)
4032 template <
typename InnerMatcher>
4034 const InnerMatcher & inner_matcher)
4043 template <
typename Class,
typename FieldType,
typename FieldMatcher>
4050 field, MatcherCast<const FieldType &>(matcher)));
4061 template <
typename Class,
typename PropertyType,
typename PropertyMatcher>
4064 PropertyType(Class::*property)()
const,
const PropertyMatcher & matcher)
4089 template <
typename Callable,
typename ResultOfMatcher>
4095 MatcherCast<typename internal::CallableTraits<Callable>::ResultType>(
4134 str,
false,
false));
4188 #if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING 4220 str,
false,
false));
4248 #endif // GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING 4252 inline internal::Eq2Matcher
Eq() {
return internal::Eq2Matcher(); }
4256 inline internal::Ge2Matcher
Ge() {
return internal::Ge2Matcher(); }
4260 inline internal::Gt2Matcher
Gt() {
return internal::Gt2Matcher(); }
4264 inline internal::Le2Matcher
Le() {
return internal::Le2Matcher(); }
4268 inline internal::Lt2Matcher
Lt() {
return internal::Lt2Matcher(); }
4272 inline internal::Ne2Matcher
Ne() {
return internal::Ne2Matcher(); }
4276 template <
typename InnerMatcher>
4285 template <
typename Predicate>
4287 Truly(Predicate pred)
4298 template <
typename SizeMatcher>
4300 SizeIs(
const SizeMatcher & size_matcher)
4309 template <
typename Container>
4323 template <
typename Comparator,
typename ContainerMatcher>
4326 const ContainerMatcher & container_matcher)
4329 comparator, container_matcher);
4334 template <
typename ContainerMatcher>
4336 WhenSorted(
const ContainerMatcher & container_matcher)
4349 template <
typename TupleMatcher,
typename Container>
4352 Pointwise(
const TupleMatcher & tuple_matcher,
const Container & rhs)
4358 tuple_matcher, rhs);
4379 template <
typename M>
4412 template <
typename M>
4421 template <
typename M>
4432 template <
typename FirstMatcher,
typename SecondMatcher>
4434 Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
4437 first_matcher, second_matcher);
4442 template <
typename M>
4449 template <
typename T,
typename M>
4450 inline bool Value(
const T & value, M matcher)
4457 template <
typename T,
typename M>
4461 return SafeMatcherCast<const T &>(matcher).MatchAndExplain(value, listener);
4464 #if GTEST_LANG_CXX11 4467 template <
typename...
Args>
4468 inline internal::AllOfMatcher<
Args...>
AllOf(
const Args & ... matchers)
4470 return internal::AllOfMatcher<
Args...>(matchers...);
4473 template <
typename...
Args>
4474 inline internal::AnyOfMatcher<
Args...>
AnyOf(
const Args & ... matchers)
4476 return internal::AnyOfMatcher<
Args...>(matchers...);
4479 #endif // GTEST_LANG_CXX11 4488 template <
typename InnerMatcher>
4489 inline InnerMatcher
AllArgs(
const InnerMatcher & matcher) {
return matcher; }
4495 #define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\ 4496 ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value) 4497 #define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\ 4498 ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value) 4502 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ LhsView::const_reference LhsStlContainerReference
virtual void DescribeTo(::std::ostream *os) const
virtual void DescribeTo(::std::ostream *os) const
PolymorphicMatcher< internal::IsNullMatcher > IsNull()
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
virtual void DescribeTo(::std::ostream *os) const
internal::GtMatcher< Rhs > Gt(Rhs x)
bool MatchAndExplainImpl(true_type, const Class *p, MatchResultListener *listener) const
virtual bool MatchAndExplain(T x, MatchResultListener *listener) const
static void ExplainMatchFailuresTo(const MatcherTuple &matchers, const ValueTuple &values,::std::ostream *os)
void DescribeToHelper(bool expect_eq,::std::ostream *os) const
internal::StlContainerView< GTEST_REMOVE_REFERENCE_AND_CONST_(Container) > ContainerView
virtual void DescribeNegationTo(::std::ostream *os) const
StartsWithMatcher(const StringType &prefix)
StrEqualityMatcher(const StringType &str, bool expect_eq, bool case_sensitive)
internal::StlContainerView< GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer) > LhsView
virtual void DescribeTo(::std::ostream *os) const
PolymorphicMatcher< internal::MatchesRegexMatcher > MatchesRegex(const internal::RE *regex)
CallableTraits< Callable >::StorageType CallableStorageType
static Matcher< T > Cast(M polymorphic_matcher_or_value)
internal::NeMatcher< Rhs > Ne(Rhs x)
Impl(const InnerMatcher &matcher)
bool MatchAndExplain(const T &value, MatchResultListener *listener) const
virtual void DescribeTo(::std::ostream *os) const
PolymorphicMatcher< internal::NotNullMatcher > NotNull()
AssertionResult AssertionFailure()
virtual void DescribeNegationTo(::std::ostream *os) const
internal::StlContainerView< RhsContainer > RhsView
EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
virtual void DescribeNegationTo(::std::ostream *os) const
static void CheckIsValid(Functor)
virtual bool MatchAndExplain(T value, MatchResultListener *) const
Impl(const Matcher< U > &source_matcher)
MatchResultListener(::std::ostream *os)
BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
virtual void DescribeTo(::std::ostream *os) const
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeTo(::std::ostream *os) const
internal::EqMatcher< T > Eq(T x)
void ExplainMatchResultTo(T x,::std::ostream *os) const
::std::string PrintToString(const T &value)
LhsView::type LhsStlContainer
static Matcher< T > Cast(const Matcher< U > &source_matcher)
::std::ostream * stream()
internal::StlContainerView< RawContainer > View
internal::SizeIsMatcher< SizeMatcher > SizeIs(const SizeMatcher &size_matcher)
RawPairType::second_type SecondType
Matcher(const MatcherInterface< const internal::string & > *impl)
ElementsAreArrayMatcher(Iter first, Iter last)
GTEST_API_ bool FindPairing(const MatchMatrix &matrix, MatchResultListener *listener)
StlContainer::value_type Element
virtual bool MatchAndExplain(Pointer pointer, MatchResultListener *listener) const
virtual void DescribeTo(::std::ostream *os) const
void DescribeTo(::std::ostream *os) const
PolymorphicMatcher< internal::MatchesRegexMatcher > ContainsRegex(const internal::RE *regex)
size_t SpaceIndex(size_t ilhs, size_t irhs) const
static Matcher< T > Cast(const Matcher< U > &matcher)
internal::KeyMatcher< M > Key(M inner_matcher)
bool HasEdge(size_t ilhs, size_t irhs) const
EndsWithMatcher(const StringType &suffix)
virtual void DescribeNegationTo(::std::ostream *os) const
internal::string str() const
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
bool IsInterested() const
InnerMatcher AllArgs(const InnerMatcher &matcher)
void DescribeTo(::std::ostream *os) const
void DescribeTo(::std::ostream *os) const
bool HasMaxAbsError() const
NotMatcherImpl(const Matcher< T > &matcher)
virtual void DescribeNegationTo(::std::ostream *os) const
bool MatchPrintAndExplain(Value &value, const Matcher< T > &matcher, MatchResultListener *listener)
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeTo(::std::ostream *os) const
void DescribeNegationTo(::std::ostream *os) const
EachMatcherImpl(InnerMatcher inner_matcher)
internal::PointwiseMatcher< TupleMatcher, GTEST_REMOVE_CONST_(Container)> Pointwise(const TupleMatcher &tuple_matcher, const Container &rhs)
internal::FloatingEqMatcher< double > NanSensitiveDoubleEq(double rhs)
QuantifierMatcherImpl(InnerMatcher inner_matcher)
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
bool TupleMatches(const MatcherTuple &matcher_tuple, const ValueTuple &value_tuple)
PolymorphicMatcher< internal::EndsWithMatcher< internal::string > > EndsWith(const internal::string &suffix)
#define GMOCK_IMPLEMENT_COMPARISON_MATCHER_(name, op, relation, negated_relation)
virtual bool MatchAndExplain(T obj, MatchResultListener *listener) const
internal::UnorderedElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > UnorderedElementsAreArray(Iter first, Iter last)
#define GTEST_COMPILE_ASSERT_(expr, msg)
const Impl & impl() const
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
FieldMatcher(FieldType Class::*field, const Matcher< const FieldType & > &matcher)
static Matcher< T > Cast(M polymorphic_matcher_or_value)
bool MatchAndExplainImpl(false_type, const Class &obj, MatchResultListener *listener) const
bool MatchAndExplain(T &x, MatchResultListener *) const
View::const_reference StlContainerReference
virtual bool MatchAndExplain(PairType key_value, MatchResultListener *listener) const
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
virtual void DescribeNegationTo(::std::ostream *os) const
internal::AllOfResult2< M1, M2 >::type AllOf(M1 m1, M2 m2)
internal::RefMatcher< T & > Ref(T &x)
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrEq(const internal::string &str)
virtual void DescribeTo(::std::ostream *os) const
::std::vector< ElementMatcherPair > ElementMatcherPairs
void DescribeTo(::std::ostream *os) const
Impl(const SizeMatcher &size_matcher)
virtual ~MatcherDescriberInterface()
void DescribeNegationTo(::std::ostream *os) const
PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher)
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
internal::LtMatcher< Rhs > Lt(Rhs x)
StreamMatchResultListener(::std::ostream *os)
ElementsAreMatcher(const MatcherTuple &args)
void DescribeNegationTo(::std::ostream *os) const
static Matcher< T > CastImpl(M polymorphic_matcher_or_value, BooleanConstant< true >)
MatcherBase(const MatcherInterface< T > *impl)
internal::FloatingEqMatcher< double > DoubleNear(double rhs, double max_abs_error)
FloatingEqMatcher(FloatType rhs, bool nan_eq_nan)
bool MatchAndExplain(T x, MatchResultListener *listener) const
internal::FloatingEqMatcher< double > DoubleEq(double rhs)
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
void DescribeTo(::std::ostream *os) const
NotMatcher(InnerMatcher matcher)
Matcher(const MatcherInterface< T > *impl)
virtual bool MatchAndExplain(T x, MatchResultListener *listener) const
virtual void DescribeNegationTo(::std::ostream *os) const
void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeNegationTo(::std::ostream *os) const
MatchMatrix(size_t num_elements, size_t num_matchers)
internal::LeMatcher< Rhs > Le(Rhs x)
MatchesRegexMatcher(const RE *regex, bool full_match)
RawPairType::first_type FirstType
AssertionResult AssertionSuccess()
PolymorphicMatcher< Impl > MakePolymorphicMatcher(const Impl &impl)
TrulyMatcher(Predicate pred)
void DescribeTo(::std::ostream *os) const
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrCaseNe(const internal::string &str)
StlContainer::const_iterator StlContainerConstIterator
BothOfMatcherImpl(const Matcher< T > &matcher1, const Matcher< T > &matcher2)
static void ExplainMatchFailuresTo(const MatcherTuple &, const ValueTuple &,::std::ostream *)
def Iter(n, format, sep='')
static Matcher< T > CastImpl(M value, BooleanConstant< false >)
void DescribeNegationTo(::std::ostream *os) const
MatcherDescriberVec & matcher_describers()
void DescribeTo(::std::ostream *os) const
internal::ElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > ElementsAreArray(Iter first, Iter last)
string Print(const T &value)
PolymorphicMatcher(const Impl &an_impl)
MatchMatrix AnalyzeElements(ElementIter elem_first, ElementIter elem_last,::std::vector< string > *element_printouts, MatchResultListener *listener) const
MatchResultListener & operator<<(const T &x)
bool MatchAndExplainImpl(true_type, const Class *p, MatchResultListener *listener) const
bool MatchAndExplain(const T &value, MatchResultListener *listener) const
::std::vector< Matcher< const Element & > > MatcherVec
PolymorphicMatcher< internal::HasSubstrMatcher< internal::string > > HasSubstr(const internal::string &substring)
void DescribeNegationTo(::std::ostream *os) const
bool Value(const T &value, M matcher)
virtual bool MatchAndExplain(T x, MatchResultListener *listener) const
void DescribeTo(::std::ostream *os) const
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
static Message Elements(size_t n)
void PrintIfNotEmpty(const internal::string &explanation,::std::ostream *os)
virtual bool MatchAndExplain(Super &x, MatchResultListener *listener) const
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
UnorderedElementsAreArrayMatcher(Iter first, Iter last)
bool MatchAndExplain(const Pointer &p, MatchResultListener *) const
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeTo(::std::ostream *os) const
PropertyMatcher(PropertyType(Class::*property)() const, const Matcher< RefToConstProperty > &matcher)
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
bool CaseInsensitiveCStringEquals(const char *lhs, const char *rhs)
internal::MatcherAsPredicate< M > Matches(M matcher)
virtual bool MatchAndExplain(T x, MatchResultListener *listener) const
Matcher< T > MakeMatcher(const MatcherInterface< T > *impl)
Matcher< T > SafeMatcherCast(const M &polymorphic_matcher)
virtual bool MatchAndExplain(LhsContainer lhs, MatchResultListener *listener) const
UnorderedElementsAreMatcherImpl(InputIter first, InputIter last)
::std::pair< size_t, size_t > ElementMatcherPair
void UniversalPrint(const T &value,::std::ostream *os)
internal::FloatingEqMatcher< float > NanSensitiveFloatEq(float rhs)
virtual void DescribeTo(::std::ostream *os) const
Functor::result_type ResultType
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T)
void DescribeNegationTo(::std::ostream *os) const
#define GTEST_DISALLOW_ASSIGN_(type)
void DescribeTo(::std::ostream *os) const
virtual void DescribeNegationTo(::std::ostream *os) const
DummyMatchResultListener()
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
#define GTEST_REMOVE_REFERENCE_(T)
GTEST_API_ string FormatMatcherDescription(bool negation, const char *matcher_name, const Strings ¶m_values)
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
virtual bool MatchAndExplain(PairType a_pair, MatchResultListener *listener) const
void DescribeNegationTo(::std::ostream *os) const
GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener)
RhsView::type RhsStlContainer
#define GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(name, op, relation)
PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher)
#define GTEST_REFERENCE_TO_CONST_(T)
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
virtual bool MatchAndExplain(LhsContainer lhs, MatchResultListener *listener) const
bool MatchAndExplain(const Pointer &p, MatchResultListener *) const
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
virtual void DescribeNegationTo(::std::ostream *os) const
void DescribeTo(::std::ostream *os) const
ElementsAreMatcherImpl(InputIter first, InputIter last)
View::const_reference StlContainerReference
virtual void DescribeTo(::std::ostream *os) const
ContainsMatcherImpl(InnerMatcher inner_matcher)
static Matcher< T > Cast(const Matcher< T > &matcher)
internal::FloatingEqMatcher< float > NanSensitiveFloatNear(float rhs, float max_abs_error)
virtual void DescribeTo(::std::ostream *os) const
static bool Matches(const MatcherTuple &matcher_tuple, const ValueTuple &value_tuple)
MonomorphicImpl(const Impl &impl)
static ResType Invoke(ResType(*f)(ArgType), T arg)
void DescribeTo(::std::ostream *os) const
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrNe(const internal::string &str)
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
bool operator()(const T &lhs, const U &rhs) const
PredicateFormatterFromMatcher< M > MakePredicateFormatterFromMatcher(const M &matcher)
void ExplainMatchFailureTupleTo(const MatcherTuple &matchers, const ValueTuple &values,::std::ostream *os)
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
const type & const_reference
ResultOfMatcher(Callable callable, const Matcher< ResultType > &matcher)
virtual void DescribeTo(::std::ostream *os) const
HasSubstrMatcher(const StringType &substring)
void SetEdge(size_t ilhs, size_t irhs, bool b)
bool MatchAndExplain(const LhsContainer &lhs, MatchResultListener *listener) const
Matcher< Lhs > TypedEq(const Rhs &rhs)
::std::ostream *const stream_
#define GMOCK_KIND_OF_(type)
internal::WhenSortedByMatcher< internal::LessComparator, ContainerMatcher > WhenSorted(const ContainerMatcher &container_matcher)
View::const_reference StlContainerReference
internal::FloatingEqMatcher< double > NanSensitiveDoubleNear(double rhs, double max_abs_error)
internal::NamedArg< char > arg(StringRef name, const T &arg)
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
FloatingEqMatcher(FloatType rhs, bool nan_eq_nan, FloatType max_abs_error)
RawPairType::first_type KeyType
Matcher< T > MatcherCast(M matcher)
virtual void DescribeTo(::std::ostream *os) const
static bool Matches(const MatcherTuple &, const ValueTuple &)
ContainerView::type::size_type SizeType
virtual ~MatchResultListener()=0
WhenSortedByMatcher(const Comparator &comparator, const ContainerMatcher &matcher)
Impl(const TupleMatcher &tuple_matcher, const RhsStlContainer &rhs)
const MatcherDescriberInterface * GetDescriber() const
LhsView::const_reference LhsStlContainerReference
void DescribeTo(::std::ostream *os) const
internal::StlContainerView< GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer) > LhsView
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeTo(::std::ostream *os) const
GTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix &g)
StlContainer::value_type Element
internal::EachMatcher< M > Each(M matcher)
bool IsReadableTypeName(const string &type_name)
PointeeOf< GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(Pointer))>::type Pointee
OutIter TransformTupleValues(Func f, const Tuple &t, OutIter out)
LhsStlContainer::value_type LhsValue
::std::vector< string > Strings
#define GTEST_REMOVE_CONST_(T)
internal::FloatingEqMatcher< float > FloatEq(float rhs)
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
virtual void DescribeTo(::std::ostream *os) const
StlContainer::value_type Element
const Pointer::element_type * GetRawPointer(const Pointer &p)
LhsView::type LhsStlContainer
bool_constant< false > false_type
bool StaticAssertTypeEq()
View::const_reference StlContainerReference
bool CaseInsensitiveStringEquals(const StringType &s1, const StringType &s2)
void DescribeNegationTo(::std::ostream *os) const
virtual bool MatchAndExplain(T, MatchResultListener *) const
const internal::AnythingMatcher _
virtual void DescribeNegationTo(::std::ostream *os) const
PointeeMatcher(const InnerMatcher &matcher)
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
void DescribeNegationTo(::std::ostream *os) const
bool MatchAndExplainImpl(false_type, const Class &obj, MatchResultListener *listener) const
KeyMatcherImpl(InnerMatcher inner_matcher)
CallableTraits< Callable >::ResultType ResultType
StlContainerView< RawContainer > View
UnorderedElementsAreArrayMatcher()
RemoveConstFromKey< typename LhsStlContainer::value_type >::type LhsValue
UnorderedElementsAreMatcher(const MatcherTuple &args)
virtual bool MatchAndExplain(T x, MatchResultListener *listener) const
virtual void DescribeNegationTo(::std::ostream *os) const
ContainerEqMatcher(const Container &rhs)
virtual void DescribeTo(::std::ostream *os) const
internal::GeMatcher< Rhs > Ge(Rhs x)
Iter ArrayAwareFind(Iter begin, Iter end, const Element &elem)
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrCaseEq(const internal::string &str)
bool operator()(const T &x) const
void DescribeNegationTo(::std::ostream *os) const
void ExplainSuccess(const internal::string &first_explanation, const internal::string &second_explanation, MatchResultListener *listener) const
internal::StlContainerView< RawContainer > View
void DescribeNegationTo(::std::ostream *os) const
EitherOfMatcherImpl(const Matcher< T > &matcher1, const Matcher< T > &matcher2)
internal::ContainsMatcher< M > Contains(M matcher)
#define GTEST_CHECK_(condition)
Impl(FloatType rhs, bool nan_eq_nan, FloatType max_abs_error)
internal::StlContainerView< Container > View
static void CheckIsValid(ResType(*f)(ArgType))
internal::ResultOfMatcher< Callable > ResultOf(Callable callable, const ResultOfMatcher &matcher)
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
PointwiseMatcher(const TupleMatcher &tuple_matcher, const RhsContainer &rhs)
Impl(CallableStorageType callable, const Matcher< ResultType > &matcher)
MatcherAsPredicate(M matcher)
Matcher(const MatcherInterface< internal::string > *impl)
static Message Elements(size_t count)
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
::std::tr1::tuple< const LhsValue &, const RhsValue & > InnerMatcherArg
virtual void DescribeNegationTo(::std::ostream *os) const
SizeIsMatcher(const SizeMatcher &size_matcher)
virtual void DescribeNegationTo(::std::ostream *os) const
::std::vector< const MatcherDescriberInterface * > MatcherDescriberVec
internal::WhenSortedByMatcher< Comparator, ContainerMatcher > WhenSortedBy(const Comparator &comparator, const ContainerMatcher &container_matcher)
StringMatchResultListener()
bool MatchAndExplainImpl(bool all_elements_should_match, Container container, MatchResultListener *listener) const
static ResultType Invoke(Functor f, T arg)
RhsStlContainer::value_type RhsValue
Impl(const Comparator &comparator, const ContainerMatcher &matcher)
virtual void DescribeNegationTo(::std::ostream *os) const
internal::FloatingEqMatcher< float > FloatNear(float rhs, float max_abs_error)