diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-06-04 17:24:49 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-06-04 17:24:49 (GMT) |
commit | 5c17f3abe1c43539db613da78414bc0b27928814 (patch) | |
tree | aeda95c710a5dd597d4e45a94f57729f0dc1a6dc /tests/auto/qtextcodec/tst_qtextcodec.cpp | |
parent | b70c535fb096652def0c4f6df6f9cd2827fa9c97 (diff) | |
parent | 398c022e8adefc6e71a6048da40c19f6169be831 (diff) | |
download | Qt-5c17f3abe1c43539db613da78414bc0b27928814.zip Qt-5c17f3abe1c43539db613da78414bc0b27928814.tar.gz Qt-5c17f3abe1c43539db613da78414bc0b27928814.tar.bz2 |
Merge commit 'origin/4.5'
Diffstat (limited to 'tests/auto/qtextcodec/tst_qtextcodec.cpp')
-rw-r--r-- | tests/auto/qtextcodec/tst_qtextcodec.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp index 22f9557..97c409b 100644 --- a/tests/auto/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp @@ -1540,7 +1540,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") @@ -1721,14 +1721,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); |