Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
testing::internal::UnorderedElementsAreMatcherImplBase Class Reference

#include <gmock-matchers.h>

Inheritance diagram for testing::internal::UnorderedElementsAreMatcherImplBase:

Protected Types

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

Protected Member Functions

 UnorderedElementsAreMatcherImplBase (UnorderedMatcherRequire::Flags matcher_flags)
 
void DescribeToImpl (::std::ostream *os) const
 
void DescribeNegationToImpl (::std::ostream *os) const
 
bool VerifyMatchMatrix (const ::std::vector< std::string > &element_printouts, const MatchMatrix &matrix, MatchResultListener *listener) const
 
bool FindPairing (const MatchMatrix &matrix, MatchResultListener *listener) const
 
MatcherDescriberVecmatcher_describers ()
 
UnorderedMatcherRequire::Flags match_flags () const
 

Static Protected Member Functions

static Message Elements (size_t n)
 

Detailed Description

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

Member Typedef Documentation

◆ MatcherDescriberVec

Constructor & Destructor Documentation

◆ UnorderedElementsAreMatcherImplBase()

testing::internal::UnorderedElementsAreMatcherImplBase::UnorderedElementsAreMatcherImplBase ( UnorderedMatcherRequire::Flags matcher_flags)
inlineexplicitprotected

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

3672 : match_flags_(matcher_flags) {}

Member Function Documentation

◆ DescribeNegationToImpl()

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

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

436 {
437 switch (match_flags()) {
439 if (matcher_describers_.empty()) {
440 *os << "isn't empty";
441 return;
442 }
443 if (matcher_describers_.size() == 1) {
444 *os << "doesn't have " << Elements(1) << ", or has " << Elements(1)
445 << " that ";
446 matcher_describers_[0]->DescribeNegationTo(os);
447 return;
448 }
449 *os << "doesn't have " << Elements(matcher_describers_.size())
450 << ", or there exists no permutation of elements such that:\n";
451 break;
453 *os << "no surjection from elements to requirements exists such that:\n";
454 break;
456 *os << "no injection from elements to requirements exists such that:\n";
457 break;
458 }
459 const char* sep = "";
460 for (size_t i = 0; i != matcher_describers_.size(); ++i) {
461 *os << sep;
463 *os << " - element #" << i << " ";
464 } else {
465 *os << " - an element ";
466 }
467 matcher_describers_[i]->DescribeTo(os);
469 sep = ", and\n";
470 } else {
471 sep = "\n";
472 }
473 }
474}
UnorderedMatcherRequire::Flags match_flags() const
os_t os
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DescribeToImpl()

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

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

395 {
396 switch (match_flags()) {
398 if (matcher_describers_.empty()) {
399 *os << "is empty";
400 return;
401 }
402 if (matcher_describers_.size() == 1) {
403 *os << "has " << Elements(1) << " and that element ";
404 matcher_describers_[0]->DescribeTo(os);
405 return;
406 }
407 *os << "has " << Elements(matcher_describers_.size())
408 << " and there exists some permutation of elements such that:\n";
409 break;
411 *os << "a surjection from elements to requirements exists such that:\n";
412 break;
414 *os << "an injection from elements to requirements exists such that:\n";
415 break;
416 }
417
418 const char* sep = "";
419 for (size_t i = 0; i != matcher_describers_.size(); ++i) {
420 *os << sep;
422 *os << " - element #" << i << " ";
423 } else {
424 *os << " - an element ";
425 }
426 matcher_describers_[i]->DescribeTo(os);
428 sep = ", and\n";
429 } else {
430 sep = "\n";
431 }
432 }
433}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Elements()

static Message testing::internal::UnorderedElementsAreMatcherImplBase::Elements ( size_t n)
inlinestaticprotected

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

3696 {
3697 return Message() << n << " element" << (n == 1 ? "" : "s");
3698 }
Here is the caller graph for this function:

