void testStringSimilar(const char* /*file*/, int line, const std::string& string_1, const char* string_1_stringified, const std::string& string_2, const char* string_2_stringified ) { ++TEST::test_count; TEST::test_line = line; TEST::fuzzy_message.clear(); FuzzyStringComparator fsc; fsc.setAcceptableAbsolute(absdiff_max_allowed); fsc.setAcceptableRelative(ratio_max_allowed); fsc.setVerboseLevel(2); fsc.setWhitelist(whitelist); std::ostringstream os; fsc.setLogDestination(os); fsc.use_prefix_ = true; TEST::this_test = fsc.compareStrings(string_1, string_2); TEST::fuzzy_message = os.str(); TEST::absdiff = fsc.absdiff_max_; TEST::ratio = fsc.ratio_max_; TEST::line_num_1_max = fsc.line_num_1_max_; TEST::line_num_2_max = fsc.line_num_2_max_; TEST::test = TEST::test && TEST::this_test; TEST::initialNewline(); if (TEST::this_test) { std__cout << " + line " << line << ": TEST_STRING_SIMILAR(" << string_1_stringified << ',' << string_2_stringified << "): " "absolute: " << TEST::absdiff << " (" << TEST::absdiff_max_allowed << "), relative: " << TEST::ratio << " (" << TEST::ratio_max_allowed << ") +\n"; std__cout << "got:\n"; TEST::printWithPrefix(string_1, TEST::line_num_1_max); std__cout << "expected:\n"; TEST::printWithPrefix(string_2, TEST::line_num_2_max); } else { std__cout << " - line " << TEST::test_line << ": TEST_STRING_SIMILAR(" << string_1_stringified << ',' << string_2_stringified << ") ... -\n" "got:\n"; TEST::printWithPrefix(string_1, TEST::line_num_1_max); std__cout << "expected:\n"; TEST::printWithPrefix(string_2, TEST::line_num_2_max); std__cout << "message: \n"; std__cout << TEST::fuzzy_message; failed_lines_list.push_back(line); } }
bool isFileSimilar(const std::string& filename_1, const std::string& filename_2) { fuzzy_message.clear(); FuzzyStringComparator fsc; fsc.setAcceptableAbsolute(absdiff_max_allowed); fsc.setAcceptableRelative(ratio_max_allowed); fsc.setVerboseLevel(2); fsc.setWhitelist(whitelist); std::ostringstream os; fsc.setLogDestination(os); fsc.use_prefix_ = true; bool result = fsc.compareFiles(filename_1, filename_2); fuzzy_message = os.str(); absdiff = fsc.absdiff_max_; ratio = fsc.ratio_max_; line_num_1_max = fsc.line_num_1_max_; line_num_2_max = fsc.line_num_2_max_; return result; }