summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-09-08 14:59:05 +0200
committerLars Knoll <lars.knoll@qt.io>2020-09-15 08:13:27 +0200
commite96a311334a5c70d5ffcc2ca5c10919952b99636 (patch)
tree58c4b65892f170ae770bb5e8d74950031558b203 /tests
parentcb78972e375b9e5f8180b39bd6985ea0be75d2f7 (diff)
Use UTF-8 when converting 8 bit data in QTextStream
This was overlooked when doing the conversion to use UTF-8 as the standard 8 bit encoding for text. Fixes: QTBUG-54942 Change-Id: Ib7b1b75b4d694648ab7143f6930b6bb1dcad19c9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp4
-rw-r--r--tests/auto/corelib/text/qstring/tst_qstring.cpp10
2 files changed, 11 insertions, 3 deletions
diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
index e1fd7a7147..f9de9eeebf 100644
--- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
@@ -2125,9 +2125,9 @@ void tst_QTextStream::generateStringData(bool for_QString)
if (!for_QString) {
QTest::newRow("utf16-BE (empty)") << QByteArray("\xff\xfe", 2) << QByteArray() << QString();
- QTest::newRow("utf16-BE (corrupt)") << QByteArray("\xff", 1) << QByteArray("\xff") << QString::fromLatin1("\xff");
+ QTest::newRow("utf16-BE (corrupt)") << QByteArray("\xff", 1) << QByteArray("\xc3\xbf") << QString::fromUtf8("\xc3\xbf");
QTest::newRow("utf16-LE (empty)") << QByteArray("\xfe\xff", 2) << QByteArray() << QString();
- QTest::newRow("utf16-LE (corrupt)") << QByteArray("\xfe", 1) << QByteArray("\xfe") << QString::fromLatin1("\xfe");
+ QTest::newRow("utf16-LE (corrupt)") << QByteArray("\xfe", 1) << QByteArray("\xc3\xbe") << QString::fromUtf8("\xc3\xbe");
}
}
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp
index 8f77d03226..6e1b47a839 100644
--- a/tests/auto/corelib/text/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp
@@ -3963,8 +3963,16 @@ void tst_QString::check_QTextIOStream()
{
a="";
QTextStream ts(&a);
+ // invalid Utf8
ts << "pi \261= " << 3.125;
- QCOMPARE(a, QString::fromLatin1("pi \261= 3.125"));
+ QCOMPARE(a, QString::fromUtf16(u"pi \xfffd= 3.125"));
+ }
+ {
+ a="";
+ QTextStream ts(&a);
+ // valid Utf8
+ ts << "pi ø= " << 3.125;
+ QCOMPARE(a, QString::fromUtf16(u"pi ø= 3.125"));
}
{
a="123 456";