38#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
39#define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
54#if GTEST_HAS_STD_INITIALIZER_LIST_
55# include <initializer_list>
97 ::std::ostream*
stream() {
return stream_; }
106 ::std::ostream*
const stream_;
195 impl_->DescribeNegationTo(
os);
200 return impl_->MatchAndExplain(x, listener);
217 std::string
str()
const {
return ss_.str(); }
223 ::std::stringstream ss_;
231 template <
typename A,
typename B>
235 template <
typename A,
typename B>
239 template <
typename A,
typename B>
243 template <
typename A,
typename B>
247 template <
typename A,
typename B>
251 template <
typename A,
typename B>
286 return impl_->MatchAndExplain(x, listener);
300 impl_->DescribeNegationTo(
os);
305 ::std::ostream*
os)
const {
325 template <
typename U>
360class Matcher :
public internal::MatcherBase<T> {
371 template <
typename U>
392 :
internal::MatcherBase<const
std::string&>(impl) {}
398#if GTEST_HAS_GLOBAL_STRING
423#if GTEST_HAS_GLOBAL_STRING
433#if GTEST_HAS_GLOBAL_STRING
439 :
public internal::MatcherBase<const ::string&> {
443 explicit Matcher(
const MatcherInterface<const ::string&>* impl)
444 :
internal::MatcherBase<const ::string&>(impl) {}
448 Matcher(
const std::string&
s);
452 Matcher(const ::string&
s);
455 Matcher(
const char*
s);
460 :
public internal::MatcherBase< ::string> {
464 explicit Matcher(
const MatcherInterface<const ::string&>* impl)
465 :
internal::MatcherBase< ::string>(impl) {}
466 explicit Matcher(
const MatcherInterface< ::string>* impl)
467 :
internal::MatcherBase< ::string>(impl) {}
471 Matcher(
const std::string&
s);
475 Matcher(const ::string&
s);
478 Matcher(
const char*
s);
487class GTEST_API_ Matcher<const absl::string_view&>
488 :
public internal::MatcherBase<const absl::string_view&> {
492 explicit Matcher(
const MatcherInterface<const absl::string_view&>* impl)
493 :
internal::MatcherBase<const absl::string_view&>(impl) {}
497 Matcher(
const std::string&
s);
499#if GTEST_HAS_GLOBAL_STRING
502 Matcher(const ::string&
s);
506 Matcher(
const char*
s);
509 Matcher(absl::string_view
s);
514 :
public internal::MatcherBase<absl::string_view> {
518 explicit Matcher(
const MatcherInterface<const absl::string_view&>* impl)
519 :
internal::MatcherBase<absl::string_view>(impl) {}
520 explicit Matcher(
const MatcherInterface<absl::string_view>* impl)
521 :
internal::MatcherBase<absl::string_view>(impl) {}
525 Matcher(
const std::string&
s);
527#if GTEST_HAS_GLOBAL_STRING
530 Matcher(const ::string&
s);
534 Matcher(
const char*
s);
537 Matcher(absl::string_view
s);
544 matcher.DescribeTo(&
os);
571 const Impl&
impl()
const {
return impl_; }
573 template <
typename T>
579 template <
typename T>
582 explicit MonomorphicImpl(
const Impl&
impl) : impl_(
impl) {}
584 virtual void DescribeTo(::std::ostream*
os)
const {
585 impl_.DescribeTo(
os);
588 virtual void DescribeNegationTo(::std::ostream*
os)
const {
589 impl_.DescribeNegationTo(
os);
592 virtual bool MatchAndExplain(
T x, MatchResultListener* listener)
const {
593 return impl_.MatchAndExplain(x, listener);
645template <
typename T,
typename M>
663 polymorphic_matcher_or_value,
671 template <
bool Ignore>
672 static Matcher<T> CastImpl(
const M& polymorphic_matcher_or_value,
683 return polymorphic_matcher_or_value;
690 const M&
value, BooleanConstant<false> ,
691 BooleanConstant<true> ) {
705 static Matcher<T> CastImpl(
706 const M&
value, BooleanConstant<false> ,
707 BooleanConstant<false> );
713template <
typename T,
typename U>
723 explicit Impl(
const Matcher<U>& source_matcher)
724 : source_matcher_(source_matcher) {}
729 using FromType =
typename std::remove_cv<
typename std::remove_pointer<
730 typename std::remove_reference<T>::type>::type>
::type;
731 using ToType =
typename std::remove_cv<
typename std::remove_pointer<
732 typename std::remove_reference<U>::type>::type>
::type;
737 (std::is_pointer<typename std::remove_reference<T>::type>
::value !=
738 std::is_pointer<typename std::remove_reference<U>::type>
::value) ||
739 std::is_same<FromType, ToType>::value ||
740 !std::is_base_of<FromType, ToType>::value,
741 "Can't implicitly convert from <base> to <derived>");
744 return source_matcher_.MatchAndExplain(
static_cast<U>(x), listener);
747 virtual void DescribeTo(::std::ostream*
os)
const {
748 source_matcher_.DescribeTo(
os);
751 virtual void DescribeNegationTo(::std::ostream*
os)
const {
752 source_matcher_.DescribeNegationTo(
os);
756 const Matcher<U> source_matcher_;
776template <
typename T,
typename M>
793 template <
typename M>
807 template <
typename U>
811 T_must_be_implicitly_convertible_to_U);
816 cannot_convert_non_reference_arg_to_reference);
824 kTIsOther || kUIsOther ||
825 (internal::LosslessArithmeticConvertible<RawT, RawU>::value),
826 conversion_of_arithmetic_types_must_be_lossless);
831template <
typename T,
typename M>
846 ::std::ostream*
os) {
847 if (explanation !=
"" &&
os != NULL) {
848 *
os <<
", " << explanation;
858 return (type_name.length() <= 20 ||
859 type_name.find_first_of(
"<(") == std::string::npos);
867template <
typename Value,
typename T>
873 return matcher.Matches(
value);
877 const bool match = matcher.MatchAndExplain(
value, &inner_listener);
883 *listener->
stream() <<
" (of type " << type_name <<
")";
898 template <
typename MatcherTuple,
typename ValueTuple>
900 const ValueTuple& value_tuple) {
902 && get<
N - 1>(matcher_tuple).
Matches(get<N - 1>(value_tuple));
909 template <
typename MatcherTuple,
typename ValueTuple>
911 const ValueTuple& values,
912 ::std::ostream*
os) {
919 get<
N - 1>(matchers);
920 typedef typename tuple_element<
N - 1, ValueTuple>::type
Value;
923 if (!matcher.MatchAndExplain(
value, &listener)) {
926 *
os <<
" Expected arg #" <<
N - 1 <<
": ";
927 get<
N - 1>(matchers).DescribeTo(
os);
928 *
os <<
"\n Actual: ";
945 template <
typename MatcherTuple,
typename ValueTuple>
947 const ValueTuple& ) {
951 template <
typename MatcherTuple,
typename ValueTuple>
962template <
typename MatcherTuple,
typename ValueTuple>
964 const ValueTuple& value_tuple) {
968 tuple_size<ValueTuple>::value,
969 matcher_and_value_have_different_numbers_of_fields);
971 Matches(matcher_tuple, value_tuple);
976template <
typename MatcherTuple,
typename ValueTuple>
978 const ValueTuple& values,
979 ::std::ostream*
os) {
981 matchers, values,
os);
988template <
typename Tuple,
typename Func,
typename OutIter>
991 typedef ::testing::tuple_size<Tuple> TupleSize;
996 static OutIter
Run(Func
f,
const Tuple& t, OutIter out) {
997 return IterateOverTuple<Tuple, TupleSize::value>()(
f, t, out);
1001 template <
typename Tup,
size_t kRemainingSize>
1002 struct IterateOverTuple {
1003 OutIter operator() (Func
f,
const Tup& t, OutIter out)
const {
1004 *out++ =
f(::testing::get<TupleSize::value - kRemainingSize>(t));
1005 return IterateOverTuple<Tup, kRemainingSize - 1>()(
f, t, out);
1008 template <
typename Tup>
1009 struct IterateOverTuple<Tup, 0> {
1010 OutIter operator() (Func ,
const Tup& , OutIter out)
const {
1019template <
typename Tuple,
typename Func,
typename OutIter>
1025template <
typename T>
1037 *
os <<
"never matches";
1047 template <
typename T>
1061template <
typename D,
typename Rhs,
typename Op>
1065 template <
typename Lhs>
1071 template <
typename Lhs>
1074 explicit Impl(
const Rhs& rhs) : rhs_(rhs) {}
1075 virtual bool MatchAndExplain(
1077 return Op()(lhs, rhs_);
1079 virtual void DescribeTo(::std::ostream*
os)
const {
1080 *
os << D::Desc() <<
" ";
1083 virtual void DescribeNegationTo(::std::ostream*
os)
const {
1084 *
os << D::NegatedDesc() <<
" ";
1095template <
typename Rhs>
1100 static const char*
Desc() {
return "is equal to"; }
1103template <
typename Rhs>
1108 static const char*
Desc() {
return "isn't equal to"; }
1111template <
typename Rhs>
1116 static const char*
Desc() {
return "is <"; }
1119template <
typename Rhs>
1124 static const char*
Desc() {
return "is >"; }
1127template <
typename Rhs>
1132 static const char*
Desc() {
return "is <="; }
1135template <
typename Rhs>
1140 static const char*
Desc() {
return "is >="; }
1148 template <
typename Po
inter>
1152 return p ==
nullptr;
1160 *
os <<
"isn't NULL";
1168 template <
typename Po
inter>
1172 return p !=
nullptr;
1197template <
typename T>
1200template <
typename T>
1213 template <
typename Super>
1224 template <
typename Super>
1227 explicit Impl(Super& x) : object_(x) {}
1231 virtual bool MatchAndExplain(
1233 *listener <<
"which is located @" <<
static_cast<const void*
>(&x);
1234 return &x == &object_;
1237 virtual void DescribeTo(::std::ostream*
os)
const {
1238 *
os <<
"references the variable ";
1239 UniversalPrinter<Super&>::Print(object_,
os);
1242 virtual void DescribeNegationTo(::std::ostream*
os)
const {
1243 *
os <<
"does not reference the variable ";
1244 UniversalPrinter<Super&>::Print(object_,
os);
1248 const Super& object_;
1264 const wchar_t* rhs) {
1270template <
typename StringType>
1272 const StringType& s2) {
1279 const typename StringType::value_type nul = 0;
1280 const size_t i1 = s1.find(nul), i2 = s2.find(nul);
1283 if (i1 == StringType::npos || i2 == StringType::npos) {
1294template <
typename StringType>
1298 bool case_sensitive)
1299 : string_(str), expect_eq_(expect_eq), case_sensitive_(case_sensitive) {}
1304 if (
s.data() == NULL) {
1309 const StringType& str =
string(
s);
1319 template <
typename CharType>
1331 template <
typename MatcheeStringType>
1334 const StringType& s2(
s);
1335 const bool eq = case_sensitive_ ? s2 == string_ :
1337 return expect_eq_ == eq;
1341 DescribeToHelper(expect_eq_,
os);
1345 DescribeToHelper(!expect_eq_,
os);
1349 void DescribeToHelper(
bool expect_eq, ::std::ostream*
os)
const {
1350 *
os << (expect_eq ?
"is " :
"isn't ");
1352 if (!case_sensitive_) {
1353 *
os <<
"(ignoring case) ";
1358 const StringType string_;
1359 const bool expect_eq_;
1360 const bool case_sensitive_;
1368template <
typename StringType>
1372 : substring_(substring) {}
1377 if (
s.data() == NULL) {
1382 const StringType& str =
string(
s);
1392 template <
typename CharType>
1401 template <
typename MatcheeStringType>
1404 const StringType& s2(
s);
1405 return s2.find(substring_) != StringType::npos;
1410 *
os <<
"has substring ";
1415 *
os <<
"has no substring ";
1420 const StringType substring_;
1428template <
typename StringType>
1437 if (
s.data() == NULL) {
1442 const StringType& str =
string(
s);
1452 template <
typename CharType>
1461 template <
typename MatcheeStringType>
1464 const StringType& s2(
s);
1465 return s2.length() >= prefix_.length() &&
1466 s2.substr(0, prefix_.length()) == prefix_;
1470 *
os <<
"starts with ";
1475 *
os <<
"doesn't start with ";
1480 const StringType prefix_;
1488template <
typename StringType>
1496 if (
s.data() == NULL) {
1501 const StringType& str =
string(
s);
1511 template <
typename CharType>
1520 template <
typename MatcheeStringType>
1523 const StringType& s2(
s);
1524 return s2.length() >= suffix_.length() &&
1525 s2.substr(s2.length() - suffix_.length()) == suffix_;
1529 *
os <<
"ends with ";
1534 *
os <<
"doesn't end with ";
1539 const StringType suffix_;
1550 : regex_(regex), full_match_(full_match) {}
1564 template <
typename CharType>
1573 template <
class MatcheeStringType>
1576 const std::string& s2(
s);
1582 *
os << (full_match_ ?
"matches" :
"contains")
1583 <<
" regular expression ";
1588 *
os <<
"doesn't " << (full_match_ ?
"match" :
"contain")
1589 <<
" regular expression ";
1595 const bool full_match_;
1608template <
typename D,
typename Op>
1611 template <
typename T1,
typename T2>
1613 return MakeMatcher(
new Impl< ::testing::tuple<T1, T2> >);
1615 template <
typename T1,
typename T2>
1617 return MakeMatcher(
new Impl<const ::testing::tuple<T1, T2>&>);
1621 static ::std::ostream& GetDesc(::std::ostream&
os) {
1622 return os << D::Desc();
1625 template <
typename Tuple>
1628 virtual bool MatchAndExplain(
1631 return Op()(::testing::get<0>(args), ::testing::get<1>(args));
1633 virtual void DescribeTo(::std::ostream*
os)
const {
1634 *
os <<
"are " << GetDesc;
1636 virtual void DescribeNegationTo(::std::ostream*
os)
const {
1637 *
os <<
"aren't " << GetDesc;
1644 static const char*
Desc() {
return "an equal pair"; }
1648 static const char*
Desc() {
return "an unequal pair"; }
1652 static const char*
Desc() {
return "a pair where the first < the second"; }
1656 static const char*
Desc() {
return "a pair where the first > the second"; }
1660 static const char*
Desc() {
return "a pair where the first <= the second"; }
1664 static const char*
Desc() {
return "a pair where the first >= the second"; }
1671template <
typename T>
1675 : matcher_(matcher) {}
1679 return !matcher_.MatchAndExplain(x, listener);
1683 matcher_.DescribeNegationTo(
os);
1687 matcher_.DescribeTo(
os);
1698template <
typename InnerMatcher>
1705 template <
typename T>
1711 InnerMatcher matcher_;
1720template <
typename T>
1725 : matchers_(
internal::move(matchers)) {}
1729 for (
size_t i = 0; i < matchers_.size(); ++i) {
1730 if (i != 0) *
os <<
") and (";
1731 matchers_[i].DescribeTo(
os);
1738 for (
size_t i = 0; i < matchers_.size(); ++i) {
1739 if (i != 0) *
os <<
") or (";
1740 matchers_[i].DescribeNegationTo(
os);
1749 std::string all_match_result;
1751 for (
size_t i = 0; i < matchers_.size(); ++i) {
1754 if (all_match_result.empty()) {
1755 all_match_result = slistener.
str();
1757 std::string result = slistener.
str();
1758 if (!result.empty()) {
1759 all_match_result +=
", and ";
1760 all_match_result += result;
1764 *listener << slistener.
str();
1770 *listener << all_match_result;
1775 const std::vector<Matcher<T> > matchers_;
1785template <
template <
typename T>
class CombiningMatcher,
typename... Args>
1786class VariadicMatcher {
1788 VariadicMatcher(
const Args&... matchers)
1789 : matchers_(matchers...) {
1790 static_assert(
sizeof...(Args) > 0,
"Must have at least one matcher.");
1796 template <
typename T>
1797 operator Matcher<T>()
const {
1798 std::vector<Matcher<T> > values;
1799 CreateVariadicMatcher<T>(&values, std::integral_constant<size_t, 0>());
1800 return Matcher<T>(
new CombiningMatcher<T>(internal::move(values)));
1804 template <
typename T,
size_t I>
1805 void CreateVariadicMatcher(std::vector<Matcher<T> >* values,
1806 std::integral_constant<size_t, I>)
const {
1807 values->push_back(SafeMatcherCast<T>(std::get<I>(matchers_)));
1808 CreateVariadicMatcher<T>(values, std::integral_constant<size_t, I + 1>());
1811 template <
typename T>
1812 void CreateVariadicMatcher(
1813 std::vector<Matcher<T> >*,
1814 std::integral_constant<
size_t,
sizeof...(Args)>)
const {}
1816 tuple<Args...> matchers_;
1821template <
typename... Args>
1822using AllOfMatcher = VariadicMatcher<AllOfMatcherImpl, Args...>;
1828template <
typename Matcher1,
typename Matcher2>
1832 : matcher1_(matcher1), matcher2_(matcher2) {}
1837 template <
typename T>
1839 std::vector<Matcher<T> > values;
1856template <
typename T>
1861 : matchers_(
internal::move(matchers)) {}
1865 for (
size_t i = 0; i < matchers_.size(); ++i) {
1866 if (i != 0) *
os <<
") or (";
1867 matchers_[i].DescribeTo(
os);
1874 for (
size_t i = 0; i < matchers_.size(); ++i) {
1875 if (i != 0) *
os <<
") and (";
1876 matchers_[i].DescribeNegationTo(
os);
1883 std::string no_match_result;
1887 for (
size_t i = 0; i < matchers_.size(); ++i) {
1890 *listener << slistener.
str();
1893 if (no_match_result.empty()) {
1894 no_match_result = slistener.
str();
1896 std::string result = slistener.
str();
1897 if (!result.empty()) {
1898 no_match_result +=
", and ";
1899 no_match_result += result;
1906 *listener << no_match_result;
1911 const std::vector<Matcher<T> > matchers_;
1918template <
typename... Args>
1919using AnyOfMatcher = VariadicMatcher<AnyOfMatcherImpl, Args...>;
1926template <
typename Matcher1,
typename Matcher2>
1930 : matcher1_(matcher1), matcher2_(matcher2) {}
1935 template <
typename T>
1937 std::vector<Matcher<T> > values;
1952template <
typename Predicate>
1961 template <
typename T>
1976 *
os <<
"satisfies the given predicate";
1980 *
os <<
"doesn't satisfy the given predicate";
1984 Predicate predicate_;
1991template <
typename M>
2002 template <
typename T>
2029template <
typename M>
2037 template <
typename T>
2055 ::std::stringstream ss;
2056 ss <<
"Value of: " << value_text <<
"\n"
2058 matcher.DescribeTo(&ss);
2059 ss <<
"\n Actual: " << listener.
str();
2073template <
typename M>
2074inline PredicateFormatterFromMatcher<M>
2083template <
typename FloatType>
2093 expected_(expected), nan_eq_nan_(nan_eq_nan), max_abs_error_(-1) {
2100 FloatType max_abs_error)
2101 : expected_(expected),
2102 nan_eq_nan_(nan_eq_nan),
2103 max_abs_error_(max_abs_error) {
2105 <<
", where max_abs_error is" << max_abs_error;
2109 template <
typename T>
2112 Impl(FloatType expected,
bool nan_eq_nan, FloatType max_abs_error)
2113 : expected_(expected),
2114 nan_eq_nan_(nan_eq_nan),
2115 max_abs_error_(max_abs_error) {}
2122 if (actual.is_nan() || expected.
is_nan()) {
2123 if (actual.is_nan() && expected.
is_nan()) {
2129 if (HasMaxAbsError()) {
2134 if (
value == expected_) {
2138 const FloatType
diff =
value - expected_;
2139 if (
fabs(
diff) <= max_abs_error_) {
2144 *listener <<
"which is " <<
diff <<
" from " << expected_;
2148 return actual.AlmostEquals(expected);
2156 const ::std::streamsize old_precision =
os->precision(
2157 ::std::numeric_limits<FloatType>::digits10 + 2);
2162 *
os <<
"never matches";
2165 *
os <<
"is approximately " << expected_;
2166 if (HasMaxAbsError()) {
2167 *
os <<
" (absolute error <= " << max_abs_error_ <<
")";
2170 os->precision(old_precision);
2175 const ::std::streamsize old_precision =
os->precision(
2176 ::std::numeric_limits<FloatType>::digits10 + 2);
2181 *
os <<
"is anything";
2184 *
os <<
"isn't approximately " << expected_;
2185 if (HasMaxAbsError()) {
2186 *
os <<
" (absolute error > " << max_abs_error_ <<
")";
2190 os->precision(old_precision);
2194 bool HasMaxAbsError()
const {
2195 return max_abs_error_ >= 0;
2198 const FloatType expected_;
2199 const bool nan_eq_nan_;
2201 const FloatType max_abs_error_;
2228 const FloatType expected_;
2229 const bool nan_eq_nan_;
2231 const FloatType max_abs_error_;
2241template <
typename FloatType>
2249 Init(max_abs_error,
false);
2253 Init(max_abs_error, nan_eq_nan);
2256 template <
typename T1,
typename T2>
2259 new Impl< ::testing::tuple<T1, T2> >(max_abs_error_, nan_eq_nan_));
2261 template <
typename T1,
typename T2>
2264 new Impl<const ::testing::tuple<T1, T2>&>(max_abs_error_, nan_eq_nan_));
2268 static ::std::ostream& GetDesc(::std::ostream&
os) {
2269 return os <<
"an almost-equal pair";
2272 template <
typename Tuple>
2275 Impl(FloatType max_abs_error,
bool nan_eq_nan) :
2276 max_abs_error_(max_abs_error),
2277 nan_eq_nan_(nan_eq_nan) {}
2279 virtual bool MatchAndExplain(Tuple args,
2280 MatchResultListener* listener)
const {
2281 if (max_abs_error_ == -1) {
2282 FloatingEqMatcher<FloatType> fm(::testing::get<0>(args), nan_eq_nan_);
2283 return static_cast<Matcher<FloatType>
>(fm).MatchAndExplain(
2284 ::testing::get<1>(args), listener);
2286 FloatingEqMatcher<FloatType> fm(::testing::get<0>(args), nan_eq_nan_,
2288 return static_cast<Matcher<FloatType>
>(fm).MatchAndExplain(
2289 ::testing::get<1>(args), listener);
2292 virtual void DescribeTo(::std::ostream*
os)
const {
2293 *
os <<
"are " << GetDesc;
2295 virtual void DescribeNegationTo(::std::ostream*
os)
const {
2296 *
os <<
"aren't " << GetDesc;
2300 FloatType max_abs_error_;
2301 const bool nan_eq_nan_;
2304 void Init(FloatType max_abs_error_val,
bool nan_eq_nan_val) {
2305 max_abs_error_ = max_abs_error_val;
2306 nan_eq_nan_ = nan_eq_nan_val;
2308 FloatType max_abs_error_;
2314template <
typename InnerMatcher>
2327 template <
typename Po
inter>
2335 template <
typename Po
inter>
2341 explicit Impl(
const InnerMatcher& matcher)
2342 : matcher_(MatcherCast<const Pointee&>(matcher)) {}
2344 virtual void DescribeTo(::std::ostream*
os)
const {
2345 *
os <<
"points to a value that ";
2349 virtual void DescribeNegationTo(::std::ostream*
os)
const {
2350 *
os <<
"does not point to a value that ";
2355 MatchResultListener* listener)
const {
2359 *listener <<
"which points to ";
2364 const Matcher<const Pointee&> matcher_;
2369 const InnerMatcher matcher_;
2381template <
typename To>
2382class WhenDynamicCastToMatcherBase {
2384 explicit WhenDynamicCastToMatcherBase(
const Matcher<To>& matcher)
2385 : matcher_(matcher) {}
2387 void DescribeTo(::std::ostream*
os)
const {
2388 GetCastTypeDescription(
os);
2389 matcher_.DescribeTo(
os);
2392 void DescribeNegationTo(::std::ostream*
os)
const {
2393 GetCastTypeDescription(
os);
2394 matcher_.DescribeNegationTo(
os);
2398 const Matcher<To> matcher_;
2400 static std::string GetToName() {
2401 return GetTypeName<To>();
2405 static void GetCastTypeDescription(::std::ostream*
os) {
2406 *
os <<
"when dynamic_cast to " << GetToName() <<
", ";
2414template <
typename To>
2415class WhenDynamicCastToMatcher :
public WhenDynamicCastToMatcherBase<To> {
2417 explicit WhenDynamicCastToMatcher(
const Matcher<To>& matcher)
2418 : WhenDynamicCastToMatcherBase<To>(matcher) {}
2420 template <
typename From>
2421 bool MatchAndExplain(From from, MatchResultListener* listener)
const {
2423 To to =
dynamic_cast<To
>(from);
2430template <
typename To>
2431class WhenDynamicCastToMatcher<To&> :
public WhenDynamicCastToMatcherBase<To&> {
2433 explicit WhenDynamicCastToMatcher(
const Matcher<To&>& matcher)
2434 : WhenDynamicCastToMatcherBase<To&>(matcher) {}
2436 template <
typename From>
2437 bool MatchAndExplain(From& from, MatchResultListener* listener)
const {
2439 To* to =
dynamic_cast<To*
>(&from);
2441 *listener <<
"which cannot be dynamic_cast to " << this->GetToName();
2451template <
typename Class,
typename FieldType>
2456 : field_(
field), matcher_(matcher), whose_field_(
"whose given field ") {}
2462 whose_field_(
"whose field `" + field_name +
"` ") {}
2465 *
os <<
"is an object " << whose_field_;
2470 *
os <<
"is an object " << whose_field_;
2474 template <
typename T>
2476 return MatchAndExplainImpl(
2477 typename ::testing::internal::
2486 bool MatchAndExplainImpl(
false_type ,
const Class& obj,
2488 *listener << whose_field_ <<
"is ";
2492 bool MatchAndExplainImpl(
true_type ,
const Class*
p,
2497 *listener <<
"which points to an object ";
2501 return MatchAndExplainImpl(
false_type(), *
p, listener);
2504 const FieldType Class::*field_;
2505 const Matcher<const FieldType&> matcher_;
2509 const std::string whose_field_;
2519template <
typename Class,
typename PropertyType,
typename Property>
2529 : property_(property),
2531 whose_property_(
"whose given property ") {}
2535 : property_(property),
2537 whose_property_(
"whose property `" + property_name +
"` ") {}
2540 *
os <<
"is an object " << whose_property_;
2545 *
os <<
"is an object " << whose_property_;
2549 template <
typename T>
2551 return MatchAndExplainImpl(
2552 typename ::testing::internal::
2561 bool MatchAndExplainImpl(
false_type ,
const Class& obj,
2563 *listener << whose_property_ <<
"is ";
2566#if defined(_PREFAST_ ) && _MSC_VER == 1800
2572 RefToConstProperty result = (obj.*property_)();
2577 bool MatchAndExplainImpl(
true_type ,
const Class*
p,
2582 *listener <<
"which points to an object ";
2586 return MatchAndExplainImpl(
false_type(), *
p, listener);
2590 const Matcher<RefToConstProperty> matcher_;
2594 const std::string whose_property_;
2603template <
typename Functor>
2609 template <
typename T>
2614template <
typename ArgType,
typename ResType>
2617 typedef ResType(*StorageType)(ArgType);
2621 <<
"NULL function pointer is passed into ResultOf().";
2623 template <
typename T>
2631template <
typename Callable>
2637 : callable_(callable), matcher_(matcher) {
2641 template <
typename T>
2643 return Matcher<T>(
new Impl<T>(callable_, matcher_));
2649 template <
typename T>
2653 : callable_(callable), matcher_(matcher) {}
2655 virtual void DescribeTo(::std::ostream*
os)
const {
2656 *
os <<
"is mapped by the given callable to a value that ";
2660 virtual void DescribeNegationTo(::std::ostream*
os)
const {
2661 *
os <<
"is mapped by the given callable to a value that ";
2665 virtual bool MatchAndExplain(
T obj, MatchResultListener* listener)
const {
2666 *listener <<
"which is mapped by the given callable to ";
2670 CallableTraits<Callable>::template
Invoke<T>(callable_, obj);
2680 mutable CallableStorageType callable_;
2681 const Matcher<ResultType> matcher_;
2686 const CallableStorageType callable_;
2687 const Matcher<ResultType> matcher_;
2693template <
typename SizeMatcher>
2697 : size_matcher_(size_matcher) {
2700 template <
typename Container>
2705 template <
typename Container>
2710 typedef typename ContainerView::type::size_type
SizeType;
2711 explicit Impl(
const SizeMatcher& size_matcher)
2712 : size_matcher_(MatcherCast<
SizeType>(size_matcher)) {}
2727 const bool result = size_matcher_.
MatchAndExplain(size, &size_listener);
2729 <<
"whose size " << size << (result ?
" matches" :
" doesn't match");
2740 const SizeMatcher size_matcher_;
2746template <
typename DistanceMatcher>
2750 : distance_matcher_(distance_matcher) {}
2752 template <
typename Container>
2757 template <
typename Container>
2762 typedef typename std::iterator_traits<
2763 typename ContainerView::type::const_iterator>::difference_type
2765 explicit Impl(
const DistanceMatcher& distance_matcher)
2766 : distance_matcher_(MatcherCast<
DistanceType>(distance_matcher)) {}
2769 *
os <<
"distance between begin() and end() ";
2773 *
os <<
"distance between begin() and end() ";
2779#if GTEST_HAS_STD_BEGIN_AND_END_
2782 DistanceType distance = std::distance(begin(container), end(container));
2784 DistanceType distance = std::distance(container.begin(), container.end());
2789 *listener <<
"whose distance between begin() and end() " << distance
2790 << (result ?
" matches" :
" doesn't match");
2801 const DistanceMatcher distance_matcher_;
2815template <
typename Container>
2825 : expected_(
View::Copy(expected)) {
2837 *
os <<
"does not equal ";
2841 template <
typename LhsContainer>
2848 typedef typename LhsView::type LhsStlContainer;
2850 if (lhs_stl_container == expected_)
2853 ::std::ostream*
const os = listener->
stream();
2856 bool printed_header =
false;
2857 for (
typename LhsStlContainer::const_iterator it =
2858 lhs_stl_container.begin();
2859 it != lhs_stl_container.end(); ++it) {
2862 if (printed_header) {
2865 *
os <<
"which has these unexpected elements: ";
2866 printed_header =
true;
2873 bool printed_header2 =
false;
2874 for (
typename StlContainer::const_iterator it = expected_.begin();
2875 it != expected_.end(); ++it) {
2877 lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
2878 lhs_stl_container.end()) {
2879 if (printed_header2) {
2882 *
os << (printed_header ?
",\nand" :
"which")
2883 <<
" doesn't have these expected elements: ";
2884 printed_header2 =
true;
2902 template <
typename T,
typename U>
2907template <
typename Comparator,
typename ContainerMatcher>
2911 const ContainerMatcher& matcher)
2912 : comparator_(comparator), matcher_(matcher) {}
2914 template <
typename LhsContainer>
2919 template <
typename LhsContainer>
2931 Impl(
const Comparator& comparator,
const ContainerMatcher& matcher)
2932 : comparator_(comparator), matcher_(matcher) {}
2935 *
os <<
"(when sorted) ";
2940 *
os <<
"(when sorted) ";
2947 ::std::vector<LhsValue> sorted_container(lhs_stl_container.begin(),
2948 lhs_stl_container.end());
2950 sorted_container.begin(), sorted_container.end(), comparator_);
2955 return matcher_.
Matches(sorted_container);
2958 *listener <<
"which is ";
2960 *listener <<
" when sorted";
2970 const Comparator comparator_;
2977 const Comparator comparator_;
2978 const ContainerMatcher matcher_;
2987template <
typename TupleMatcher,
typename RhsContainer>
2991 use_UnorderedPointwise_with_hash_tables);
3001 : tuple_matcher_(tuple_matcher), rhs_(
RhsView::Copy(rhs)) {
3008 template <
typename LhsContainer>
3012 use_UnorderedPointwise_with_hash_tables);
3017 template <
typename LhsContainer>
3037 *
os <<
"contains " << rhs_.size()
3038 <<
" values, where each value and its corresponding value in ";
3044 *
os <<
"doesn't contain exactly " << rhs_.size()
3045 <<
" values, or contains a value x at some index i"
3046 <<
" where x and the i-th value of ";
3055 const size_t actual_size = lhs_stl_container.size();
3056 if (actual_size != rhs_.size()) {
3057 *listener <<
"which contains " << actual_size <<
" values";
3061 typename LhsStlContainer::const_iterator left = lhs_stl_container.begin();
3062 typename RhsStlContainer::const_iterator right = rhs_.begin();
3063 for (
size_t i = 0; i != actual_size; ++i, ++left, ++right) {
3073 *listener <<
"where the value pair (";
3077 *listener <<
") at index #" << i <<
" don't match";
3082 if (!mono_tuple_matcher_.
Matches(
3100 const TupleMatcher tuple_matcher_;
3107template <
typename Container>
3114 typedef typename StlContainer::value_type
Element;
3116 template <
typename InnerMatcher>
3125 Container container,
3129 for (
typename StlContainer::const_iterator it = stl_container.begin();
3130 it != stl_container.end(); ++it, ++i) {
3134 if (matches != all_elements_should_match) {
3135 *listener <<
"whose element #" << i
3136 << (matches ?
" matches" :
" doesn't match");
3138 return !all_elements_should_match;
3141 return all_elements_should_match;
3152template <
typename Container>
3155 template <
typename InnerMatcher>
3161 *
os <<
"contains at least one element that ";
3166 *
os <<
"doesn't contain any element that ";
3181template <
typename Container>
3184 template <
typename InnerMatcher>
3190 *
os <<
"only contains elements that ";
3195 *
os <<
"contains some element that ";
3209template <
typename M>
3214 template <
typename Container>
3220 const M inner_matcher_;
3226template <
typename M>
3231 template <
typename Container>
3237 const M inner_matcher_;
3245namespace pair_getters {
3248template <
typename T>
3252template <
typename T>
3257template <
typename T>
3261template <
typename T>
3266template <
typename T>
3270template <
typename T>
3275template <
typename T>
3279template <
typename T>
3290template <
typename PairType>
3296 template <
typename InnerMatcher>
3308 const std::string explanation = inner_listener.
str();
3309 if (explanation !=
"") {
3310 *listener <<
"whose first field is a value " << explanation;
3317 *
os <<
"has a key that ";
3323 *
os <<
"doesn't have a key that ";
3334template <
typename M>
3339 template <
typename PairType>
3345 const M matcher_for_key_;
3352template <
typename PairType>
3359 template <
typename FirstMatcher,
typename SecondMatcher>
3369 *
os <<
"has a first field that ";
3371 *
os <<
", and has a second field that ";
3377 *
os <<
"has a first field that ";
3379 *
os <<
", or has a second field that ";
3395 &first_inner_listener)) {
3396 *listener <<
"whose first field does not match";
3402 &second_inner_listener)) {
3403 *listener <<
"whose second field does not match";
3407 ExplainSuccess(first_inner_listener.
str(), second_inner_listener.
str(),
3413 void ExplainSuccess(
const std::string& first_explanation,
3414 const std::string& second_explanation,
3416 *listener <<
"whose both fields match";
3417 if (first_explanation !=
"") {
3418 *listener <<
", where the first field is a value " << first_explanation;
3420 if (second_explanation !=
"") {
3422 if (first_explanation !=
"") {
3423 *listener <<
"and ";
3425 *listener <<
"where ";
3427 *listener <<
"the second field is a value " << second_explanation;
3431 const Matcher<const FirstType&> first_matcher_;
3432 const Matcher<const SecondType&> second_matcher_;
3438template <
typename FirstMatcher,
typename SecondMatcher>
3442 : first_matcher_(first_matcher), second_matcher_(second_matcher) {}
3444 template <
typename PairType>
3448 first_matcher_, second_matcher_));
3452 const FirstMatcher first_matcher_;
3453 const SecondMatcher second_matcher_;
3459template <
typename Container>
3466 typedef typename StlContainer::value_type
Element;
3470 template <
typename InputIter>
3472 while (first != last) {
3473 matchers_.push_back(MatcherCast<const Element&>(*first++));
3481 }
else if (count() == 1) {
3482 *
os <<
"has 1 element that ";
3483 matchers_[0].DescribeTo(
os);
3485 *
os <<
"has " << Elements(count()) <<
" where\n";
3486 for (
size_t i = 0; i != count(); ++i) {
3487 *
os <<
"element #" << i <<
" ";
3488 matchers_[i].DescribeTo(
os);
3489 if (i + 1 < count()) {
3499 *
os <<
"isn't empty";
3503 *
os <<
"doesn't have " << Elements(count()) <<
", or\n";
3504 for (
size_t i = 0; i != count(); ++i) {
3505 *
os <<
"element #" << i <<
" ";
3506 matchers_[i].DescribeNegationTo(
os);
3507 if (i + 1 < count()) {
3518 const bool listener_interested = listener->
IsInterested();
3521 ::std::vector<std::string> explanations(count());
3523 typename StlContainer::const_iterator it = stl_container.begin();
3524 size_t exam_pos = 0;
3525 bool mismatch_found =
false;
3530 for (; it != stl_container.end() && exam_pos != count(); ++it, ++exam_pos) {
3532 if (listener_interested) {
3534 match = matchers_[exam_pos].MatchAndExplain(*it, &
s);
3535 explanations[exam_pos] =
s.str();
3537 match = matchers_[exam_pos].Matches(*it);
3541 mismatch_found =
true;
3550 size_t actual_count = exam_pos;
3551 for (; it != stl_container.end(); ++it) {
3555 if (actual_count != count()) {
3560 if (listener_interested && (actual_count != 0)) {
3561 *listener <<
"which has " << Elements(actual_count);
3566 if (mismatch_found) {
3568 if (listener_interested) {
3569 *listener <<
"whose element #" << exam_pos <<
" doesn't match";
3577 if (listener_interested) {
3578 bool reason_printed =
false;
3579 for (
size_t i = 0; i != count(); ++i) {
3580 const std::string&
s = explanations[i];
3582 if (reason_printed) {
3583 *listener <<
",\nand ";
3585 *listener <<
"whose element #" << i <<
" matches, " <<
s;
3586 reason_printed =
true;
3594 static Message Elements(
size_t count) {
3598 size_t count()
const {
return matchers_.size(); }
3600 ::std::vector<Matcher<const Element&> > matchers_;
3612 : num_elements_(num_elements),
3613 num_matchers_(num_matchers),
3614 matched_(num_elements_* num_matchers_, 0) {
3620 return matched_[SpaceIndex(ilhs, irhs)] == 1;
3623 matched_[SpaceIndex(ilhs, irhs)] = b ? 1 : 0;
3633 std::string DebugString()
const;
3636 size_t SpaceIndex(
size_t ilhs,
size_t irhs)
const {
3637 return ilhs * num_matchers_ + irhs;
3640 size_t num_elements_;
3641 size_t num_matchers_;
3646 ::std::vector<char> matched_;
3672 : match_flags_(matcher_flags) {}
3680 void DescribeToImpl(::std::ostream*
os)
const;
3683 void DescribeNegationToImpl(::std::ostream*
os)
const;
3685 bool VerifyMatchMatrix(const ::std::vector<std::string>& element_printouts,
3693 return matcher_describers_;
3697 return Message() << n <<
" element" << (n == 1 ?
"" :
"s");
3704 MatcherDescriberVec matcher_describers_;
3711template <
typename Container>
3721 typedef typename StlContainer::value_type
Element;
3723 template <
typename InputIter>
3725 InputIter first, InputIter last)
3727 for (; first != last; ++first) {
3728 matchers_.push_back(MatcherCast<const Element&>(*first));
3746 ::std::vector<std::string> element_printouts;
3748 AnalyzeElements(stl_container.begin(), stl_container.end(),
3749 &element_printouts, listener);
3773 template <
typename ElementIter>
3774 MatchMatrix AnalyzeElements(ElementIter elem_first, ElementIter elem_last,
3775 ::std::vector<std::string>* element_printouts,
3777 element_printouts->clear();
3778 ::std::vector<char> did_match;
3779 size_t num_elements = 0;
3780 for (; elem_first != elem_last; ++num_elements, ++elem_first) {
3784 for (
size_t irhs = 0; irhs != matchers_.size(); ++irhs) {
3785 did_match.push_back(
Matches(matchers_[irhs])(*elem_first));
3789 MatchMatrix matrix(num_elements, matchers_.size());
3790 ::std::vector<char>::const_iterator did_match_iter = did_match.begin();
3791 for (
size_t ilhs = 0; ilhs != num_elements; ++ilhs) {
3792 for (
size_t irhs = 0; irhs != matchers_.size(); ++irhs) {
3793 matrix.SetEdge(ilhs, irhs, *did_match_iter++ != 0);
3799 ::std::vector<Matcher<const Element&> > matchers_;
3806template <
typename Target>
3808 template <
typename Arg>
3815template <
typename MatcherTuple>
3819 : matchers_(args) {}
3821 template <
typename Container>
3825 typedef typename View::value_type Element;
3826 typedef ::std::vector<Matcher<const Element&> > MatcherVec;
3827 MatcherVec matchers;
3828 matchers.reserve(::testing::tuple_size<MatcherTuple>::value);
3830 ::std::back_inserter(matchers));
3841template <
typename MatcherTuple>
3846 template <
typename Container>
3850 ::testing::tuple_size<MatcherTuple>::value < 2,
3851 use_UnorderedElementsAre_with_hash_tables);
3855 typedef typename View::value_type Element;
3856 typedef ::std::vector<Matcher<const Element&> > MatcherVec;
3857 MatcherVec matchers;
3858 matchers.reserve(::testing::tuple_size<MatcherTuple>::value);
3860 ::std::back_inserter(matchers));
3862 matchers.begin(), matchers.end()));
3871template <
typename T>
3874 template <
typename Iter>
3876 Iter first, Iter last)
3877 : match_flags_(match_flags), matchers_(first, last) {}
3879 template <
typename Container>
3882 match_flags_, matchers_.begin(), matchers_.end()));
3887 ::std::vector<T> matchers_;
3893template <
typename T>
3896 template <
typename Iter>
3899 template <
typename Container>
3903 use_UnorderedElementsAreArray_with_hash_tables);
3906 matchers_.begin(), matchers_.end()));
3910 const ::std::vector<T> matchers_;
3924template <
typename Tuple2Matcher,
typename Second>
3928 : tuple2_matcher_(tm), second_value_(second) {}
3930 template <
typename T>
3932 return MakeMatcher(
new Impl<T>(tuple2_matcher_, second_value_));
3944 GTEST_LOG_(FATAL) <<
"BoundSecondMatcher should never be assigned.";
3948 template <
typename T>
3951 typedef ::testing::tuple<T, Second> ArgTuple;
3953 Impl(
const Tuple2Matcher& tm,
const Second& second)
3955 second_value_(second) {}
3957 virtual void DescribeTo(::std::ostream*
os)
const {
3964 virtual bool MatchAndExplain(
T x, MatchResultListener* listener)
const {
3965 return mono_tuple2_matcher_.
MatchAndExplain(ArgTuple(x, second_value_),
3970 const Matcher<const ArgTuple&> mono_tuple2_matcher_;
3971 const Second second_value_;
3976 const Tuple2Matcher tuple2_matcher_;
3977 const Second second_value_;
3984template <
typename Tuple2Matcher,
typename Second>
3986 const Tuple2Matcher& tm,
const Second& second) {
3996 const char* matcher_name,
4000template <
typename ValueMatcher>
4004 : value_matcher_(value_matcher) {}
4006 template <
typename Optional>
4011 template <
typename Optional>
4016 explicit Impl(
const ValueMatcher& value_matcher)
4017 : value_matcher_(MatcherCast<
ValueType>(value_matcher)) {}
4032 *listener <<
"which is not engaged";
4039 << (match ?
" matches" :
" doesn't match");
4050 const ValueMatcher value_matcher_;
4054namespace variant_matcher {
4056template <
typename T>
4058template <
typename T>
4062template <
typename T>
4066 : matcher_(
internal::move(matcher)) {}
4068 template <
typename Variant>
4076 *listener <<
"whose value is not of type '" << GetTypeName() <<
"'";
4084 << (match ?
" matches" :
" doesn't match");
4090 *
os <<
"is a variant<> with value of type '" << GetTypeName()
4091 <<
"' and the value ";
4096 *
os <<
"is a variant<> with value of type other than '" << GetTypeName()
4097 <<
"' or the value ";
4102 static std::string GetTypeName() {
4107 return "the element type";
4110 const ::testing::Matcher<const T&> matcher_;
4115namespace any_cast_matcher {
4118template <
typename T>
4122template <
typename T>
4126 : matcher_(matcher) {}
4128 template <
typename AnyType>
4133 return ptr != NULL && matcher_.
Matches(*ptr);
4138 *listener <<
"whose value is not of type '" << GetTypeName() <<
"'";
4145 << (match ?
" matches" :
" doesn't match");
4151 *
os <<
"is an 'any' type with value of type '" << GetTypeName()
4152 <<
"' and the value ";
4157 *
os <<
"is an 'any' type with value of type other than '" << GetTypeName()
4158 <<
"' or the value ";
4163 static std::string GetTypeName() {
4168 return "the element type";
4171 const ::testing::Matcher<const T&> matcher_;
4192template <
typename Iter>
4193inline internal::ElementsAreArrayMatcher<
4194 typename ::std::iterator_traits<Iter>::value_type>
4196 typedef typename ::std::iterator_traits<Iter>::value_type
T;
4200template <
typename T>
4206template <
typename T,
size_t N>
4208 const T (&array)[
N]) {
4212template <
typename Container>
4213inline internal::ElementsAreArrayMatcher<typename Container::value_type>
4218#if GTEST_HAS_STD_INITIALIZER_LIST_
4219template <
typename T>
4220inline internal::ElementsAreArrayMatcher<T>
4239template <
typename Iter>
4240inline internal::UnorderedElementsAreArrayMatcher<
4241 typename ::std::iterator_traits<Iter>::value_type>
4243 typedef typename ::std::iterator_traits<Iter>::value_type
T;
4248template <
typename T>
4249inline internal::UnorderedElementsAreArrayMatcher<T>
4254template <
typename T,
size_t N>
4255inline internal::UnorderedElementsAreArrayMatcher<T>
4260template <
typename Container>
4261inline internal::UnorderedElementsAreArrayMatcher<
4262 typename Container::value_type>
4267#if GTEST_HAS_STD_INITIALIZER_LIST_
4268template <
typename T>
4269inline internal::UnorderedElementsAreArrayMatcher<T>
4286template <
typename T>
4292template <
typename T>
4298template <
typename T>
4303template <
typename T>
4306template <
typename T,
typename M>
4326template <
typename Lhs,
typename Rhs>
4330template <
typename Rhs>
4336template <
typename Rhs>
4342template <
typename Rhs>
4348template <
typename Rhs>
4354template <
typename Rhs>
4373template <
typename T>
4394 double rhs,
double max_abs_error) {
4402 double rhs,
double max_abs_error) {
4422 float rhs,
float max_abs_error) {
4430 float rhs,
float max_abs_error) {
4436template <
typename InnerMatcher>
4438 const InnerMatcher& inner_matcher) {
4449template <
typename To>
4450inline PolymorphicMatcher<internal::WhenDynamicCastToMatcher<To> >
4451WhenDynamicCastTo(
const Matcher<To>& inner_matcher) {
4453 internal::WhenDynamicCastToMatcher<To>(inner_matcher));
4461template <
typename Class,
typename FieldType,
typename FieldMatcher>
4462inline PolymorphicMatcher<
4464 FieldType Class::*
field,
const FieldMatcher& matcher) {
4467 field, MatcherCast<const FieldType&>(matcher)));
4476template <
typename Class,
typename FieldType,
typename FieldMatcher>
4478 const std::string& field_name, FieldType Class::*
field,
4479 const FieldMatcher& matcher) {
4481 field_name,
field, MatcherCast<const FieldType&>(matcher)));
4488template <
typename Class,
typename PropertyType,
typename PropertyMatcher>
4489inline PolymorphicMatcher<internal::PropertyMatcher<
4490 Class, PropertyType, PropertyType (Class::*)()
const> >
4492 const PropertyMatcher& matcher) {
4495 PropertyType (Class::*)()
const>(
4506template <
typename Class,
typename PropertyType,
typename PropertyMatcher>
4507inline PolymorphicMatcher<internal::PropertyMatcher<
4508 Class, PropertyType, PropertyType (Class::*)()
const> >
4510 PropertyType (Class::*property)()
const,
4511 const PropertyMatcher& matcher) {
4514 PropertyType (Class::*)()
const>(
4515 property_name, property,
4521template <
typename Class,
typename PropertyType,
typename PropertyMatcher>
4522inline PolymorphicMatcher<internal::PropertyMatcher<
4523 Class, PropertyType, PropertyType (Class::*)()
const &> >
4524Property(PropertyType (Class::*property)()
const &,
4525 const PropertyMatcher& matcher) {
4527 internal::PropertyMatcher<Class, PropertyType,
4528 PropertyType (Class::*)()
const &>(
4548template <
typename Callable,
typename ResultOfMatcher>
4550 Callable callable,
const ResultOfMatcher& matcher) {
4565 const std::string& str) {
4572 const std::string& str) {
4579 const std::string& str) {
4586 const std::string& str) {
4594 const std::string& substring) {
4601 const std::string& prefix) {
4608 const std::string& suffix) {
4619 const std::string& regex) {
4630 const std::string& regex) {
4634#if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
4638inline PolymorphicMatcher<internal::StrEqualityMatcher<std::wstring> >
StrEq(
4639 const std::wstring& str) {
4641 internal::StrEqualityMatcher<std::wstring>(str,
true,
true));
4645inline PolymorphicMatcher<internal::StrEqualityMatcher<std::wstring> >
StrNe(
4646 const std::wstring& str) {
4648 internal::StrEqualityMatcher<std::wstring>(str,
false,
true));
4652inline PolymorphicMatcher<internal::StrEqualityMatcher<std::wstring> >
4655 internal::StrEqualityMatcher<std::wstring>(str,
true,
false));
4659inline PolymorphicMatcher<internal::StrEqualityMatcher<std::wstring> >
4662 internal::StrEqualityMatcher<std::wstring>(str,
false,
false));
4667inline PolymorphicMatcher<internal::HasSubstrMatcher<std::wstring> >
HasSubstr(
4668 const std::wstring& substring) {
4670 internal::HasSubstrMatcher<std::wstring>(substring));
4674inline PolymorphicMatcher<internal::StartsWithMatcher<std::wstring> >
4677 internal::StartsWithMatcher<std::wstring>(prefix));
4681inline PolymorphicMatcher<internal::EndsWithMatcher<std::wstring> >
EndsWith(
4682 const std::wstring& suffix) {
4684 internal::EndsWithMatcher<std::wstring>(suffix));
4753 float max_abs_error) {
4761 double max_abs_error) {
4767template <
typename InnerMatcher>
4775template <
typename Predicate>
4776inline PolymorphicMatcher<internal::TrulyMatcher<Predicate> >
4787template <
typename SizeMatcher>
4788inline internal::SizeIsMatcher<SizeMatcher>
4798template <
typename DistanceMatcher>
4799inline internal::BeginEndDistanceIsMatcher<DistanceMatcher>
4808template <
typename Container>
4809inline PolymorphicMatcher<internal::ContainerEqMatcher<
4821template <
typename Comparator,
typename ContainerMatcher>
4822inline internal::WhenSortedByMatcher<Comparator, ContainerMatcher>
4824 const ContainerMatcher& container_matcher) {
4826 comparator, container_matcher);
4831template <
typename ContainerMatcher>
4832inline internal::WhenSortedByMatcher<internal::LessComparator, ContainerMatcher>
4845template <
typename TupleMatcher,
typename Container>
4846inline internal::PointwiseMatcher<TupleMatcher,
4848Pointwise(
const TupleMatcher& tuple_matcher,
const Container& rhs) {
4854 tuple_matcher, rhs);
4857#if GTEST_HAS_STD_INITIALIZER_LIST_
4860template <
typename TupleMatcher,
typename T>
4861inline internal::PointwiseMatcher<TupleMatcher, std::vector<T> >
Pointwise(
4862 const TupleMatcher& tuple_matcher, std::initializer_list<T> rhs) {
4863 return Pointwise(tuple_matcher, std::vector<T>(rhs));
4879template <
typename Tuple2Matcher,
typename RhsContainer>
4880inline internal::UnorderedElementsAreArrayMatcher<
4881 typename internal::BoundSecondMatcher<
4883 RhsContainer)>::type::value_type> >
4885 const RhsContainer& rhs_container) {
4894 typedef typename RhsView::type RhsStlContainer;
4895 typedef typename RhsStlContainer::value_type Second;
4896 const RhsStlContainer& rhs_stl_container =
4897 RhsView::ConstReference(rhs_container);
4900 ::std::vector<internal::BoundSecondMatcher<Tuple2Matcher, Second> > matchers;
4901 for (
typename RhsStlContainer::const_iterator it = rhs_stl_container.begin();
4902 it != rhs_stl_container.end(); ++it) {
4911#if GTEST_HAS_STD_INITIALIZER_LIST_
4914template <
typename Tuple2Matcher,
typename T>
4915inline internal::UnorderedElementsAreArrayMatcher<
4916 typename internal::BoundSecondMatcher<Tuple2Matcher, T> >
4918 std::initializer_list<T> rhs) {
4942template <
typename M>
4974template <
typename Iter>
4975inline internal::UnorderedElementsAreArrayMatcher<
4976 typename ::std::iterator_traits<Iter>::value_type>
4978 typedef typename ::std::iterator_traits<Iter>::value_type
T;
4983template <
typename T>
4989template <
typename T,
size_t N>
4991 const T (&array)[
N]) {
4995template <
typename Container>
4996inline internal::UnorderedElementsAreArrayMatcher<
4997 typename Container::value_type>
4999 return IsSupersetOf(container.begin(), container.end());
5002#if GTEST_HAS_STD_INITIALIZER_LIST_
5003template <
typename T>
5004inline internal::UnorderedElementsAreArrayMatcher<T>
IsSupersetOf(
5005 ::std::initializer_list<T> xs) {
5033template <
typename Iter>
5034inline internal::UnorderedElementsAreArrayMatcher<
5035 typename ::std::iterator_traits<Iter>::value_type>
5037 typedef typename ::std::iterator_traits<Iter>::value_type
T;
5042template <
typename T>
5048template <
typename T,
size_t N>
5050 const T (&array)[
N]) {
5054template <
typename Container>
5055inline internal::UnorderedElementsAreArrayMatcher<
5056 typename Container::value_type>
5058 return IsSubsetOf(container.begin(), container.end());
5061#if GTEST_HAS_STD_INITIALIZER_LIST_
5062template <
typename T>
5063inline internal::UnorderedElementsAreArrayMatcher<T>
IsSubsetOf(
5064 ::std::initializer_list<T> xs) {
5096template <
typename M>
5104template <
typename M>
5114template <
typename FirstMatcher,
typename SecondMatcher>
5115inline internal::PairMatcher<FirstMatcher, SecondMatcher>
5116Pair(FirstMatcher first_matcher, SecondMatcher second_matcher) {
5118 first_matcher, second_matcher);
5123template <
typename M>
5129template <
typename T,
typename M>
5136template <
typename T,
typename M>
5152template <
typename T,
typename M>
5154 ::std::stringstream ss;
5157 monomorphic_matcher.DescribeNegationTo(&ss);
5159 monomorphic_matcher.DescribeTo(&ss);
5167template <
typename... Args>
5168internal::AllOfMatcher<Args...>
AllOf(
const Args&... matchers) {
5169 return internal::AllOfMatcher<Args...>(matchers...);
5172template <
typename... Args>
5173internal::AnyOfMatcher<Args...>
AnyOf(
const Args&... matchers) {
5174 return internal::AnyOfMatcher<Args...>(matchers...);
5177template <
typename... Args>
5178internal::ElementsAreMatcher<tuple<typename std::decay<const Args&>::type...>>
5180 return internal::ElementsAreMatcher<
5181 tuple<typename std::decay<const Args&>::type...>>(
5182 make_tuple(matchers...));
5185template <
typename... Args>
5186internal::UnorderedElementsAreMatcher<
5187 tuple<typename std::decay<const Args&>::type...>>
5189 return internal::UnorderedElementsAreMatcher<
5190 tuple<typename std::decay<const Args&>::type...>>(
5191 make_tuple(matchers...));
5203template <
typename InnerMatcher>
5204inline InnerMatcher
AllArgs(
const InnerMatcher& matcher) {
return matcher; }
5214template <
typename ValueMatcher>
5216 const ValueMatcher& value_matcher) {
5221template <
typename T>
5232template <
typename T>
5243#define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\
5244 ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
5245#define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\
5246 ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
Unary< NodeType::optional > Optional
Represents a JSON Pointer. Use Pointer for UTF8 encoding and default allocator.
MatchResultListener(::std::ostream *os)
::std::ostream * stream()
MatchResultListener & operator<<(const T &x)
virtual ~MatchResultListener()=0
bool IsInterested() const
Matcher(const MatcherInterface< const std::string & > *impl)
Matcher(const std::string &s)
Matcher(const MatcherInterface< const std::string & > *impl)
Matcher(const MatcherInterface< std::string > *impl)
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeTo(::std::ostream *os) const =0
virtual ~MatcherDescriberInterface()
Matcher(const MatcherInterface< U > *impl, typename internal::EnableIf<!internal::IsSame< U, GTEST_REFERENCE_TO_CONST_(U)>::value >::type *=NULL)
Matcher(const MatcherInterface< GTEST_REFERENCE_TO_CONST_(T)> *impl)
virtual bool MatchAndExplain(T x, MatchResultListener *listener) const =0
PolymorphicMatcher(const Impl &an_impl)
const Impl & impl() const
static Matcher< T > Cast(const M &polymorphic_matcher_or_value)
static Matcher< T > Cast(const Matcher< U > &matcher)
StringMatchResultListener()
virtual void DescribeTo(::std::ostream *os) const
virtual bool MatchAndExplain(GTEST_REFERENCE_TO_CONST_(T) x, MatchResultListener *listener) const
virtual void DescribeNegationTo(::std::ostream *os) const
AllOfMatcherImpl(std::vector< Matcher< T > > matchers)
virtual void DescribeTo(::std::ostream *os) const
virtual bool MatchAndExplain(GTEST_REFERENCE_TO_CONST_(T), MatchResultListener *) const
virtual void DescribeNegationTo(::std::ostream *os) const
AnyOfMatcherImpl(std::vector< Matcher< T > > matchers)
virtual void DescribeTo(::std::ostream *os) const
virtual bool MatchAndExplain(GTEST_REFERENCE_TO_CONST_(T) x, MatchResultListener *listener) const
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeNegationTo(::std::ostream *os) const
std::iterator_traits< typenameContainerView::type::const_iterator >::difference_type DistanceType
virtual void DescribeTo(::std::ostream *os) const
Impl(const DistanceMatcher &distance_matcher)
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
internal::StlContainerView< GTEST_REMOVE_REFERENCE_AND_CONST_(Container)> ContainerView
BeginEndDistanceIsMatcher(const DistanceMatcher &distance_matcher)
BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
void operator=(const BoundSecondMatcher &)
BoundSecondMatcher(const Tuple2Matcher &tm, const Second &second)
ComparisonBase(const Rhs &rhs)
internal::StlContainerView< Container > View
View::const_reference StlContainerReference
void DescribeTo(::std::ostream *os) const
bool MatchAndExplain(const LhsContainer &lhs, MatchResultListener *listener) const
void DescribeNegationTo(::std::ostream *os) const
ContainerEqMatcher(const Container &expected)
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
ContainsMatcherImpl(InnerMatcher inner_matcher)
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeTo(::std::ostream *os) const
DummyMatchResultListener()
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeTo(::std::ostream *os) const
EachMatcherImpl(InnerMatcher inner_matcher)
EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
ElementsAreArrayMatcher(Iter first, Iter last)
ElementsAreMatcher(const MatcherTuple &args)
View::const_reference StlContainerReference
StlContainer::value_type Element
internal::StlContainerView< RawContainer > View
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
virtual void DescribeTo(::std::ostream *os) const
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer
virtual void DescribeNegationTo(::std::ostream *os) const
ElementsAreMatcherImpl(InputIter first, InputIter last)
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
EndsWithMatcher(const StringType &suffix)
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
void DescribeTo(::std::ostream *os) const
void DescribeNegationTo(::std::ostream *os) const
static const char * Desc()
static const char * NegatedDesc()
EqMatcher(const Rhs &rhs)
static const char * Desc()
FieldMatcher(const std::string &field_name, FieldType Class::*field, const Matcher< const FieldType & > &matcher)
void DescribeNegationTo(::std::ostream *os) const
bool MatchAndExplain(const T &value, MatchResultListener *listener) const
FieldMatcher(FieldType Class::*field, const Matcher< const FieldType & > &matcher)
void DescribeTo(::std::ostream *os) const
FloatingEq2Matcher(bool nan_eq_nan)
FloatingEq2Matcher(FloatType max_abs_error, bool nan_eq_nan)
FloatingEq2Matcher(FloatType max_abs_error)
Impl(FloatType expected, bool nan_eq_nan, FloatType max_abs_error)
virtual void DescribeNegationTo(::std::ostream *os) const
virtual bool MatchAndExplain(T value, MatchResultListener *listener) const
virtual void DescribeTo(::std::ostream *os) const
FloatingEqMatcher(FloatType expected, bool nan_eq_nan, FloatType max_abs_error)
FloatingEqMatcher(FloatType expected, bool nan_eq_nan)
static const char * Desc()
static const char * Desc()
static const char * NegatedDesc()
GeMatcher(const Rhs &rhs)
static const char * Desc()
static const char * Desc()
static const char * NegatedDesc()
GtMatcher(const Rhs &rhs)
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
void DescribeTo(::std::ostream *os) const
HasSubstrMatcher(const StringType &substring)
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
void DescribeNegationTo(::std::ostream *os) const
void DescribeTo(::std::ostream *os) const
void DescribeNegationTo(::std::ostream *os) const
bool MatchAndExplain(const Pointer &p, MatchResultListener *) const
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType
virtual void DescribeNegationTo(::std::ostream *os) const
KeyMatcherImpl(InnerMatcher inner_matcher)
virtual bool MatchAndExplain(PairType key_value, MatchResultListener *listener) const
RawPairType::first_type KeyType
virtual void DescribeTo(::std::ostream *os) const
static const char * Desc()
static const char * Desc()
static const char * NegatedDesc()
LeMatcher(const Rhs &rhs)
static const char * Desc()
static const char * Desc()
static const char * NegatedDesc()
LtMatcher(const Rhs &rhs)
bool HasEdge(size_t ilhs, size_t irhs) const
void SetEdge(size_t ilhs, size_t irhs, bool b)
MatchMatrix(size_t num_elements, size_t num_matchers)
MatcherAsPredicate(M matcher)
bool operator()(const T &x) const
MatcherBase(const MatcherInterface< GTEST_REFERENCE_TO_CONST_(T)> *impl)
void ExplainMatchResultTo(GTEST_REFERENCE_TO_CONST_(T) x, ::std::ostream *os) const
void DescribeTo(::std::ostream *os) const
bool MatchAndExplain(GTEST_REFERENCE_TO_CONST_(T) x, MatchResultListener *listener) const
MatcherBase(const MatcherInterface< U > *impl, typename internal::EnableIf< !internal::IsSame< U, GTEST_REFERENCE_TO_CONST_(U)>::value >::type *=NULL)
bool Matches(GTEST_REFERENCE_TO_CONST_(T) x) const
void DescribeNegationTo(::std::ostream *os) const
const MatcherDescriberInterface * GetDescriber() const
static Matcher< T > Cast(const Matcher< T > &matcher)
static Matcher< T > Cast(const Matcher< U > &source_matcher)
static Matcher< T > Cast(const M &polymorphic_matcher_or_value)
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeTo(::std::ostream *os) const
virtual ~MatcherInterfaceAdapter()
MatcherInterfaceAdapter(const MatcherInterface< T > *impl)
virtual bool MatchAndExplain(const T &x, MatchResultListener *listener) const
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
void DescribeNegationTo(::std::ostream *os) const
void DescribeTo(::std::ostream *os) const
MatchesRegexMatcher(const RE *regex, bool full_match)
static const char * Desc()
static const char * NegatedDesc()
NeMatcher(const Rhs &rhs)
static const char * Desc()
NotMatcher(InnerMatcher matcher)
virtual void DescribeTo(::std::ostream *os) const
virtual bool MatchAndExplain(GTEST_REFERENCE_TO_CONST_(T) x, MatchResultListener *listener) const
virtual void DescribeNegationTo(::std::ostream *os) const
NotMatcherImpl(const Matcher< T > &matcher)
void DescribeNegationTo(::std::ostream *os) const
bool MatchAndExplain(const Pointer &p, MatchResultListener *) const
void DescribeTo(::std::ostream *os) const
Impl(const ValueMatcher &value_matcher)
virtual void DescribeNegationTo(::std::ostream *os) const
OptionalView::value_type ValueType
virtual bool MatchAndExplain(Optional optional, MatchResultListener *listener) const
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Optional) OptionalView
virtual void DescribeTo(::std::ostream *os) const
OptionalMatcher(const ValueMatcher &value_matcher)
PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher)
virtual bool MatchAndExplain(PairType a_pair, MatchResultListener *listener) const
RawPairType::second_type SecondType
virtual void DescribeNegationTo(::std::ostream *os) const
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType
RawPairType::first_type FirstType
virtual void DescribeTo(::std::ostream *os) const
PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher)
PointeeMatcher(const InnerMatcher &matcher)
virtual void DescribeTo(::std::ostream *os) const
virtual void DescribeNegationTo(::std::ostream *os) const
internal::StlContainerView< GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView
LhsView::const_reference LhsStlContainerReference
virtual bool MatchAndExplain(LhsContainer lhs, MatchResultListener *listener) const
::testing::tuple< const LhsValue &, const RhsValue & > InnerMatcherArg
LhsView::type LhsStlContainer
Impl(const TupleMatcher &tuple_matcher, const RhsStlContainer &rhs)
LhsStlContainer::value_type LhsValue
internal::StlContainerView< RhsContainer > RhsView
RhsView::type RhsStlContainer
PointwiseMatcher(const TupleMatcher &tuple_matcher, const RhsContainer &rhs)
RhsStlContainer::value_type RhsValue
PropertyMatcher(const std::string &property_name, Property property, const Matcher< RefToConstProperty > &matcher)
void DescribeNegationTo(::std::ostream *os) const
bool MatchAndExplain(const T &value, MatchResultListener *listener) const
typedef GTEST_REFERENCE_TO_CONST_(PropertyType) RefToConstProperty
void DescribeTo(::std::ostream *os) const
PropertyMatcher(Property property, const Matcher< RefToConstProperty > &matcher)
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer
StlContainer::value_type Element
bool MatchAndExplainImpl(bool all_elements_should_match, Container container, MatchResultListener *listener) const
GTEST_DISALLOW_ASSIGN_(QuantifierMatcherImpl)
View::const_reference StlContainerReference
QuantifierMatcherImpl(InnerMatcher inner_matcher)
const Matcher< const Element & > inner_matcher_
StlContainerView< RawContainer > View
static bool PartialMatch(const ::std::string &str, const RE &re)
static bool FullMatch(const ::std::string &str, const RE &re)
CallableTraits< Callable >::ResultType ResultType
ResultOfMatcher(Callable callable, const Matcher< ResultType > &matcher)
virtual void DescribeNegationTo(::std::ostream *os) const
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
virtual void DescribeTo(::std::ostream *os) const
ContainerView::type::size_type SizeType
Impl(const SizeMatcher &size_matcher)
internal::StlContainerView< GTEST_REMOVE_REFERENCE_AND_CONST_(Container)> ContainerView
SizeIsMatcher(const SizeMatcher &size_matcher)
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
void DescribeNegationTo(::std::ostream *os) const
StartsWithMatcher(const StringType &prefix)
void DescribeTo(::std::ostream *os) const
static const_reference ConstReference(const RawContainer &container)
const type & const_reference
void DescribeTo(::std::ostream *os) const
StrEqualityMatcher(const StringType &str, bool expect_eq, bool case_sensitive)
bool MatchAndExplain(CharType *s, MatchResultListener *listener) const
bool MatchAndExplain(const MatcheeStringType &s, MatchResultListener *) const
void DescribeNegationTo(::std::ostream *os) const
StreamMatchResultListener(::std::ostream *os)
static bool CaseInsensitiveCStringEquals(const char *lhs, const char *rhs)
static bool CaseInsensitiveWideCStringEquals(const wchar_t *lhs, const wchar_t *rhs)
void DescribeNegationTo(::std::ostream *os) const
TrulyMatcher(Predicate pred)
void DescribeTo(::std::ostream *os) const
bool MatchAndExplain(T &x, MatchResultListener *) const
static bool Matches(const MatcherTuple &, const ValueTuple &)
static void ExplainMatchFailuresTo(const MatcherTuple &, const ValueTuple &, ::std::ostream *)
static void ExplainMatchFailuresTo(const MatcherTuple &matchers, const ValueTuple &values, ::std::ostream *os)
static bool Matches(const MatcherTuple &matcher_tuple, const ValueTuple &value_tuple)
static void Print(const T &value, ::std::ostream *os)
UnorderedElementsAreArrayMatcher(UnorderedMatcherRequire::Flags match_flags, Iter first, Iter last)
UnorderedElementsAreMatcher(const MatcherTuple &args)
void DescribeToImpl(::std::ostream *os) const
bool FindPairing(const MatchMatrix &matrix, MatchResultListener *listener) const
bool VerifyMatchMatrix(const ::std::vector< std::string > &element_printouts, const MatchMatrix &matrix, MatchResultListener *listener) const
void DescribeNegationToImpl(::std::ostream *os) const
static Message Elements(size_t n)
UnorderedElementsAreMatcherImplBase(UnorderedMatcherRequire::Flags matcher_flags)
UnorderedMatcherRequire::Flags match_flags() const
MatcherDescriberVec & matcher_describers()
::std::vector< const MatcherDescriberInterface * > MatcherDescriberVec
StlContainer::value_type Element
View::const_reference StlContainerReference
virtual void DescribeTo(::std::ostream *os) const
virtual bool MatchAndExplain(Container container, MatchResultListener *listener) const
internal::StlContainerView< RawContainer > View
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer
StlContainer::const_iterator StlContainerConstIterator
UnorderedElementsAreMatcherImpl(UnorderedMatcherRequire::Flags matcher_flags, InputIter first, InputIter last)
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeNegationTo(::std::ostream *os) const
virtual void DescribeTo(::std::ostream *os) const
LhsView::type LhsStlContainer
Impl(const Comparator &comparator, const ContainerMatcher &matcher)
RemoveConstFromKey< typenameLhsStlContainer::value_type >::type LhsValue
virtual bool MatchAndExplain(LhsContainer lhs, MatchResultListener *listener) const
internal::StlContainerView< GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView
LhsView::const_reference LhsStlContainerReference
WhenSortedByMatcher(const Comparator &comparator, const ContainerMatcher &matcher)
void DescribeNegationTo(std::ostream *os) const
bool MatchAndExplain(const AnyType &value, ::testing::MatchResultListener *listener) const
void DescribeTo(std::ostream *os) const
AnyCastMatcher(const ::testing::Matcher< const T & > &matcher)
void DescribeTo(std::ostream *os) const
bool MatchAndExplain(const Variant &value, ::testing::MatchResultListener *listener) const
VariantMatcher(::testing::Matcher< const T & > matcher)
void DescribeNegationTo(std::ostream *os) const
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
#define GMOCK_KIND_OF_(type)
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
#define GTEST_REMOVE_CONST_(T)
#define GTEST_REMOVE_REFERENCE_(T)
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T)
#define GTEST_LOG_(severity)
#define GTEST_REFERENCE_TO_CONST_(T)
#define GTEST_CHECK_(condition)
#define GTEST_DISALLOW_ASSIGN_(type)
#define GTEST_COMPILE_ASSERT_(expr, msg)
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
void diff(const std::string &a, const std::string &b)
GeneratorWrapper< T > values(std::initializer_list< T > values)
T::second_type & Second(T &x, Rank0)
T::first_type & First(T &x, Rank0)
::std::vector< ElementMatcherPair > ElementMatcherPairs
OutIter TransformTupleValues(Func f, const Tuple &t, OutIter out)
bool MatchPrintAndExplain(Value &value, const Matcher< T > &matcher, MatchResultListener *listener)
bool TupleMatches(const MatcherTuple &matcher_tuple, const ValueTuple &value_tuple)
::std::pair< size_t, size_t > ElementMatcherPair
void UniversalPrint(const T &value, ::std::ostream *os)
bool CaseInsensitiveStringEquals(const StringType &s1, const StringType &s2)
BoundSecondMatcher< Tuple2Matcher, Second > MatcherBindSecond(const Tuple2Matcher &tm, const Second &second)
::std::vector< ::std::string > Strings
bool_constant< true > true_type
std::string GetTypeName()
PredicateFormatterFromMatcher< M > MakePredicateFormatterFromMatcher(M matcher)
Iter ArrayAwareFind(Iter begin, Iter end, const Element &elem)
const T & move(const T &t)
bool_constant< false > false_type
bool IsReadableTypeName(const std::string &type_name)
GTEST_API_ std::string FormatMatcherDescription(bool negation, const char *matcher_name, const Strings ¶m_values)
const Pointer::element_type * GetRawPointer(const Pointer &p)
void PrintIfNotEmpty(const std::string &explanation, ::std::ostream *os)
GTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix &g)
bool CaseInsensitiveCStringEquals(const char *lhs, const char *rhs)
void ExplainMatchFailureTupleTo(const MatcherTuple &matchers, const ValueTuple &values, ::std::ostream *os)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
internal::Le2Matcher Le()
internal::PointwiseMatcher< TupleMatcher, GTEST_REMOVE_CONST_(Container)> Pointwise(const TupleMatcher &tuple_matcher, const Container &rhs)
Matcher< Lhs > TypedEq(const Rhs &rhs)
PolymorphicMatcher< internal::StrEqualityMatcher< std::string > > StrCaseEq(const std::string &str)
internal::Ne2Matcher Ne()
PolymorphicMatcher< internal::variant_matcher::VariantMatcher< T > > VariantWith(const Matcher< const T & > &matcher)
internal::FloatingEq2Matcher< double > DoubleEq()
PolymorphicMatcher< internal::NotNullMatcher > NotNull()
PolymorphicMatcher< internal::HasSubstrMatcher< std::string > > HasSubstr(const std::string &substring)
internal::WhenSortedByMatcher< Comparator, ContainerMatcher > WhenSortedBy(const Comparator &comparator, const ContainerMatcher &container_matcher)
InnerMatcher AllArgs(const InnerMatcher &matcher)
PolymorphicMatcher< internal::IsNullMatcher > IsNull()
internal::WhenSortedByMatcher< internal::LessComparator, ContainerMatcher > WhenSorted(const ContainerMatcher &container_matcher)
internal::FloatingEqMatcher< float > NanSensitiveFloatNear(float rhs, float max_abs_error)
internal::EachMatcher< M > Each(M matcher)
internal::Lt2Matcher Lt()
internal::Gt2Matcher Gt()
internal::FloatingEqMatcher< double > DoubleNear(double rhs, double max_abs_error)
PolymorphicMatcher< internal::StrEqualityMatcher< std::string > > StrCaseNe(const std::string &str)
PolymorphicMatcher< internal::MatchesRegexMatcher > MatchesRegex(const internal::RE *regex)
internal::UnorderedElementsAreArrayMatcher< typename ::std::iterator_traits< Iter >::value_type > IsSubsetOf(Iter first, Iter last)
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType, PropertyType(Class::*)() const > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
internal::AllOfResult2< M1, M2 >::type AllOf(M1 m1, M2 m2)
PolymorphicMatcher< internal::StartsWithMatcher< std::string > > StartsWith(const std::string &prefix)
PolymorphicMatcher< internal::EndsWithMatcher< std::string > > EndsWith(const std::string &suffix)
internal::ResultOfMatcher< Callable > ResultOf(Callable callable, const ResultOfMatcher &matcher)
bool StaticAssertTypeEq()
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
internal::ElementsAreArrayMatcher< typename ::std::iterator_traits< Iter >::value_type > ElementsAreArray(Iter first, Iter last)
GTEST_API_ AssertionResult AssertionFailure()
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
internal::FloatingEqMatcher< float > FloatNear(float rhs, float max_abs_error)
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
std::ostream & operator<<(std::ostream &os, const Matcher< T > &matcher)
internal::FloatingEq2Matcher< float > NanSensitiveFloatEq()
internal::Ge2Matcher Ge()
PolymorphicMatcher< internal::MatchesRegexMatcher > ContainsRegex(const internal::RE *regex)
internal::UnorderedElementsAreArrayMatcher< typename ::std::iterator_traits< Iter >::value_type > IsSupersetOf(Iter first, Iter last)
internal::KeyMatcher< M > Key(M inner_matcher)
internal::SizeIsMatcher< SizeMatcher > SizeIs(const SizeMatcher &size_matcher)
::std::string PrintToString(const T &value)
internal::ContainsMatcher< M > Contains(M matcher)
internal::Eq2Matcher Eq()
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
PolymorphicMatcher< Impl > MakePolymorphicMatcher(const Impl &impl)
internal::FloatingEq2Matcher< float > FloatEq()
internal::FloatingEq2Matcher< double > NanSensitiveDoubleEq()
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
GTEST_API_ AssertionResult AssertionSuccess()
internal::FloatingEqMatcher< double > NanSensitiveDoubleNear(double rhs, double max_abs_error)
internal::BeginEndDistanceIsMatcher< DistanceMatcher > BeginEndDistanceIs(const DistanceMatcher &distance_matcher)
Matcher< T > MakeMatcher(const MatcherInterface< T > *impl)
internal::UnorderedElementsAreArrayMatcher< typename ::std::iterator_traits< Iter >::value_type > UnorderedElementsAreArray(Iter first, Iter last)
PolymorphicMatcher< internal::StrEqualityMatcher< std::string > > StrEq(const std::string &str)
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
Matcher< T > MatcherCast(const M &matcher)
Matcher< T > SafeMatcherCast(const M &polymorphic_matcher)
internal::UnorderedElementsAreArrayMatcher< typename internal::BoundSecondMatcher< Tuple2Matcher, typename internal::StlContainerView< GTEST_REMOVE_CONST_(RhsContainer)>::type::value_type > > UnorderedPointwise(const Tuple2Matcher &tuple2_matcher, const RhsContainer &rhs_container)
internal::RefMatcher< T & > Ref(T &x)
internal::MatcherAsPredicate< M > Matches(M matcher)
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
PolymorphicMatcher< internal::any_cast_matcher::AnyCastMatcher< T > > AnyWith(const Matcher< const T & > &matcher)
std::string DescribeMatcher(const M &matcher, bool negation=false)
PolymorphicMatcher< internal::StrEqualityMatcher< std::string > > StrNe(const std::string &str)
const GenericPointer< typename T::ValueType > & pointer
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
#define T(meth, val, expected)
bool operator()(const A &a, const B &b) const
bool operator()(const A &a, const B &b) const
bool operator()(const A &a, const B &b) const
bool operator()(const A &a, const B &b) const
bool operator()(const A &a, const B &b) const
bool operator()(const A &a, const B &b) const
static void CheckIsValid(ResType(*f)(ArgType))
static ResType Invoke(ResType(*f)(ArgType), T arg)
static void CheckIsValid(Functor)
static ResultType Invoke(Functor f, T arg)
Functor::result_type ResultType
bool operator()(const T &lhs, const U &rhs) const