diff options
author | Don Sanders <don.sanders@nokia.com> | 2012-01-02 13:42:14 +0200 |
---|---|---|
committer | Don Sanders <don.sanders@nokia.com> | 2012-01-02 13:42:14 +0200 |
commit | 2984d83d1d82fd3dd96ed28975053d9e2015b995 (patch) | |
tree | eb95f8ba42118f494a376dfff90c4758575f7919 | |
parent | 1be06140d7c0f4e976a934f79609d24d5535a04b (diff) |
Make unit tests more robust and lower utf in content-type params.2011W52
Follow up fix for NB#294947.
Make unit tests more robust by making content-type header field
parameter testing case insensitive.
Also lower case "utf-8" in input text, as an expedient measure
to ensure unit tests pass. It's only use for content-type charset
parameter and that specific text is case insensitive.
-rw-r--r-- | tests/tst_qmailmessage/tst_qmailmessage.cpp | 18 | ||||
-rw-r--r-- | tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp | 12 | ||||
-rw-r--r-- | tests/tst_qmailmessagepart/tst_qmailmessagepart.cpp | 8 |
3 files changed, 19 insertions, 19 deletions
diff --git a/tests/tst_qmailmessage/tst_qmailmessage.cpp b/tests/tst_qmailmessage/tst_qmailmessage.cpp index b8f4f932..b415e064 100644 --- a/tests/tst_qmailmessage/tst_qmailmessage.cpp +++ b/tests/tst_qmailmessage/tst_qmailmessage.cpp @@ -273,7 +273,7 @@ void tst_QMailMessage::toRfc2822_data() /* to */ << toAddressList /* subject */ << "Test" /* time_stamp */ << "Fri, 21 Nov 1997 09:55:06 -0600" - /* content_type */ << QByteArray("text/plain; charset=UTF-8") + /* content_type */ << QByteArray("text/plain; charset=utf-8") /* plain_text */ << "Plain text." /* text_parts */ << QList<pair_type>() /* rfc_header_text */ << QByteArray( @@ -281,7 +281,7 @@ void tst_QMailMessage::toRfc2822_data() "To: =?UTF-8?B?2LbZqdql2rQ=?= <address@test>, mary@example.net" CRLF "Subject: Test" CRLF "Date: Fri, 21 Nov 1997 09:55:06 -0600" CRLF -"Content-Type: text/plain; charset=UTF-8" CRLF +"Content-Type: text/plain; charset=utf-8" CRLF "<ENCODING>" "MIME-Version: 1.0" CRLF ) /* rfc_body_text */ << QByteArray( @@ -1237,7 +1237,7 @@ void tst_QMailMessage::multiMultipart() type = "text/plain; charset=UTF-8"; data = "P1: This is a plain text part.", p1.setBody(QMailMessageBody::fromData(data, QMailMessageContentType(type), QMailMessageBody::EightBit, QMailMessageBody::RequiresEncoding)); - QCOMPARE( p1.contentType().toString(), QByteArray("Content-Type: text/plain; charset=UTF-8") ); + QCOMPARE( p1.contentType().toString().toLower(), QByteArray("Content-Type: text/plain; charset=UTF-8").toLower() ); QCOMPARE( p1.transferEncoding(), QMailMessageBody::EightBit ); QCOMPARE( p1.partCount(), static_cast<uint>(0) ); for (uint i = 0; i < p1.partCount(); ++i) @@ -1262,14 +1262,14 @@ void tst_QMailMessage::multiMultipart() #endif "</html>"; p3.setBody(QMailMessageBody::fromData(data, QMailMessageContentType(type), QMailMessageBody::EightBit, QMailMessageBody::RequiresEncoding)); - QCOMPARE( p3.contentType().toString(), QByteArray("Content-Type: text/html; charset=UTF-8") ); + QCOMPARE( p3.contentType().toString().toLower(), QByteArray("Content-Type: text/html; charset=UTF-8").toLower() ); QCOMPARE( p3.transferEncoding(), QMailMessageBody::EightBit ); QMailMessagePart p4; type = "text/plain;\n charset=\"ISO-8859-1\""; data = "P4: This is a plain text part that should be referenced by p3..."; p4.setBody(QMailMessageBody::fromData(data, QMailMessageContentType(type), QMailMessageBody::EightBit, QMailMessageBody::RequiresEncoding)); - QCOMPARE( p4.contentType().toString(), QByteArray("Content-Type: text/plain; charset=ISO-8859-1") ); + QCOMPARE( p4.contentType().toString().toLower(), QByteArray("Content-Type: text/plain; charset=ISO-8859-1").toLower() ); QCOMPARE( p4.transferEncoding(), QMailMessageBody::EightBit ); QMailMessagePart p5; @@ -1279,7 +1279,7 @@ void tst_QMailMessage::multiMultipart() #else p5.setBody(QMailMessageBody::fromFile("/etc/hosts", QMailMessageContentType(type), QMailMessageBody::SevenBit, QMailMessageBody::RequiresEncoding)); #endif - QCOMPARE( p5.contentType().toString(), QByteArray("Content-Type: text/plain; charset=us-ascii") ); + QCOMPARE( p5.contentType().toString().toLower(), QByteArray("Content-Type: text/plain; charset=us-ascii").toLower() ); QCOMPARE( p5.transferEncoding(), QMailMessageBody::SevenBit ); p2.setMultipartType(QMailMessagePartContainer::MultipartRelated); @@ -1288,7 +1288,7 @@ void tst_QMailMessage::multiMultipart() #ifndef FIT_MESSAGE_WITHIN_QDEBUG_LIMIT p2.appendPart(p5); #endif - QCOMPARE( p2.contentType().toString(), QByteArray("Content-Type: multipart/related") ); + QCOMPARE( p2.contentType().toString().toLower(), QByteArray("Content-Type: multipart/related").toLower() ); QCOMPARE( p2.transferEncoding(), QMailMessageBody::NoEncoding ); #ifndef FIT_MESSAGE_WITHIN_QDEBUG_LIMIT QCOMPARE( p2.partCount(), static_cast<uint>(3) ); @@ -1306,7 +1306,7 @@ void tst_QMailMessage::multiMultipart() m.setMultipartType(QMailMessagePartContainer::MultipartAlternative); m.appendPart(p1); m.appendPart(p2); - QCOMPARE( m.contentType().toString(), QByteArray("Content-Type: multipart/alternative") ); + QCOMPARE( m.contentType().toString().toLower(), QByteArray("Content-Type: multipart/alternative").toLower() ); QCOMPARE( m.transferEncoding(), QMailMessageBody::NoEncoding ); QCOMPARE( m.partCount(), static_cast<uint>(2) ); for (uint i = 0; i < m.partCount(); ++i) @@ -1359,7 +1359,7 @@ void tst_QMailMessage::multiMultipart() QMailMessage m4 = QMailMessage::fromRfc2822(identity); - QCOMPARE( m4.contentType().toString(), m.contentType().toString() ); + QCOMPARE( m4.contentType().toString().toLower(), m.contentType().toString().toLower() ); QCOMPARE( m4.transferEncoding(), m.transferEncoding() ); QCOMPARE( m4.partCount(), m.partCount() ); for (uint i = 0; i < m.partCount(); ++i) { diff --git a/tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp b/tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp index 99e82923..9a553f36 100644 --- a/tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp +++ b/tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp @@ -546,9 +546,9 @@ void tst_QMailMessageBody::fromFile() QCOMPARE( body.data( QMailMessageBody::Encoded ), encoded ); QCOMPARE( body.data(), string_decoded ); - QCOMPARE( body.contentType().type(), content_properties[0].toLatin1() ); - QCOMPARE( body.contentType().subType(), content_properties[1].toLatin1() ); - QCOMPARE( body.contentType().charset(), content_properties[2].toLatin1() ); + QCOMPARE( body.contentType().type().toLower(), content_properties[0].toLatin1().toLower() ); + QCOMPARE( body.contentType().subType().toLower(), content_properties[1].toLatin1().toLower() ); + QCOMPARE( body.contentType().charset().toLower(), content_properties[2].toLatin1().toLower() ); } else { @@ -563,9 +563,9 @@ void tst_QMailMessageBody::fromFile() QCOMPARE( body.data( QMailMessageBody::Encoded ), encoded ); QCOMPARE( body.data( QMailMessageBody::Decoded ), bytearray_decoded ); - QCOMPARE( body.contentType().type(), content_properties[0].toLatin1() ); - QCOMPARE( body.contentType().subType(), content_properties[1].toLatin1() ); - QCOMPARE( body.contentType().charset(), content_properties[2].toLatin1() ); + QCOMPARE( body.contentType().type().toLower(), content_properties[0].toLatin1().toLower() ); + QCOMPARE( body.contentType().subType().toLower(), content_properties[1].toLatin1().toLower() ); + QCOMPARE( body.contentType().charset().toLower(), content_properties[2].toLatin1().toLower() ); } } diff --git a/tests/tst_qmailmessagepart/tst_qmailmessagepart.cpp b/tests/tst_qmailmessagepart/tst_qmailmessagepart.cpp index 5b19d754..8565de51 100644 --- a/tests/tst_qmailmessagepart/tst_qmailmessagepart.cpp +++ b/tests/tst_qmailmessagepart/tst_qmailmessagepart.cpp @@ -360,7 +360,7 @@ void tst_QMailMessagePart::testSerialization() p1.setContentID("P1"); p1.setContentLocation("After the header"); p1.setContentDescription("The first part"); - QCOMPARE( p1.contentType().toString(), QByteArray("Content-Type: text/plain; charset=us-ascii") ); + QCOMPARE( p1.contentType().toString().toLower(), QByteArray("Content-Type: text/plain; charset=us-ascii").toLower() ); QCOMPARE( p1.transferEncoding(), QMailMessageBody::SevenBit ); type = "text/html; charset=UTF-8"; @@ -372,7 +372,7 @@ void tst_QMailMessagePart::testSerialization() QMailMessagePart p2; p2.setBody(QMailMessageBody::fromData(data, ct, QMailMessageBody::EightBit, QMailMessageBody::RequiresEncoding)); p2.setContentDisposition(cd); - QCOMPARE( p2.contentType().toString(), QByteArray("Content-Type: text/html; charset=UTF-8; name=P2") ); + QCOMPARE( p2.contentType().toString().toLower(), QByteArray("Content-Type: text/html; charset=UTF-8; name=P2").toLower() ); QCOMPARE( p2.transferEncoding(), QMailMessageBody::EightBit ); QMailMessage m; @@ -383,7 +383,7 @@ void tst_QMailMessagePart::testSerialization() m.setMultipartType(QMailMessagePartContainer::MultipartAlternative); m.appendPart(p1); m.appendPart(p2); - QCOMPARE( m.contentType().toString(), QByteArray("Content-Type: multipart/alternative") ); + QCOMPARE( m.contentType().toString().toLower(), QByteArray("Content-Type: multipart/alternative").toLower() ); QCOMPARE( m.transferEncoding(), QMailMessageBody::NoEncoding ); const QByteArray expected( @@ -404,7 +404,7 @@ CRLF CRLF "P1: This is a plain text part." CRLF "--" BOUNDARY CRLF -"Content-Type: text/html; charset=UTF-8; name=P2" CRLF +"Content-Type: text/html; charset=utf-8; name=P2" CRLF "Content-Transfer-Encoding: 8bit" CRLF "Content-Disposition: inline; filename=p2.html" CRLF CRLF |