proxygen
testing::internal::UnorderedElementsAreMatcherImplBase Class Reference

#include <gmock-matchers.h>

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

Protected Types

typedef ::std::vector< const MatcherDescriberInterface * > MatcherDescriberVec
 
typedef ::std::vector< const MatcherDescriberInterface * > MatcherDescriberVec
 
typedef ::std::vector< const MatcherDescriberInterface * > MatcherDescriberVec
 

Protected Member Functions

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

static Message Elements (size_t n)
 
static Message Elements (size_t n)
 
static Message Elements (size_t n)
 

Private Member Functions

 GTEST_DISALLOW_ASSIGN_ (UnorderedElementsAreMatcherImplBase)
 
 GTEST_DISALLOW_ASSIGN_ (UnorderedElementsAreMatcherImplBase)
 
 GTEST_DISALLOW_ASSIGN_ (UnorderedElementsAreMatcherImplBase)
 

Private Attributes

MatcherDescriberVec matcher_describers_
 

Detailed Description

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

Member Typedef Documentation

Member Function Documentation

void testing::internal::UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl ( ::std::ostream *  os) const
protected

Definition at line 416 of file gmock-matchers.cc.

References i.

417  {
418  if (matcher_describers_.empty()) {
419  *os << "isn't empty";
420  return;
421  }
422  if (matcher_describers_.size() == 1) {
423  *os << "doesn't have " << Elements(1)
424  << ", or has " << Elements(1) << " that ";
425  matcher_describers_[0]->DescribeNegationTo(os);
426  return;
427  }
428  *os << "doesn't have " << Elements(matcher_describers_.size())
429  << ", or there exists no permutation of elements such that:\n";
430  const char* sep = "";
431  for (size_t i = 0; i != matcher_describers_.size(); ++i) {
432  *os << sep << " - element #" << i << " ";
433  matcher_describers_[i]->DescribeTo(os);
434  sep = ", and\n";
435  }
436 }
void testing::internal::UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl ( ::std::ostream *  os) const
protected
void testing::internal::UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl ( ::std::ostream *  os) const
protected
void testing::internal::UnorderedElementsAreMatcherImplBase::DescribeToImpl ( ::std::ostream *  os) const
protected

Definition at line 395 of file gmock-matchers.cc.

References i.

396  {
397  if (matcher_describers_.empty()) {
398  *os << "is empty";
399  return;
400  }
401  if (matcher_describers_.size() == 1) {
402  *os << "has " << Elements(1) << " and that element ";
403  matcher_describers_[0]->DescribeTo(os);
404  return;
405  }
406  *os << "has " << Elements(matcher_describers_.size())
407  << " and there exists some permutation of elements such that:\n";
408  const char* sep = "";
409  for (size_t i = 0; i != matcher_describers_.size(); ++i) {
410  *os << sep << " - element #" << i << " ";
411  matcher_describers_[i]->DescribeTo(os);
412  sep = ", and\n";
413  }
414 }
void testing::internal::UnorderedElementsAreMatcherImplBase::DescribeToImpl ( ::std::ostream *  os) const
protected
void testing::internal::UnorderedElementsAreMatcherImplBase::DescribeToImpl ( ::std::ostream *  os) const
protected
static Message testing::internal::UnorderedElementsAreMatcherImplBase::Elements ( size_t  n)
inlinestaticprotected

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

References GTEST_DISALLOW_ASSIGN_, and GTEST_REMOVE_REFERENCE_AND_CONST_.

3333  {
3334  return Message() << n << " element" << (n == 1 ? "" : "s");
3335  }
static Message testing::internal::UnorderedElementsAreMatcherImplBase::Elements ( size_t  n)
inlinestaticprotected

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

3333  {
3334  return Message() << n << " element" << (n == 1 ? "" : "s");
3335  }
static Message testing::internal::UnorderedElementsAreMatcherImplBase::Elements ( size_t  n)
inlinestaticprotected

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

References GTEST_DISALLOW_ASSIGN_, and GTEST_REMOVE_REFERENCE_AND_CONST_.

