add test case for attachment names' parsing

This commit is contained in:
GlacJAY 2015-07-15 10:09:23 +08:00
parent 596edc5385
commit f36800fb70
2 changed files with 37 additions and 0 deletions

View File

@ -431,6 +431,42 @@ void MailMessageTest::testReadMultiPart()
}
void MailMessageTest::testReadMultiPartWithAttachmentNames()
{
std::istringstream istr(
"Content-Type: multipart/mixed; boundary=MIME_boundary_01234567\r\n"
"Date: Thu, 1 Jan 1970 00:00:00 GMT\r\n"
"From: poco@appinf.com\r\n"
"Mime-Version: 1.0\r\n"
"Subject: Test Message\r\n"
"To: John Doe <john.doe@no.where>\r\n"
"\r\n"
"\r\n"
"--MIME_boundary_01234567\r\n"
"Content-Disposition: inline\r\n"
"Content-Transfer-Encoding: 8bit\r\n"
"Content-Type: text/plain\r\n"
"\r\n"
"Hello World!\r\n"
"\r\n"
"--MIME_boundary_01234567\r\n"
"Content-Disposition: attachment; filename=sample.dat\r\n"
"Content-Transfer-Encoding: base64\r\n"
"Content-Type: application/octet-stream; name=sample\r\n"
"\r\n"
"VGhpcyBpcyBzb21lIGJpbmFyeSBkYXRhLiBSZWFsbHku\r\n"
"--MIME_boundary_01234567--\r\n"
);
MailMessage message;
message.read(istr);
assert (message.parts().size() == 2);
assert (message.parts()[1].name == "sample");
assert (message.parts()[1].pSource->filename() == "sample.dat");
}
void MailMessageTest::testReadMultiPartDefaultTransferEncoding()
{
std::istringstream istr(

View File

@ -37,6 +37,7 @@ public:
void testReadQP();
void testRead8Bit();
void testReadMultiPart();
void testReadMultiPartWithAttachmentNames();
void testReadMultiPartDefaultTransferEncoding();
void testEncodeWord();