Skip to content

Commit

Permalink
add test case for attachment names' parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
glacjay committed Jul 15, 2015
1 parent 596edc5 commit f36800f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Net/testsuite/src/MailMessageTest.cpp
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions Net/testsuite/src/MailMessageTest.h
Expand Up @@ -37,6 +37,7 @@ class MailMessageTest: public CppUnit::TestCase
void testReadQP();
void testRead8Bit();
void testReadMultiPart();
void testReadMultiPartWithAttachmentNames();
void testReadMultiPartDefaultTransferEncoding();
void testEncodeWord();

Expand Down

0 comments on commit f36800f

Please sign in to comment.