3333  {
3334  return Message() << n << " element" << (n == 1 ? "" : "s");
3335  }
testing::internal::UnorderedElementsAreMatcherImplBase::GTEST_DISALLOW_ASSIGN_ ( UnorderedElementsAreMatcherImplBase  )
private
testing::internal::UnorderedElementsAreMatcherImplBase::GTEST_DISALLOW_ASSIGN_ ( UnorderedElementsAreMatcherImplBase  )
private
testing::internal::UnorderedElementsAreMatcherImplBase::GTEST_DISALLOW_ASSIGN_ ( UnorderedElementsAreMatcherImplBase  )
private
MatcherDescriberVec& testing::internal::UnorderedElementsAreMatcherImplBase::matcher_describers ( )
inlineprotected

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

3329  {
3330  return matcher_describers_;
3331  }
MatcherDescriberVec& testing::internal::UnorderedElementsAreMatcherImplBase::matcher_describers ( )
inlineprotected

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

3329  {
3330  return matcher_describers_;
3331  }
MatcherDescriberVec& testing::internal::UnorderedElementsAreMatcherImplBase::matcher_describers ( )
inlineprotected

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

3329  {
3330  return matcher_describers_;
3331  }
bool testing::internal::UnorderedElementsAreMatcherImplBase::VerifyAllElementsAndMatchersAreMatched ( const ::std::vector< string > &  element_printouts,
const MatchMatrix matrix,
MatchResultListener listener 
) const
protected

Definition at line 444 of file gmock-matchers.cc.

References testing::internal::MatchMatrix::HasEdge(), testing::MatchResultListener::IsInterested(), testing::internal::MatchMatrix::LhsSize(), testing::internal::MatchMatrix::RhsSize(), and testing::MatchResultListener::stream().

447  {
448  bool result = true;
449  ::std::vector<char> element_matched(matrix.LhsSize(), 0);
450  ::std::vector<char> matcher_matched(matrix.RhsSize(), 0);
451 
452  for (size_t ilhs = 0; ilhs < matrix.LhsSize(); ilhs++) {
453  for (size_t irhs = 0; irhs < matrix.RhsSize(); irhs++) {
454  char matched = matrix.HasEdge(ilhs, irhs);
455  element_matched[ilhs] |= matched;
456  matcher_matched[irhs] |= matched;
457  }
458  }
459 
460  {
461  const char* sep =
462  "where the following matchers don't match any elements:\n";
463  for (size_t mi = 0; mi < matcher_matched.size(); ++mi) {
464  if (matcher_matched[mi])
465  continue;
466  result = false;
467  if (listener->IsInterested()) {
468  *listener << sep << "matcher #" << mi << ": ";
469  matcher_describers_[mi]->DescribeTo(listener->stream());
470  sep = ",\n";
471  }
472  }
473  }
474 
475  {
476  const char* sep =
477  "where the following elements don't match any matchers:\n";
478  const char* outer_sep = "";
479  if (!result) {
480  outer_sep = "\nand ";
481  }
482  for (size_t ei = 0; ei < element_matched.size(); ++ei) {
483  if (element_matched[ei])
484  continue;
485  result = false;
486  if (listener->IsInterested()) {
487  *listener << outer_sep << sep << "element #" << ei << ": "
488  << element_printouts[ei];
489  sep = ",\n";
490  outer_sep = "";
491  }
492  }
493  }
494  return result;
495 }
bool testing::internal::UnorderedElementsAreMatcherImplBase::VerifyAllElementsAndMatchersAreMatched ( const ::std::vector< string > &  element_printouts,
const MatchMatrix matrix,
MatchResultListener listener 
) const
protected
bool testing::internal::UnorderedElementsAreMatcherImplBase::VerifyAllElementsAndMatchersAreMatched ( const ::std::vector< string > &  element_printouts,
const MatchMatrix matrix,
MatchResultListener listener 
) const
protected

Member Data Documentation

MatcherDescriberVec testing::internal::UnorderedElementsAreMatcherImplBase::matcher_describers_
private

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


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