◆ FindPairing()

bool testing::internal::UnorderedElementsAreMatcherImplBase::FindPairing ( const MatchMatrix & matrix,
MatchResultListener * listener ) const
protected

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

532 {
534
535 size_t max_flow = matches.size();
537 max_flow < matrix.RhsSize()) {
538 if (listener->IsInterested()) {
539 *listener << "where no permutation of the elements can satisfy all "
540 "matchers, and the closest match is "
541 << max_flow << " of " << matrix.RhsSize()
542 << " matchers with the pairings:\n";
543 LogElementMatcherPairVec(matches, listener->stream());
544 }
545 return false;
546 }
548 max_flow < matrix.LhsSize()) {
549 if (listener->IsInterested()) {
550 *listener
551 << "where not all elements can be matched, and the closest match is "
552 << max_flow << " of " << matrix.RhsSize()
553 << " matchers with the pairings:\n";
554 LogElementMatcherPairVec(matches, listener->stream());
555 }
556 return false;
557 }
558
559 if (matches.size() > 1) {
560 if (listener->IsInterested()) {
561 const char* sep = "where:\n";
562 for (size_t mi = 0; mi < matches.size(); ++mi) {
563 *listener << sep << " - element #" << matches[mi].first
564 << " is matched by matcher #" << matches[mi].second;
565 sep = ",\n";
566 }
567 }
568 }
569 return true;
570}
::std::vector< ElementMatcherPair > ElementMatcherPairs
GTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix &g)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ match_flags()

UnorderedMatcherRequire::Flags testing::internal::UnorderedElementsAreMatcherImplBase::match_flags ( ) const
inlineprotected

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

3700{ return match_flags_; }
Here is the caller graph for this function:

◆ matcher_describers()

MatcherDescriberVec & testing::internal::UnorderedElementsAreMatcherImplBase::matcher_describers ( )
inlineprotected

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

3692 {
3693 return matcher_describers_;
3694 }
Here is the caller graph for this function:

◆ VerifyMatchMatrix()

bool testing::internal::UnorderedElementsAreMatcherImplBase::VerifyMatchMatrix ( const ::std::vector< std::string > & element_printouts,
const MatchMatrix & matrix,
MatchResultListener * listener ) const
protected

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

483 {
484 bool result = true;
485 ::std::vector<char> element_matched(matrix.LhsSize(), 0);
486 ::std::vector<char> matcher_matched(matrix.RhsSize(), 0);
487
488 for (size_t ilhs = 0; ilhs < matrix.LhsSize(); ilhs++) {
489 for (size_t irhs = 0; irhs < matrix.RhsSize(); irhs++) {
490 char matched = matrix.HasEdge(ilhs, irhs);
491 element_matched[ilhs] |= matched;
492 matcher_matched[irhs] |= matched;
493 }
494 }
495
497 const char* sep =
498 "where the following matchers don't match any elements:\n";
499 for (size_t mi = 0; mi < matcher_matched.size(); ++mi) {
500 if (matcher_matched[mi]) continue;
501 result = false;
502 if (listener->IsInterested()) {
503 *listener << sep << "matcher #" << mi << ": ";
504 matcher_describers_[mi]->DescribeTo(listener->stream());
505 sep = ",\n";
506 }
507 }
508 }
509
511 const char* sep =
512 "where the following elements don't match any matchers:\n";
513 const char* outer_sep = "";
514 if (!result) {
515 outer_sep = "\nand ";
516 }
517 for (size_t ei = 0; ei < element_matched.size(); ++ei) {
518 if (element_matched[ei]) continue;
519 result = false;
520 if (listener->IsInterested()) {
521 *listener << outer_sep << sep << "element #" << ei << ": "
522 << element_printouts[ei];
523 sep = ",\n";
524 outer_sep = "";
525 }
526 }
527 }
528 return result;
529}
Here is the call graph for this function:
Here is the caller graph for this function:

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