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}