proxygen
testing::internal::UnorderedElementsAreMatcherImpl< Container > Class Template Reference

#include <gmock-matchers.h>

Inheritance diagram for testing::internal::UnorderedElementsAreMatcherImpl< Container >:
testing::MatcherInterface< Container > testing::internal::UnorderedElementsAreMatcherImplBase testing::MatcherInterface< Container > testing::internal::UnorderedElementsAreMatcherImplBase testing::MatcherInterface< Container > testing::internal::UnorderedElementsAreMatcherImplBase testing::MatcherDescriberInterface testing::MatcherDescriberInterface testing::MatcherDescriberInterface testing::MatcherDescriberInterface testing::MatcherDescriberInterface testing::MatcherDescriberInterface testing::MatcherDescriberInterface testing::MatcherDescriberInterface testing::MatcherDescriberInterface

Public Types

typedef internal::StlContainerView< RawContainer > View
 
typedef View::type StlContainer
 
typedef View::const_reference StlContainerReference
 
typedef StlContainer::const_iterator StlContainerConstIterator
 
typedef StlContainer::value_type Element
 
typedef internal::StlContainerView< RawContainer > View
 
typedef View::type StlContainer
 
typedef View::const_reference StlContainerReference
 
typedef StlContainer::const_iterator StlContainerConstIterator
 
typedef StlContainer::value_type Element
 
typedef internal::StlContainerView< RawContainer > View
 
typedef View::type StlContainer
 
typedef View::const_reference StlContainerReference
 
typedef StlContainer::const_iterator StlContainerConstIterator
 
typedef StlContainer::value_type Element
 

Public Member Functions

typedef GTEST_REMOVE_REFERENCE_AND_CONST_ (Container) RawContainer
 
template<typename InputIter >
 UnorderedElementsAreMatcherImpl (InputIter first, InputIter last)
 
virtual void DescribeTo (::std::ostream *os) const
 
virtual void DescribeNegationTo (::std::ostream *os) const
 
virtual bool MatchAndExplain (Container container, MatchResultListener *listener) const
 
typedef GTEST_REMOVE_REFERENCE_AND_CONST_ (Container) RawContainer
 
template<typename InputIter >
 UnorderedElementsAreMatcherImpl (InputIter first, InputIter last)
 
virtual void DescribeTo (::std::ostream *os) const
 
virtual void DescribeNegationTo (::std::ostream *os) const
 
virtual bool MatchAndExplain (Container container, MatchResultListener *listener) const
 
typedef GTEST_REMOVE_REFERENCE_AND_CONST_ (Container) RawContainer
 
template<typename InputIter >
 UnorderedElementsAreMatcherImpl (InputIter first, InputIter last)
 
virtual void DescribeTo (::std::ostream *os) const
 
virtual void DescribeNegationTo (::std::ostream *os) const
 
virtual bool MatchAndExplain (Container container, MatchResultListener *listener) const
 
- Public Member Functions inherited from testing::MatcherDescriberInterface
virtual ~MatcherDescriberInterface ()
 
virtual ~MatcherDescriberInterface ()
 
virtual ~MatcherDescriberInterface ()
 

Private Types

typedef ::std::vector< Matcher< const Element & > > MatcherVec
 
typedef ::std::vector< Matcher< const Element & > > MatcherVec
 
typedef ::std::vector< Matcher< const Element & > > MatcherVec
 

Private Member Functions

template<typename ElementIter >
MatchMatrix AnalyzeElements (ElementIter elem_first, ElementIter elem_last,::std::vector< string > *element_printouts, MatchResultListener *listener) const
 
 GTEST_DISALLOW_ASSIGN_ (UnorderedElementsAreMatcherImpl)
 
template<typename ElementIter >
MatchMatrix AnalyzeElements (ElementIter elem_first, ElementIter elem_last,::std::vector< string > *element_printouts, MatchResultListener *listener) const
 
 GTEST_DISALLOW_ASSIGN_ (UnorderedElementsAreMatcherImpl)
 
template<typename ElementIter >
MatchMatrix AnalyzeElements (ElementIter elem_first, ElementIter elem_last,::std::vector< string > *element_printouts, MatchResultListener *listener) const
 
 GTEST_DISALLOW_ASSIGN_ (UnorderedElementsAreMatcherImpl)
 

Private Attributes

MatcherVec matchers_
 

Additional Inherited Members

- Protected Types inherited from testing::internal::UnorderedElementsAreMatcherImplBase
typedef ::std::vector< const MatcherDescriberInterface * > MatcherDescriberVec
 
