From da2797702fe09dcf627ceed3eab27b52dacd31a9 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Mon, 18 Mar 2013 09:35:04 +0100 Subject: Updated tests for charset conversion. Added test for UTF-7 encoding availability. Added test for input buffer underflow in charsetFilteredOutputStream. Refactored charset conversion tests and removed useless tests. --- tests/testUtils.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/testUtils.cpp') diff --git a/tests/testUtils.cpp b/tests/testUtils.cpp index 56117e07..d008ed94 100644 --- a/tests/testUtils.cpp +++ b/tests/testUtils.cpp @@ -270,3 +270,39 @@ std::ostream& operator<<(std::ostream& os, const vmime::exception& e) } +const vmime::string toHex(const vmime::string str) +{ + static const char hexChars[] = "0123456789abcdef"; + + vmime::string res = "\n"; + + for (unsigned int i = 0 ; i < str.length() ; i += 16) + { + unsigned int r = std::min + (static_cast (16), str.length() - i); + + vmime::string hex; + vmime::string chr; + + for (unsigned int j = 0 ; j < r ; ++j) + { + const unsigned char c = str[i + j]; + + hex += hexChars[c / 16]; + hex += hexChars[c % 16]; + hex += " "; + + if (c >= 32 && c <= 127) + chr += c; + else + chr += '.'; + } + + for (unsigned int j = r ; j < 16 ; ++j) + hex += " "; + + res += hex + " " + chr + "\n"; + } + + return res; +} -- cgit v1.2.3