diff options
author | Vincent Richard <[email protected]> | 2005-10-20 16:56:04 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2005-10-20 16:56:04 +0000 |
commit | c241f071d26823ce2b6140c2687dcb750f6dfc29 (patch) | |
tree | 7bd0762a15665a1500cfe6ee63901e92972b9a66 /tests/parser/charsetTest.cpp | |
parent | Added 'charsetFilteredOutputStream'. (diff) | |
download | vmime-c241f071d26823ce2b6140c2687dcb750f6dfc29.tar.gz vmime-c241f071d26823ce2b6140c2687dcb750f6dfc29.zip |
Added flush() on 'outputStream' + added unit tests for 'charsetFilteredOutputStream' when input contains invalid sequences.
Diffstat (limited to 'tests/parser/charsetTest.cpp')
-rw-r--r-- | tests/parser/charsetTest.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/parser/charsetTest.cpp b/tests/parser/charsetTest.cpp index 02360e8a..c4787791 100644 --- a/tests/parser/charsetTest.cpp +++ b/tests/parser/charsetTest.cpp @@ -101,6 +101,9 @@ VMIME_TEST_SUITE_BEGIN VMIME_TEST(testFilterValid2) VMIME_TEST(testFilterValid3) + // Test invalid input + VMIME_TEST(testFilterInvalid1) + // TODO: more tests VMIME_TEST_LIST_END @@ -130,6 +133,8 @@ VMIME_TEST_SUITE_BEGIN vmime::charset::convert (is, os, inputCharset, outputCharset); + os.flush(); + VASSERT_EQ("1", toHex(expectedOut), toHex(actualOut)); } @@ -148,6 +153,8 @@ VMIME_TEST_SUITE_BEGIN vmime::utility::bufferedStreamCopy(is, os); + os.flush(); + VASSERT_EQ("1", toHex(expectedOut), toHex(actualOut)); } @@ -169,6 +176,8 @@ VMIME_TEST_SUITE_BEGIN for (int i = 0 ; !is.eof() ; ++i) os.write(buffer, is.read(buffer, 1)); + os.flush(); + VASSERT_EQ("1", toHex(expectedOut), toHex(actualOut)); } @@ -190,6 +199,31 @@ VMIME_TEST_SUITE_BEGIN for (int i = 0 ; !is.eof() ; ++i) os.write(buffer, is.read(buffer, (i % 5) + 1)); + os.flush(); + + VASSERT_EQ("1", toHex(expectedOut), toHex(actualOut)); + } + + void testFilterInvalid1() + { + vmime::string in("foo\xab\xcd\xef bar"); + vmime::string expectedOut("foo??? bar"); + + vmime::string actualOut; + vmime::utility::outputStreamStringAdapter osa(actualOut); + vmime::utility::charsetFilteredOutputStream os + (vmime::charset("utf-8"), + vmime::charset("iso-8859-1"), osa); + + vmime::utility::inputStreamStringAdapter is(in); + + vmime::utility::stream::value_type buffer[16]; + + for (int i = 0 ; !is.eof() ; ++i) + os.write(buffer, is.read(buffer, 1)); + + os.flush(); + VASSERT_EQ("1", toHex(expectedOut), toHex(actualOut)); } |