summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtextcodec/tst_qtextcodec.cpp
diff options
context:
space:
mode:
authorMarius Storm-Olsen <marius@trolltech.com>2009-06-03 11:21:21 (GMT)
committerMarius Storm-Olsen <marius@trolltech.com>2009-06-03 11:37:41 (GMT)
commit34d003341c5286354e8277a4cc33182c94549ac0 (patch)
tree2db833aa1ad0e24cf57eb34a2e9320f6f87a7f71 /tests/auto/qtextcodec/tst_qtextcodec.cpp
parent259b65c2f5d736dd7f6d81b6390f54464dd5f183 (diff)
downloadQt-34d003341c5286354e8277a4cc33182c94549ac0.zip
Qt-34d003341c5286354e8277a4cc33182c94549ac0.tar.gz
Qt-34d003341c5286354e8277a4cc33182c94549ac0.tar.bz2
Fix BOM for UTF-32 codec
The BOM was created correctly, but half of the BOM was then overwritten by the converted data afterwards. Also made the autotest also do reverse encoding tests where possible. Task-number: 255095 Reviewed-by: lars
Diffstat (limited to 'tests/auto/qtextcodec/tst_qtextcodec.cpp')
-rw-r--r--tests/auto/qtextcodec/tst_qtextcodec.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp
index cf4135b..566b20e 100644
--- a/tests/auto/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp
@@ -1537,7 +1537,7 @@ void tst_QTextCodec::utfHeaders_data()
<< QByteArray("\xef\xbb\xbfhello")
<< (QString(QChar(0xfeff)) + QString::fromLatin1("hello"))
<< true;
- QTest::newRow("utf8 nobom")
+ QTest::newRow("utf8 nobom ignore header")
<< QByteArray("UTF-8")
<< (int)QTextCodec::IgnoreHeader
<< QByteArray("hello")
@@ -1718,14 +1718,23 @@ void tst_QTextCodec::utfHeaders()
QFETCH(bool, toUnicode);
+ QLatin1String ignoreReverseTestOn = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? QLatin1String(" le") : QLatin1String(" be");
+ QString rowName(QTest::currentDataTag());
+
for (int i = 0; i < encoded.length(); ++i)
qDebug() << hex << " " << (uint)(uchar)encoded.at(i);
if (toUnicode) {
QString result = codec->toUnicode(encoded.constData(), encoded.length(), &state);
- for (int i = 0; i < result.length(); ++i)
- qDebug() << hex << " " << (uint)result.at(i).unicode();
+ for (int i = 0; i < result.length(); ++i)
+ qDebug() << hex << " " << (uint)result.at(i).unicode();
QCOMPARE(result.length(), unicode.length());
QCOMPARE(result, unicode);
+
+ if (!rowName.endsWith("nobom") && !rowName.contains(ignoreReverseTestOn)) {
+ QTextCodec::ConverterState state2(cFlags);
+ QByteArray reencoded = codec->fromUnicode(unicode.unicode(), unicode.length(), &state2);
+ QCOMPARE(reencoded, encoded);
+ }
} else {
QByteArray result = codec->fromUnicode(unicode.unicode(), unicode.length(), &state);
QCOMPARE(result, encoded);