typedef ::std::vector< const MatcherDescriberInterface * > MatcherDescriberVec
 
typedef ::std::vector< const MatcherDescriberInterface * > MatcherDescriberVec
 
- Protected Member Functions inherited from testing::internal::UnorderedElementsAreMatcherImplBase
void DescribeToImpl (::std::ostream *os) const
 
void DescribeNegationToImpl (::std::ostream *os) const
 
bool VerifyAllElementsAndMatchersAreMatched (const ::std::vector< string > &element_printouts, const MatchMatrix &matrix, MatchResultListener *listener) const
 
MatcherDescriberVecmatcher_describers ()
 
void DescribeToImpl (::std::ostream *os) const
 
void DescribeNegationToImpl (::std::ostream *os) const
 
bool VerifyAllElementsAndMatchersAreMatched (const ::std::vector< string > &element_printouts, const MatchMatrix &matrix, MatchResultListener *listener) const
 
MatcherDescriberVecmatcher_describers ()
 
void DescribeToImpl (::std::ostream *os) const
 
void DescribeNegationToImpl (::std::ostream *os) const
 
bool VerifyAllElementsAndMatchersAreMatched (const ::std::vector< string > &element_printouts, const MatchMatrix &matrix, MatchResultListener *listener) const
 
MatcherDescriberVecmatcher_describers ()
 
- Static Protected Member Functions inherited from testing::internal::UnorderedElementsAreMatcherImplBase
static Message Elements (size_t n)
 
static Message Elements (size_t n)
 
static Message Elements (size_t n)
 

Detailed Description

template<typename Container>
class testing::internal::UnorderedElementsAreMatcherImpl< Container >

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

Member Typedef Documentation

template<typename Container >
typedef StlContainer::value_type testing::internal::UnorderedElementsAreMatcherImpl< Container >::Element

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

template<typename Container >
typedef StlContainer::value_type testing::internal::UnorderedElementsAreMatcherImpl< Container >::Element

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

template<typename Container >
typedef StlContainer::value_type testing::internal::UnorderedElementsAreMatcherImpl< Container >::Element

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

template<typename Container >
typedef ::std::vector<Matcher<const Element&> > testing::internal::UnorderedElementsAreMatcherImpl< Container >::MatcherVec
private

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

template<typename Container >
typedef ::std::vector<Matcher<const Element&> > testing::internal::UnorderedElementsAreMatcherImpl< Container >::MatcherVec
private

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

template<typename Container >
typedef ::std::vector<Matcher<const Element&> > testing::internal::UnorderedElementsAreMatcherImpl< Container >::MatcherVec
private

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

template<typename Container >
typedef View::type testing::internal::UnorderedElementsAreMatcherImpl< Container >::StlContainer

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

template<typename Container >
typedef View::type testing::internal::UnorderedElementsAreMatcherImpl< Container >::StlContainer

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

template<typename Container >
typedef View::type testing::internal::UnorderedElementsAreMatcherImpl< Container >::StlContainer

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

template<typename Container >
typedef StlContainer::const_iterator testing::internal::UnorderedElementsAreMatcherImpl< Container >::StlContainerConstIterator

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

template<typename Container >
typedef StlContainer::const_iterator testing::internal::UnorderedElementsAreMatcherImpl< Container >::StlContainerConstIterator

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

template<typename Container >
typedef StlContainer::const_iterator testing::internal::UnorderedElementsAreMatcherImpl< Container >::StlContainerConstIterator

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

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

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

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

template<typename Container >
typedef internal::StlContainerView<RawContainer> testing::internal::UnorderedElementsAreMatcherImpl< Container >::View

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

template<typename Container >
typedef internal::StlContainerView<RawContainer> testing::internal::UnorderedElementsAreMatcherImpl< Container >::View

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

template<typename Container >
typedef internal::StlContainerView<RawContainer> testing::internal::UnorderedElementsAreMatcherImpl< Container >::View

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

Constructor & Destructor Documentation

template<typename Container >
template<typename InputIter >
testing::internal::UnorderedElementsAreMatcherImpl< Container >::UnorderedElementsAreMatcherImpl ( InputIter  first,
InputIter  last 
)
inline

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

References folly::gen::first.

