diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-06-24 01:51:57 +0300 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-08-22 21:45:12 +0300 |
commit | 87aac3caca30f9f9ac9efbe895ec0f9fafab8155 (patch) | |
tree | 720c850f6147e30bbbd1b23cc38cb95ad28bd21f /tests/auto | |
parent | 5d1e4567f975cd5720d22adb65c6fb55bfb21464 (diff) |
QFile: add decodeName() unittests
And extend the encodeName() unittest.
Change-Id: Id5cd8a1f7ffbdb0d810bdc80b28aab9eb5cfbcdb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/io/qfile/tst_qfile.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 4048faf4e1..bd83aff141 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -201,6 +201,9 @@ private slots: #ifdef Q_OS_UNIX void isSequential(); #endif + void decodeName_data(); + void decodeName(); + void encodeName_data() { decodeName_data(); } void encodeName(); void truncate(); void seekToPos(); @@ -1914,9 +1917,41 @@ void tst_QFile::isSequential() } #endif +void tst_QFile::decodeName_data() +{ + QTest::addColumn<QByteArray>("bytearray"); + QTest::addColumn<QString>("qstring"); + + QTest::newRow("null") << QByteArray() << QString(); + QTest::newRow("simple") << "/path/to/file"_ba << u"/path/to/file"_s; + +#ifndef Q_OS_WIN +# ifdef Q_OS_DARWIN + // Mac always expects filenames in UTF-8... and decomposed... + QTest::newRow("filé") << "/path/to/file\xCC\x81"_ba << u"/path/to/filé"_s; +# else + QTest::newRow("filé") << "/path/to/fil\xC3\xA9"_ba << u"/path/to/filé"_s; +# endif + QTest::newRow("fraction-slash") + << "/path\342\201\204to\342\201\204file"_ba << u"/path⁄to⁄file"_s; + QTest::newRow("fraction-slash-u16") << "/path\u2044to\u2044file"_ba << u"/path⁄to⁄file"_s; +#endif // !Q_OS_WIN +} + +void tst_QFile::decodeName() +{ + QFETCH(QByteArray, bytearray); + QFETCH(QString, qstring); + + QCOMPARE(QFile::decodeName(bytearray), qstring); +} + void tst_QFile::encodeName() { - QCOMPARE(QFile::encodeName(QString()), QByteArray()); + QFETCH(QString, qstring); + QFETCH(QByteArray, bytearray); + + QCOMPARE(QFile::encodeName(qstring), bytearray); } void tst_QFile::truncate() |