diff options
author | Vincent Richard <[email protected]> | 2013-03-18 08:35:04 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2013-03-18 08:35:04 +0000 |
commit | da2797702fe09dcf627ceed3eab27b52dacd31a9 (patch) | |
tree | fa991a26656685b60e40ef5d696207a494526e61 /tests/testUtils.cpp | |
parent | Fixed and clarified text about handleTimeout() return value. (diff) | |
download | vmime-da2797702fe09dcf627ceed3eab27b52dacd31a9.tar.gz vmime-da2797702fe09dcf627ceed3eab27b52dacd31a9.zip |
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.
Diffstat (limited to 'tests/testUtils.cpp')
-rw-r--r-- | tests/testUtils.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
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 <size_t>(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; +} |