3359  {
3360  for (; first != last; ++first) {
3361  matchers_.push_back(MatcherCast<const Element&>(*first));
3362  matcher_describers().push_back(matchers_.back().GetDescriber());
3363  }
3364  }
constexpr detail::First first
Definition: Base-inl.h:2553
template<typename Container >
template<typename InputIter >
testing::internal::UnorderedElementsAreMatcherImpl< Container >::UnorderedElementsAreMatcherImpl ( InputIter  first,
InputIter  last 
)
inline

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

References folly::gen::first.

3359  {
3360  for (; first != last; ++first) {
3361  matchers_.push_back(MatcherCast<const Element&>(*first));
3362  matcher_describers().push_back(matchers_.back().GetDescriber());
3363  }
3364  }
constexpr detail::First first
Definition: Base-inl.h:2553
template<typename Container >
template<typename InputIter >
testing::internal::UnorderedElementsAreMatcherImpl< Container >::UnorderedElementsAreMatcherImpl ( InputIter  first,
InputIter  last 
)
inline

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

References folly::gen::first.

3359  {
3360  for (; first != last; ++first) {
3361  matchers_.push_back(MatcherCast<const Element&>(*first));
3362  matcher_describers().push_back(matchers_.back().GetDescriber());
3363  }
3364  }
constexpr detail::First first
Definition: Base-inl.h:2553

Member Function Documentation

template<typename Container >
template<typename ElementIter >
MatchMatrix testing::internal::UnorderedElementsAreMatcherImpl< Container >::AnalyzeElements ( ElementIter  elem_first,
ElementIter  elem_last,
::std::vector< string > *  element_printouts,
MatchResultListener listener 
) const
inlineprivate

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

References testing::MatchResultListener::IsInterested(), testing::Matches(), and testing::PrintToString().

3411  {
3412  element_printouts->clear();
3413  ::std::vector<char> did_match;
3414  size_t num_elements = 0;
3415  for (; elem_first != elem_last; ++num_elements, ++elem_first) {
3416  if (listener->IsInterested()) {
3417  element_printouts->push_back(PrintToString(*elem_first));
3418  }
3419  for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {
3420  did_match.push_back(Matches(matchers_[irhs])(*elem_first));
3421  }
3422  }
3423 
3424  MatchMatrix matrix(num_elements, matchers_.size());
3425  ::std::vector<char>::const_iterator did_match_iter = did_match.begin();
3426  for (size_t ilhs = 0; ilhs != num_elements; ++ilhs) {
3427  for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {
3428  matrix.SetEdge(ilhs, irhs, *did_match_iter++ != 0);
3429  }
3430  }
3431  return matrix;
3432  }
::std::string PrintToString(const T &value)
internal::MatcherAsPredicate< M > Matches(M matcher)
template<typename Container >
template<typename ElementIter >
MatchMatrix testing::internal::UnorderedElementsAreMatcherImpl< Container >::AnalyzeElements ( ElementIter  elem_first,
ElementIter  elem_last,
::std::vector< string > *  element_printouts,
MatchResultListener listener 
) const
inlineprivate

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

References GTEST_DISALLOW_ASSIGN_, testing::Matches(), testing::PrintToString(), and testing::internal::MatchMatrix::SetEdge().

3411  {
3412  element_printouts->clear();
3413  ::std::vector<char> did_match;
3414  size_t num_elements = 0;
3415  for (; elem_first != elem_last; ++num_elements, ++elem_first) {
3416  if (listener->IsInterested()) {
3417  element_printouts->push_back(PrintToString(*elem_first));
3418  }
3419  for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {
3420  did_match.push_back(Matches(matchers_[irhs])(*elem_first));
3421  }
3422  }
3423 
3424  MatchMatrix matrix(num_elements, matchers_.size());
3425  ::std::vector<char>::const_iterator did_match_iter = did_match.begin();
3426  for (size_t ilhs = 0; ilhs != num_elements; ++ilhs) {
3427  for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {
3428  matrix.SetEdge(ilhs, irhs, *did_match_iter++ != 0);
3429  }
3430  }
3431  return matrix;
3432  }
::std::string PrintToString(const T &value)
internal::MatcherAsPredicate< M > Matches(M matcher)
template<typename Container >
template<typename ElementIter >
MatchMatrix testing::internal::UnorderedElementsAreMatcherImpl< Container >::AnalyzeElements ( ElementIter  elem_first,
ElementIter  elem_last,
::std::vector< string > *  element_printouts,
MatchResultListener listener 
) const
inlineprivate

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

References GTEST_DISALLOW_ASSIGN_, testing::Matches(), testing::PrintToString(), and testing::internal::MatchMatrix::SetEdge().

