Electroneum
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 1834 of file gmock-matchers.h.

Constructor & Destructor Documentation

◆ PredicateFormatterFromMatcher()

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

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

1836 : matcher_(internal::move(m)) {}
const T & move(const T &t)
Definition: gtest-port.h:1317

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 1842 of file gmock-matchers.h.

1842  {
1843  // We convert matcher_ to a Matcher<const T&> *now* instead of
1844  // when the PredicateFormatterFromMatcher object was constructed,
1845  // as matcher_ may be polymorphic (e.g. NotNull()) and we won't
1846  // know which type to instantiate it to until we actually see the
1847  // type of x here.
1848  //
1849  // We write SafeMatcherCast<const T&>(matcher_) instead of
1850  // Matcher<const T&>(matcher_), as the latter won't compile when
1851  // matcher_ has type Matcher<T> (e.g. An<int>()).
1852  // We don't write MatcherCast<const T&> either, as that allows
1853  // potentially unsafe downcasting of the matcher argument.
1854  const Matcher<const T&> matcher = SafeMatcherCast<const T&>(matcher_);
1855  StringMatchResultListener listener;
1856  if (MatchPrintAndExplain(x, matcher, &listener))
1857  return AssertionSuccess();
1858 
1859  ::std::stringstream ss;
1860  ss << "Value of: " << value_text << "\n"
1861  << "Expected: ";
1862  matcher.DescribeTo(&ss);
1863  ss << "\n Actual: " << listener.str();
1864  return AssertionFailure() << ss.str();
1865  }
GTEST_API_ AssertionResult AssertionFailure()
bool MatchPrintAndExplain(Value &value, const Matcher< T > &matcher, MatchResultListener *listener)
GTEST_API_ AssertionResult AssertionSuccess()
Here is the call graph for this function:

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