void printNice(boost::test_tools::predicate_result& res, const intvector& s, const intvector& diff) { const char *c = CLR_YELLOW; res.message() << c; for (int i = 0; i < s.size(); i++) { if ((i > 0) && (i % 16 == 0)) { res.message() << CLR_NORM << "\n" << std::setfill('0') << std::setw(3) << std::hex << i << ": " << c; } if ((i >= diff.size()) || (s[i] != diff[i])) { if (c != CLR_MAG) { c = CLR_MAG; res.message() << CLR_MAG; } } else { if (c != CLR_YELLOW) { c = CLR_YELLOW; res.message() << CLR_YELLOW; } } res.message() << "\\x" << std::setfill('0') << std::setw(2) << std::hex << s[i]; } return; }
void test_main::print_wrong(boost::test_tools::predicate_result& res, const std::string& strExpected, const std::string& strResult) { res.message() << "\nExp: "; this->printNice(res, strExpected, strResult); res.message() << CLR_NORM "\n\nGot: "; this->printNice(res, strResult, strExpected); res.message() << CLR_NORM "\n"; return; }
void print_wrong(boost::test_tools::predicate_result& res, const intvector& expected, const intvector& result) { res.message() << "\nExp: "; this->printNice(res, expected, result); res.message() << CLR_NORM "\n" << "Got: "; this->printNice(res, result, expected); res.message() << CLR_NORM; return; }
void test_main::printNice(boost::test_tools::predicate_result& res, const std::string& s, const std::string& diff) { const char *c = CLR_YELLOW; res.message() << c; std::ostringstream text; text << c; unsigned int len = s.length(); for (unsigned int i = 0; i < len; i++) { if ((i > 0) && (i % this->outputWidth == 0)) { res.message() << ' ' << text.str(); //res.message() << "\" \\"; res.message() << CLR_NORM << "\n" << std::setfill('0') << std::setw(3) << std::hex << i << ": " << c; text.str(""); text.seekp(0, std::ios::beg); res.message() << c; text << c; //res.message() << "\""; } if ((i >= diff.length()) || (s[i] != diff[i])) { if (c != CLR_MAG) { c = CLR_MAG; res.message() << c; text << c; } } else { if (c != CLR_YELLOW) { c = CLR_YELLOW; res.message() << c; text << c; } } /* res.message() << "\\x" << std::setfill('0') << std::setw(2) << std::hex << (int)((uint8_t)s[i]); /*/ if ((s[i] < 32) || (s[i] == 127)) { text << '.'; } else { text << s[i]; } res.message() << std::setfill('0') << std::setw(2) << std::hex << (int)((uint8_t)s[i]) << ' '; // */ } // If the last row was only a partial one, pad it out and write the text side if (len > 0) { for (int i = ((len - 1) % this->outputWidth) + 1; i < this->outputWidth; i++) { res.message() << " "; } res.message() << ' ' << text.str(); } return; }