Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
testing::internal::PredicateFormatterFromMatcher< M > Class Template Reference

#include <gmock-matchers.h>

Public Member Functions

 PredicateFormatterFromMatcher (M m)
 
template<typename T >
AssertionResult operator() (const char *value_text, const T &x) const
 

Detailed Description

template<typename M>
class testing::internal::PredicateFormatterFromMatcher< M >

Definition at line 2030 of file gmock-matchers.h.

Constructor & Destructor Documentation

◆ PredicateFormatterFromMatcher()

template<typename M >
testing::internal::PredicateFormatterFromMatcher< M >::PredicateFormatterFromMatcher ( M m)
inlineexplicit

Definition at line 2032 of file gmock-matchers.h.

2032: matcher_(internal::move(m)) {}
const T & move(const T &t)

Member Function Documentation

◆ operator()()

template<typename M >
template<typename T >
AssertionResult testing::internal::PredicateFormatterFromMatcher< M >::operator() ( const char * value_text,
const T & x ) const
inline

Definition at line 2038 of file gmock-matchers.h.

2038 {
2039 // We convert matcher_ to a Matcher<const T&> *now* instead of
2040 // when the PredicateFormatterFromMatcher object was constructed,
2041 // as matcher_ may be polymorphic (e.g. NotNull()) and we won't
2042 // know which type to instantiate it to until we actually see the
2043 // type of x here.
2044 //
2045 // We write SafeMatcherCast<const T&>(matcher_) instead of
2046 // Matcher<const T&>(matcher_), as the latter won't compile when
2047 // matcher_ has type Matcher<T> (e.g. An<int>()).
2048 // We don't write MatcherCast<const T&> either, as that allows
2049 // potentially unsafe downcasting of the matcher argument.
2050 const Matcher<const T&> matcher = SafeMatcherCast<const T&>(matcher_);
2051 StringMatchResultListener listener;
2052 if (MatchPrintAndExplain(x, matcher, &listener))
2053 return AssertionSuccess();
2054
2055 ::std::stringstream ss;
2056 ss << "Value of: " << value_text << "\n"
2057 << "Expected: ";
2058 matcher.DescribeTo(&ss);
2059 ss << "\n Actual: " << listener.str();
2060 return AssertionFailure() << ss.str();
2061 }
static const Segment ss(Segment::ss)
bool MatchPrintAndExplain(Value &value, const Matcher< T > &matcher, MatchResultListener *listener)
GTEST_API_ AssertionResult AssertionFailure()
Definition gtest.cc:1029
GTEST_API_ AssertionResult AssertionSuccess()
Definition gtest.cc:1024
Matcher< T > SafeMatcherCast(const M &polymorphic_matcher)
Here is the call graph for this function:

The documentation for this class was generated from the following file: