mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 10:22:55 +00:00
test QTextConverter::hasFailure() in QTextCodec test
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b0949ee6c5
commit
1681ba3f1e
1 changed files with 28 additions and 0 deletions
|
@ -36,6 +36,9 @@ public slots:
|
|||
private slots:
|
||||
void mibEnum_data();
|
||||
void mibEnum();
|
||||
|
||||
void hasFailure_data();
|
||||
void hasFailure();
|
||||
};
|
||||
|
||||
void tst_QTextCodec::init()
|
||||
|
@ -65,6 +68,31 @@ void tst_QTextCodec::mibEnum()
|
|||
QVERIFY(codec->mibEnum() != 2);
|
||||
}
|
||||
|
||||
void tst_QTextCodec::hasFailure_data()
|
||||
{
|
||||
QTest::addColumn<int>("mib");
|
||||
QTest::addColumn<bool>("hasfailure");
|
||||
QTest::addColumn<QString>("data");
|
||||
|
||||
QTest::newRow("latin1-from-latin1") << int(4) << false << QString("foo");
|
||||
QTest::newRow("latin1-from-utf8") << int(4) << true << QString::fromUtf8("бар");
|
||||
}
|
||||
|
||||
void tst_QTextCodec::hasFailure()
|
||||
{
|
||||
QFETCH(int, mib);
|
||||
QFETCH(bool, hasfailure);
|
||||
QFETCH(QString, data);
|
||||
|
||||
QTextConverter converter(mib);
|
||||
const QByteArray result = converter.fromUnicode(data);
|
||||
QCOMPARE(converter.hasFailure(), hasfailure);
|
||||
if (hasfailure) {
|
||||
const QByteArray expected(data.size(), '?');
|
||||
QCOMPARE(result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QTextCodec)
|
||||
|
||||
#include "moc_tst_qtextcodec.cpp"
|
||||
|
|
Loading…
Add table
Reference in a new issue