3411  {
3412  element_printouts->clear();
3413  ::std::vector<char> did_match;
3414  size_t num_elements = 0;
3415  for (; elem_first != elem_last; ++num_elements, ++elem_first) {
3416  if (listener->IsInterested()) {
3417  element_printouts->push_back(PrintToString(*elem_first));
3418  }
3419  for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {
3420  did_match.push_back(Matches(matchers_[irhs])(*elem_first));
3421  }
3422  }
3423 
3424  MatchMatrix matrix(num_elements, matchers_.size());
3425  ::std::vector<char>::const_iterator did_match_iter = did_match.begin();
3426  for (size_t ilhs = 0; ilhs != num_elements; ++ilhs) {
3427  for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {
3428  matrix.SetEdge(ilhs, irhs, *did_match_iter++ != 0);
3429  }
3430  }
3431  return matrix;
3432  }
::std::string PrintToString(const T &value)
internal::MatcherAsPredicate< M > Matches(M matcher)
template<typename Container >
virtual void testing::internal::UnorderedElementsAreMatcherImpl< Container >::DescribeNegationTo ( ::std::ostream *  os) const
inlinevirtual

Reimplemented from testing::MatcherDescriberInterface.

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

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

Reimplemented from testing::MatcherDescriberInterface.

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

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

Reimplemented from testing::MatcherDescriberInterface.

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

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

Implements testing::MatcherDescriberInterface.

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

3367  {
3369  }
template<typename Container >
virtual void testing::internal::UnorderedElementsAreMatcherImpl< Container >::DescribeTo ( ::std::ostream *  os) const
inlinevirtual

Implements testing::MatcherDescriberInterface.

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

3367  {
3369  }
template<typename Container >
virtual void testing::internal::UnorderedElementsAreMatcherImpl< Container >::DescribeTo ( ::std::ostream *  os) const
inlinevirtual

Implements testing::MatcherDescriberInterface.

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

3367  {
3369  }
template<typename Container >
testing::internal::UnorderedElementsAreMatcherImpl< Container >::GTEST_DISALLOW_ASSIGN_ ( UnorderedElementsAreMatcherImpl< Container >  )
private
template<typename Container >
testing::internal::UnorderedElementsAreMatcherImpl< Container >::GTEST_DISALLOW_ASSIGN_ ( UnorderedElementsAreMatcherImpl< Container >  )
private
template<typename Container >
testing::internal::UnorderedElementsAreMatcherImpl< Container >::GTEST_DISALLOW_ASSIGN_ ( UnorderedElementsAreMatcherImpl< Container >  )
private
template<typename Container >
typedef testing::internal::UnorderedElementsAreMatcherImpl< Container >::GTEST_REMOVE_REFERENCE_AND_CONST_ ( Container  )
template<typename Container >
typedef testing::internal::UnorderedElementsAreMatcherImpl< Container >::GTEST_REMOVE_REFERENCE_AND_CONST_ ( Container  )
template<typename Container >
typedef testing::internal::UnorderedElementsAreMatcherImpl< Container >::GTEST_REMOVE_REFERENCE_AND_CONST_ ( Container  )
template<typename Container >
virtual bool testing::internal::UnorderedElementsAreMatcherImpl< Container >::MatchAndExplain ( Container  container,
MatchResultListener listener 
) const
inlinevirtual

Implements testing::MatcherInterface< Container >.

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

References testing::internal::FindPairing(), testing::MatchResultListener::IsInterested(), and testing::internal::MatchMatrix::LhsSize().

3377  {
3378  StlContainerReference stl_container = View::ConstReference(container);
3379  ::std::vector<string> element_printouts;
3380  MatchMatrix matrix = AnalyzeElements(stl_container.begin(),
3381  stl_container.end(),
3382  &element_printouts,
3383  listener);
3384 
3385  const size_t actual_count = matrix.LhsSize();
3386  if (actual_count == 0 && matchers_.empty()) {
3387  return true;
3388  }
3389  if (actual_count != matchers_.size()) {
3390  // The element count doesn't match. If the container is empty,
3391  // there's no need to explain anything as Google Mock already
3392  // prints the empty container. Otherwise we just need to show
3393  // how many elements there actually are.
3394  if (actual_count != 0 && listener->IsInterested()) {
3395  *listener << "which has " << Elements(actual_count);
3396  }
3397  return false;
3398  }
3399 
3400  return VerifyAllElementsAndMatchersAreMatched(element_printouts,
3401  matrix, listener) &&
3402  FindPairing(matrix, listener);
3403  }
static const_reference ConstReference(const RawContainer &container)
GTEST_API_ bool FindPairing(const MatchMatrix &matrix, MatchResultListener *listener)
bool VerifyAllElementsAndMatchersAreMatched(const ::std::vector< string > &element_printouts, const MatchMatrix &matrix, MatchResultListener *listener) const
MatchMatrix AnalyzeElements(ElementIter elem_first, ElementIter elem_last,::std::vector< string > *element_printouts, MatchResultListener *listener) const
template<typename Container >
virtual bool testing::internal::UnorderedElementsAreMatcherImpl< Container >::MatchAndExplain ( Container  container,
MatchResultListener listener 
) const
inlinevirtual

