| 583 | } |
| 584 | |
| 585 | void testStringSimilar(const char* /*file*/, int line, |
| 586 | const std::string& string_1, |
| 587 | const char* string_1_stringified, |
| 588 | const std::string& string_2, |
| 589 | const char* string_2_stringified |
| 590 | ) |
| 591 | { |
| 592 | ++TEST::test_count; |
| 593 | TEST::test_line = line; |
| 594 | |
| 595 | TEST::fuzzy_message.clear(); |
| 596 | FuzzyStringComparator fsc; |
| 597 | fsc.setAcceptableAbsolute(absdiff_max_allowed); |
| 598 | fsc.setAcceptableRelative(ratio_max_allowed); |
| 599 | fsc.setVerboseLevel(2); |
| 600 | fsc.setWhitelist(whitelist); |
| 601 | std::ostringstream os; |
| 602 | fsc.setLogDestination(os); |
| 603 | fsc.use_prefix_ = true; |
| 604 | |
| 605 | TEST::this_test = fsc.compareStrings(string_1, string_2); |
| 606 | |
| 607 | TEST::fuzzy_message = os.str(); |
| 608 | TEST::absdiff = fsc.absdiff_max_; |
| 609 | TEST::ratio = fsc.ratio_max_; |
| 610 | TEST::line_num_1_max = fsc.line_num_1_max_; |
| 611 | TEST::line_num_2_max = fsc.line_num_2_max_; |
| 612 | |
| 613 | TEST::test = TEST::test && TEST::this_test; |
| 614 | |
| 615 | TEST::initialNewline(); |
| 616 | if (TEST::this_test) |
| 617 | { |
| 618 | if (TEST::verbose > 1) |
| 619 | { |
| 620 | stdcout << " + line " << line << ": TEST_STRING_SIMILAR(" |
| 621 | << string_1_stringified << ',' << string_2_stringified << "): " |
| 622 | "absolute: " << TEST::absdiff << " (" << TEST::absdiff_max_allowed |
| 623 | << "), relative: " << TEST::ratio << " (" |
| 624 | << TEST::ratio_max_allowed << ") +\n"; |
| 625 | stdcout << "got:\n"; |
| 626 | TEST::printWithPrefix(string_1, TEST::line_num_1_max); |
| 627 | stdcout << "expected:\n"; |
| 628 | TEST::printWithPrefix(string_2, TEST::line_num_2_max); |
| 629 | } |
| 630 | } |
| 631 | else |
| 632 | { |
| 633 | stdcout << " - line " << TEST::test_line |
| 634 | << ": TEST_STRING_SIMILAR(" << string_1_stringified << ',' |
| 635 | << string_2_stringified << ") ... -\n" |
| 636 | "got:\n"; |
| 637 | TEST::printWithPrefix(string_1, TEST::line_num_1_max); |
| 638 | stdcout << "expected:\n"; |
| 639 | TEST::printWithPrefix(string_2, TEST::line_num_2_max); |
| 640 | stdcout << "message: \n"; |
| 641 | stdcout << TEST::fuzzy_message; |
| 642 | failed_lines_list.push_back(line); |
no test coverage detected