summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChris Adams <chris.adams@qinetic.com.au>2021-01-18 15:29:32 +1000
committerChris Adams <chris.adams@qinetic.com.au>2021-04-08 10:38:51 +1000
commit7fb656e1e3741c17e6cd92fda4cdedb83883ff2f (patch)
treeb9f2b14f35a4b181808fdc159767da807cdb1f2c /tests
parenta8db671f00ebf5aa56e57d1bdf1511d9af22c809 (diff)
Fix QChar from unicode value conversions
Change-Id: I834645859e56a793f875892b038467c5d48291ef Reviewed-by: Christopher Adams <chris.adams@jolla.com> Reviewed-by: David Llewellyn-Jones <david.llewellyn-jones@jolla.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/tst_python_email/tst_python_email.cpp19
-rw-r--r--tests/tst_qmailcodec/tst_qmailcodec.cpp10
-rw-r--r--tests/tst_qmailmessage/tst_qmailmessage.cpp3
-rw-r--r--tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp9
-rw-r--r--tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp17
5 files changed, 46 insertions, 12 deletions
diff --git a/tests/tst_python_email/tst_python_email.cpp b/tests/tst_python_email/tst_python_email.cpp
index 25965eb2..1eb8e570 100644
--- a/tests/tst_python_email/tst_python_email.cpp
+++ b/tests/tst_python_email/tst_python_email.cpp
@@ -589,7 +589,24 @@ void tst_python_email::test_long_nonstring()
// Python appears to identify runs of single-byte characters within unicode strings, and
// output them in quoted-printable encoded-words. We don't do that.
- QChar chars[] = { 0x6b63, 0x78ba, 0x306b, 0x8a00, 0x3046, 0x3068, 0x7ffb, 0x8a33, 0x306f, 0x3055, 0x308c, 0x3066, 0x3044, 0x307e, 0x305b, 0x3093, 0x3002, 0x4e00, 0x90e8, 0x306f, 0x30c9, 0x30a4, 0x30c4, 0x8a9e, 0x3067, 0x3059, 0x304c, 0x3001, 0x3042, 0x3068, 0x306f, 0x3067, 0x305f, 0x3089, 0x3081, 0x3067, 0x3059, 0x3002, 0x5b9f, 0x969b, 0x306b, 0x306f, 0x300c, 'W', 'e', 'n', 'n', ' ', 'i', 's', 't', ' ', 'd', 'a', 's', ' ', 'N', 'u', 'n', 's', 't', 'u', 'c', 'k', ' ', 'g', 'i', 't', ' ', 'u', 'n', 'd', ' ', 'S', 'l', 'o', 't', 'e', 'r', 'm', 'e', 'y', 'e', 'r', '?', ' ', 'J', 'a', '!', ' ', 'B', 'e', 'i', 'h', 'e', 'r', 'h', 'u', 'n', 'd', ' ', 'd', 'a', 's', ' ', 'O', 'd', 'e', 'r', ' ', 'd', 'i', 'e', ' ', 'F', 'l', 'i', 'p', 'p', 'e', 'r', 'w', 'a', 'l', 'd', 't', ' ', 'g', 'e', 'r', 's', 'p', 'u', 't', '.', 0x300d, 0x3068, 0x8a00, 0x3063, 0x3066, 0x3044, 0x307e, 0x3059, 0x3002 };
+ QChar chars[] = { static_cast<char16_t>(0x6b63), static_cast<char16_t>(0x78ba), static_cast<char16_t>(0x306b), static_cast<char16_t>(0x8a00),
+ static_cast<char16_t>(0x3046), static_cast<char16_t>(0x3068), static_cast<char16_t>(0x7ffb), static_cast<char16_t>(0x8a33),
+ static_cast<char16_t>(0x306f), static_cast<char16_t>(0x3055), static_cast<char16_t>(0x308c), static_cast<char16_t>(0x3066),
+ static_cast<char16_t>(0x3044), static_cast<char16_t>(0x307e), static_cast<char16_t>(0x305b), static_cast<char16_t>(0x3093),
+ static_cast<char16_t>(0x3002), static_cast<char16_t>(0x4e00), static_cast<char16_t>(0x90e8), static_cast<char16_t>(0x306f),
+ static_cast<char16_t>(0x30c9), static_cast<char16_t>(0x30a4), static_cast<char16_t>(0x30c4), static_cast<char16_t>(0x8a9e),
+ static_cast<char16_t>(0x3067), static_cast<char16_t>(0x3059), static_cast<char16_t>(0x304c), static_cast<char16_t>(0x3001),
+ static_cast<char16_t>(0x3042), static_cast<char16_t>(0x3068), static_cast<char16_t>(0x306f), static_cast<char16_t>(0x3067),
+ static_cast<char16_t>(0x305f), static_cast<char16_t>(0x3089), static_cast<char16_t>(0x3081), static_cast<char16_t>(0x3067),
+ static_cast<char16_t>(0x3059), static_cast<char16_t>(0x3002), static_cast<char16_t>(0x5b9f), static_cast<char16_t>(0x969b),
+ static_cast<char16_t>(0x306b), static_cast<char16_t>(0x306f), static_cast<char16_t>(0x300c),
+ 'W', 'e', 'n', 'n', ' ', 'i', 's', 't', ' ', 'd', 'a', 's', ' ', 'N', 'u', 'n', 's', 't', 'u', 'c', 'k', ' ', 'g', 'i', 't',
+ ' ', 'u', 'n', 'd', ' ', 'S', 'l', 'o', 't', 'e', 'r', 'm', 'e', 'y', 'e', 'r', '?', ' ', 'J', 'a', '!', ' ', 'B', 'e', 'i',
+ 'h', 'e', 'r', 'h', 'u', 'n', 'd', ' ', 'd', 'a', 's', ' ', 'O', 'd', 'e', 'r', ' ', 'd', 'i', 'e', ' ', 'F', 'l', 'i', 'p',
+ 'p', 'e', 'r', 'w', 'a', 'l', 'd', 't', ' ', 'g', 'e', 'r', 's', 'p', 'u', 't', '.',
+ static_cast<char16_t>(0x300d), static_cast<char16_t>(0x3068), static_cast<char16_t>(0x8a00), static_cast<char16_t>(0x3063),
+ static_cast<char16_t>(0x3066), static_cast<char16_t>(0x3044), static_cast<char16_t>(0x307e), static_cast<char16_t>(0x3059),
+ static_cast<char16_t>(0x3002) };
original = QString(chars, sizeof(chars) / sizeof(chars[0]));
input.append(' ').append(QMailMessageHeaderField::encodeWord(original, "UTF-8"));
diff --git a/tests/tst_qmailcodec/tst_qmailcodec.cpp b/tests/tst_qmailcodec/tst_qmailcodec.cpp
index 8dff3d1b..302a33d0 100644
--- a/tests/tst_qmailcodec/tst_qmailcodec.cpp
+++ b/tests/tst_qmailcodec/tst_qmailcodec.cpp
@@ -131,7 +131,10 @@ void tst_QMailCodec::encode_data()
<< QByteArray("=23abc_xyz_ABC_XYZ_01_89");
// Test with some arabic characters, as per http://en.wikipedia.org/wiki/List_of_Unicode_characters
- const QChar chars[] = { 0x0636, 0x0020, 0x0669, 0x0009, 0x06a5, 0x0020, 0x06b4 };
+ const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0020),
+ static_cast<char16_t>(0x0669), static_cast<char16_t>(0x0009),
+ static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x0020),
+ static_cast<char16_t>(0x06b4) };
QTest::newRow("unicode characters")
<< QString(chars, 7)
<< "UTF-8"
@@ -689,7 +692,10 @@ void tst_QMailCodec::embedded_newlines()
void tst_QMailCodec::encodeDecodeModifiedUtf7()
{
// Test with some arabic characters, as per http://en.wikipedia.org/wiki/List_of_Unicode_characters
- const QChar arabicChars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4, 0x06a5, 0x0669, 0x0636};
+ const QChar arabicChars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669),
+ static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4),
+ static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x0669),
+ static_cast<char16_t>(0x0636) };
QStringList arabicEncoded = QStringList()
<< QString::fromLatin1("&BjY-")
<< QString::fromLatin1("&BjYGaQ-")
diff --git a/tests/tst_qmailmessage/tst_qmailmessage.cpp b/tests/tst_qmailmessage/tst_qmailmessage.cpp
index ad9d2883..21f33cc0 100644
--- a/tests/tst_qmailmessage/tst_qmailmessage.cpp
+++ b/tests/tst_qmailmessage/tst_qmailmessage.cpp
@@ -275,7 +275,8 @@ void tst_QMailMessage::toRfc2822_data()
QString latin1Address(QString::fromLatin1("\"Joh\361 D\366e\" <jdoe@example.net>"));
// Test with some arabic characters, as per http://en.wikipedia.org/wiki/List_of_Unicode_characters
- const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 };
+ const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669),
+ static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) };
QString unicodeAddress(chars, 4);
unicodeAddress.append(" <address@test>");
diff --git a/tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp b/tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp
index 4983541a..0c2cd704 100644
--- a/tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp
+++ b/tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp
@@ -275,7 +275,8 @@ void tst_QMailMessageBody::fromQString_data()
<< source;
// Unicode Characters
- const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 };
+ const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669),
+ static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) };
source = QString(chars, 4);
QTest::newRow("unicode - base64")
<< source
@@ -482,7 +483,8 @@ void tst_QMailMessageBody::fromFile_data()
<< ( QStringList() << "text" << "plain" << "ISO-8859-1" );
// Unicode Characters
- const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 };
+ const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669),
+ static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) };
string_source = QString(chars, 4);
QTest::newRow("unicode - string - base64")
<< string_source
@@ -645,7 +647,8 @@ void tst_QMailMessageBody::toFile_data()
<< encode(bytearray_source, QMailMessageBody::Base64);
// Unicode Characters
- const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 };
+ const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669),
+ static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) };
string_source = QString(chars, 4);
QTest::newRow("unicode - string - decoded")
diff --git a/tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp b/tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp
index 34d8ae63..64d41174 100644
--- a/tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp
+++ b/tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp
@@ -715,7 +715,8 @@ void tst_QMailMessageHeaderField::decodedContent_data()
QTest::addColumn<QString>("result");
// Test with some arabic characters, as per http://en.wikipedia.org/wiki/List_of_Unicode_characters
- const QChar arabicChars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 };
+ const QChar arabicChars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669),
+ static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) };
QString unicodeAddress(arabicChars, 4);
unicodeAddress.append(" <address@example>");
@@ -735,7 +736,10 @@ void tst_QMailMessageHeaderField::decodedContent_data()
input = "=?UTF-8?B?2LYg2akJ2qUg2rQ=?=; param=UTF-8'ar'%D8%B6%D9%A9%DA%A5%DA%B4%20%3Caddress%40example%3E";
- const QChar whitespaceChars[] = { 0x0636, 0x0020, 0x0669, 0x0009, 0x06a5, 0x0020, 0x06b4 };
+ const QChar whitespaceChars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0020),
+ static_cast<char16_t>(0x0669), static_cast<char16_t>(0x0009),
+ static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x0020),
+ static_cast<char16_t>(0x06b4) };
result = QString(whitespaceChars, 7);
result += "; ";
result += "param*=";
@@ -811,7 +815,8 @@ void tst_QMailMessageHeaderField::encodeWord_data()
<< QByteArray("ISO-8859-1")
<< QByteArray("=?ISO-8859-1?Q?=28t=C3=ADtulo_=C3=A1guia_Jo=C3=A3o=29?=");
- const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 };
+ const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669),
+ static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) };
QString unicodeAddress(chars, 4);
unicodeAddress.append(" <address@example>");
@@ -876,7 +881,8 @@ void tst_QMailMessageHeaderField::encodeParameter_data()
QString latin1Address(QString::fromLatin1("\"Joh\361 D\366e\" <jdoe@machine.test>"));
// Test with some arabic characters, as per http://en.wikipedia.org/wiki/List_of_Unicode_characters
- const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 };
+ const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669),
+ static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) };
QString unicodeAddress(chars, 4);
unicodeAddress.append(" <address@example>");
@@ -1032,7 +1038,8 @@ void tst_QMailMessageHeaderField::encodeContent_data()
<< QByteArray("ISO-8859-1")
<< QByteArray("=?ISO-8859-1?Q?=22Joh=F1_D=F6e=22?= =?ISO-8859-1?Q?_=3Cjdoe=40machine=2Etest=3E?=");
- const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 };
+ const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669),
+ static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) };
QString unicodeAddress(chars, 4);
unicodeAddress.append(" <address@example>");