Implements testing::MatcherInterface< Container >.

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

References testing::internal::FindPairing(), and testing::internal::MatchMatrix::LhsSize().

3377  {
3378  StlContainerReference stl_container = View::ConstReference(container);
3379  ::std::vector<string> element_printouts;
3380  MatchMatrix matrix = AnalyzeElements(stl_container.begin(),
3381  stl_container.end(),
3382  &element_printouts,
3383  listener);
3384 
3385  const size_t actual_count = matrix.LhsSize();
3386  if (actual_count == 0 && matchers_.empty()) {
3387  return true;
3388  }
3389  if (actual_count != matchers_.size()) {
3390  // The element count doesn't match. If the container is empty,
3391  // there's no need to explain anything as Google Mock already
3392  // prints the empty container. Otherwise we just need to show
3393  // how many elements there actually are.
3394  if (actual_count != 0 && listener->IsInterested()) {
3395  *listener << "which has " << Elements(actual_count);
3396  }
3397  return false;
3398  }
3399 
3400  return VerifyAllElementsAndMatchersAreMatched(element_printouts,
3401  matrix, listener) &&
3402  FindPairing(matrix, listener);
3403  }
static const_reference ConstReference(const RawContainer &container)
GTEST_API_ bool FindPairing(const MatchMatrix &matrix, MatchResultListener *listener)
bool VerifyAllElementsAndMatchersAreMatched(const ::std::vector< string > &element_printouts, const MatchMatrix &matrix, MatchResultListener *listener) const
MatchMatrix AnalyzeElements(ElementIter elem_first, ElementIter elem_last,::std::vector< string > *element_printouts, MatchResultListener *listener) const
template<typename Container >
virtual bool testing::internal::UnorderedElementsAreMatcherImpl< Container >::MatchAndExplain ( Container  container,
MatchResultListener listener 
) const
inlinevirtual

Implements testing::MatcherInterface< Container >.

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

References testing::internal::FindPairing(), and testing::internal::MatchMatrix::LhsSize().

3377  {
3378  StlContainerReference stl_container = View::ConstReference(container);
3379  ::std::vector<string> element_printouts;
3380  MatchMatrix matrix = AnalyzeElements(stl_container.begin(),
3381  stl_container.end(),
3382  &element_printouts,
3383  listener);
3384 
3385  const size_t actual_count = matrix.LhsSize();
3386  if (actual_count == 0 && matchers_.empty()) {
3387  return true;
3388  }
3389  if (actual_count != matchers_.size()) {
3390  // The element count doesn't match. If the container is empty,
3391  // there's no need to explain anything as Google Mock already
3392  // prints the empty container. Otherwise we just need to show
3393  // how many elements there actually are.
3394  if (actual_count != 0 && listener->IsInterested()) {
3395  *listener << "which has " << Elements(actual_count);
3396  }
3397  return false;
3398  }
3399 
3400  return VerifyAllElementsAndMatchersAreMatched(element_printouts,
3401  matrix, listener) &&
3402  FindPairing(matrix, listener);
3403  }
static const_reference ConstReference(const RawContainer &container)
GTEST_API_ bool FindPairing(const MatchMatrix &matrix, MatchResultListener *listener)
bool VerifyAllElementsAndMatchersAreMatched(const ::std::vector< string > &element_printouts, const MatchMatrix &matrix, MatchResultListener *listener) const
MatchMatrix AnalyzeElements(ElementIter elem_first, ElementIter elem_last,::std::vector< string > *element_printouts, MatchResultListener *listener) const

Member Data Documentation

template<typename Container >
MatcherVec testing::internal::UnorderedElementsAreMatcherImpl< Container >::matchers_
private

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


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