Electroneum
testing::internal::EitherOfMatcherImpl< T > Class Template Reference

#include <gmock-matchers.h>

Inheritance diagram for testing::internal::EitherOfMatcherImpl< T >:
Collaboration diagram for testing::internal::EitherOfMatcherImpl< T >:

Public Member Functions

 EitherOfMatcherImpl (const Matcher< T > &matcher1, const Matcher< T > &matcher2)
 
virtual void DescribeTo (::std::ostream *os) const
 
virtual void DescribeNegationTo (::std::ostream *os) const
 
virtual bool MatchAndExplain (T x, MatchResultListener *listener) const
 
- Public Member Functions inherited from testing::MatcherDescriberInterface
virtual ~MatcherDescriberInterface ()
 

Detailed Description

template<typename T>
class testing::internal::EitherOfMatcherImpl< T >

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

Constructor & Destructor Documentation

◆ EitherOfMatcherImpl()

template<typename T >
testing::internal::EitherOfMatcherImpl< T >::EitherOfMatcherImpl ( const Matcher< T > &  matcher1,
const Matcher< T > &  matcher2 
)
inline

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

1667  : matcher1_(matcher1), matcher2_(matcher2) {}

Member Function Documentation

◆ DescribeNegationTo()

template<typename T >
virtual void testing::internal::EitherOfMatcherImpl< T >::DescribeNegationTo ( ::std::ostream *  os) const
inlinevirtual

Reimplemented from testing::MatcherDescriberInterface.

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

1677  {
1678  *os << "(";
1679  matcher1_.DescribeNegationTo(os);
1680  *os << ") and (";
1681  matcher2_.DescribeNegationTo(os);
1682  *os << ")";
1683  }

◆ DescribeTo()

template<typename T >
virtual void testing::internal::EitherOfMatcherImpl< T >::DescribeTo ( ::std::ostream *  os) const
inlinevirtual

Implements testing::MatcherDescriberInterface.

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

1669  {
1670  *os << "(";
1671  matcher1_.DescribeTo(os);
1672  *os << ") or (";
1673  matcher2_.DescribeTo(os);
1674  *os << ")";
1675  }

◆ MatchAndExplain()

template<typename T >
virtual bool testing::internal::EitherOfMatcherImpl< T >::MatchAndExplain ( T  x,
MatchResultListener listener 
) const
inlinevirtual

Implements testing::MatcherInterface< T >.

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

1685  {
1686  // If either matcher1_ or matcher2_ matches x, we just need to
1687  // explain why *one* of them matches.
1688  StringMatchResultListener listener1;
1689  if (matcher1_.MatchAndExplain(x, &listener1)) {
1690  *listener << listener1.str();
1691  return true;
1692  }
1693 
1694  StringMatchResultListener listener2;
1695  if (matcher2_.MatchAndExplain(x, &listener2)) {
1696  *listener << listener2.str();
1697  return true;
1698  }
1699 
1700  // Otherwise we need to explain why *both* of them fail.
1701  const internal::string s1 = listener1.str();
1702  const internal::string s2 = listener2.str();
1703 
1704  if (s1 == "") {
1705  *listener << s2;
1706  } else {
1707  *listener << s1;
1708  if (s2 != "") {
1709  *listener << ", and " << s2;
1710  }
1711  }
1712  return false;
1713  }
::std::string string
Definition: gtest-port.h:1097
Here is the call graph for this function:

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