Electroneum
testing::internal::WhenSortedByMatcher< Comparator, ContainerMatcher >::Impl< LhsContainer > Class Template Reference

#include <gmock-matchers.h>

Inheritance diagram for testing::internal::WhenSortedByMatcher< Comparator, ContainerMatcher >::Impl< LhsContainer >:
Collaboration diagram for testing::internal::WhenSortedByMatcher< Comparator, ContainerMatcher >::Impl< LhsContainer >:

Public Types

typedef internal::StlContainerView< GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView
 
typedef LhsView::type LhsStlContainer
 
typedef LhsView::const_reference LhsStlContainerReference
 
typedef RemoveConstFromKey< typename LhsStlContainer::value_type >::type LhsValue
 

Public Member Functions

 Impl (const Comparator &comparator, const ContainerMatcher &matcher)
 
virtual void DescribeTo (::std::ostream *os) const
 
virtual void DescribeNegationTo (::std::ostream *os) const
 
virtual bool MatchAndExplain (LhsContainer lhs, MatchResultListener *listener) const
 
- Public Member Functions inherited from testing::MatcherDescriberInterface
virtual ~MatcherDescriberInterface ()
 

Detailed Description

template<typename Comparator, typename ContainerMatcher>
template<typename LhsContainer>
class testing::internal::WhenSortedByMatcher< Comparator, ContainerMatcher >::Impl< LhsContainer >

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

Member Typedef Documentation

◆ LhsStlContainer

template<typename Comparator, typename ContainerMatcher>
template<typename LhsContainer >
typedef LhsView::type testing::internal::WhenSortedByMatcher< Comparator, ContainerMatcher >::Impl< LhsContainer >::LhsStlContainer

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

◆ LhsStlContainerReference

template<typename Comparator, typename ContainerMatcher>
template<typename LhsContainer >
typedef LhsView::const_reference testing::internal::WhenSortedByMatcher< Comparator, ContainerMatcher >::Impl< LhsContainer >::LhsStlContainerReference

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

◆ LhsValue

template<typename Comparator, typename ContainerMatcher>
template<typename LhsContainer >
typedef RemoveConstFromKey< typename LhsStlContainer::value_type>::type testing::internal::WhenSortedByMatcher< Comparator, ContainerMatcher >::Impl< LhsContainer >::LhsValue

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

◆ LhsView

template<typename Comparator, typename ContainerMatcher>
template<typename LhsContainer >
typedef internal::StlContainerView< GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> testing::internal::WhenSortedByMatcher< Comparator, ContainerMatcher >::Impl< LhsContainer >::LhsView

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

Constructor & Destructor Documentation

◆ Impl()

template<typename Comparator, typename ContainerMatcher>
template<typename LhsContainer >
testing::internal::WhenSortedByMatcher< Comparator, ContainerMatcher >::Impl< LhsContainer >::Impl ( const Comparator &  comparator,
const ContainerMatcher &  matcher 
)
inline

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

2637  : comparator_(comparator), matcher_(matcher) {}

Member Function Documentation

◆ DescribeNegationTo()

template<typename Comparator, typename ContainerMatcher>
template<typename LhsContainer >
virtual void testing::internal::WhenSortedByMatcher< Comparator, ContainerMatcher >::Impl< LhsContainer >::DescribeNegationTo ( ::std::ostream *  os) const
inlinevirtual

Reimplemented from testing::MatcherDescriberInterface.

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

2644  {
2645  *os << "(when sorted) ";
2646  matcher_.DescribeNegationTo(os);
2647  }
void DescribeNegationTo(::std::ostream *os) const
Here is the call graph for this function:

◆ DescribeTo()

template<typename Comparator, typename ContainerMatcher>
template<typename LhsContainer >
virtual void testing::internal::WhenSortedByMatcher< Comparator, ContainerMatcher >::Impl< LhsContainer >::DescribeTo ( ::std::ostream *  os) const
inlinevirtual

Implements testing::MatcherDescriberInterface.

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

2639  {
2640  *os << "(when sorted) ";
2641  matcher_.DescribeTo(os);
2642  }
void DescribeTo(::std::ostream *os) const
Here is the call graph for this function:

◆ MatchAndExplain()

template<typename Comparator, typename ContainerMatcher>
template<typename LhsContainer >
virtual bool testing::internal::WhenSortedByMatcher< Comparator, ContainerMatcher >::Impl< LhsContainer >::MatchAndExplain ( LhsContainer  lhs,
MatchResultListener listener 
) const
inlinevirtual

Implements testing::MatcherInterface< LhsContainer >.

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

2650  {
2651  LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
2652  ::std::vector<LhsValue> sorted_container(lhs_stl_container.begin(),
2653  lhs_stl_container.end());
2654  ::std::sort(
2655  sorted_container.begin(), sorted_container.end(), comparator_);
2656 
2657  if (!listener->IsInterested()) {
2658  // If the listener is not interested, we do not need to
2659  // construct the inner explanation.
2660  return matcher_.Matches(sorted_container);
2661  }
2662 
2663  *listener << "which is ";
2664  UniversalPrint(sorted_container, listener->stream());
2665  *listener << " when sorted";
2666 
2667  StringMatchResultListener inner_listener;
2668  const bool match = matcher_.MatchAndExplain(sorted_container,
2669  &inner_listener);
2670  PrintIfNotEmpty(inner_listener.str(), listener->stream());
2671  return match;
2672  }
bool MatchAndExplain(T x, MatchResultListener *listener) const
LhsView::const_reference LhsStlContainerReference
static const_reference ConstReference(const RawContainer &container)
void PrintIfNotEmpty(const internal::string &explanation, ::std::ostream *os)
void UniversalPrint(const T &value, ::std::ostream *os)
Here is the call graph for this function:

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