summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2016-07-28 08:09:22 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2016-07-28 08:09:22 +0000
commit80c23042e4137dc21d92eab4db00e22f2446269b (patch)
tree306790e20b1e057e832200772857070ddacd23a0 /tests/auto/corelib/io
parent69b43e74d78e050cf5e40197acafa4bc9f90c0bd (diff)
parent6c5de416c9e77433b20b95621c75666a47fbffbd (diff)
Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp41
-rw-r--r--tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp41
2 files changed, 82 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
index 72a57c5905..0e73ea7862 100644
--- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
+++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
@@ -34,6 +34,7 @@
#include <qfile.h>
#include <qdir.h>
#include <qset.h>
+#include <qtextcodec.h>
#ifdef Q_OS_WIN
# include <windows.h>
#endif
@@ -108,6 +109,38 @@ void tst_QTemporaryDir::getSetCheck()
QCOMPARE(true, obj1.autoRemove());
}
+static inline bool canHandleUnicodeFileNames()
+{
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ return true;
+#else
+ // Check for UTF-8 by converting the Euro symbol (see tst_utf8)
+ return QFile::encodeName(QString(QChar(0x20AC))) == QByteArrayLiteral("\342\202\254");
+#endif
+}
+
+static QString hanTestText()
+{
+ QString text;
+ text += QChar(0x65B0);
+ text += QChar(0x5E10);
+ text += QChar(0x6237);
+ return text;
+}
+
+static QString umlautTestText()
+{
+ QString text;
+ text += QChar(0xc4);
+ text += QChar(0xe4);
+ text += QChar(0xd6);
+ text += QChar(0xf6);
+ text += QChar(0xdc);
+ text += QChar(0xfc);
+ text += QChar(0xdf);
+ return text;
+}
+
void tst_QTemporaryDir::fileTemplate_data()
{
QTest::addColumn<QString>("constructorTemplate");
@@ -124,6 +157,14 @@ void tst_QTemporaryDir::fileTemplate_data()
QTest::newRow("constructor with XXXX suffix") << "qt_XXXXXX_XXXX" << "qt_";
QTest::newRow("constructor with XXXX prefix") << "qt_XXXX" << "qt_";
QTest::newRow("constructor with XXXXX prefix") << "qt_XXXXX" << "qt_";
+ if (canHandleUnicodeFileNames()) {
+ // Test Umlauts (contained in Latin1)
+ QString prefix = "qt_" + umlautTestText();
+ QTest::newRow("Umlauts") << (prefix + "XXXXXX") << prefix;
+ // Test Chinese
+ prefix = "qt_" + hanTestText();
+ QTest::newRow("Chinese characters") << (prefix + "XXXXXX") << prefix;
+ }
}
void tst_QTemporaryDir::fileTemplate()
diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
index 4cfbdf8c16..8ebde627df 100644
--- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -34,6 +34,7 @@
#include <qfile.h>
#include <qdir.h>
#include <qset.h>
+#include <qtextcodec.h>
#if defined(Q_OS_WIN)
# include <windows.h>
@@ -140,6 +141,38 @@ void tst_QTemporaryFile::getSetCheck()
QCOMPARE(true, obj1.autoRemove());
}
+static inline bool canHandleUnicodeFileNames()
+{
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ return true;
+#else
+ // Check for UTF-8 by converting the Euro symbol (see tst_utf8)
+ return QFile::encodeName(QString(QChar(0x20AC))) == QByteArrayLiteral("\342\202\254");
+#endif
+}
+
+static QString hanTestText()
+{
+ QString text;
+ text += QChar(0x65B0);
+ text += QChar(0x5E10);
+ text += QChar(0x6237);
+ return text;
+}
+
+static QString umlautTestText()
+{
+ QString text;
+ text += QChar(0xc4);
+ text += QChar(0xe4);
+ text += QChar(0xd6);
+ text += QChar(0xf6);
+ text += QChar(0xdc);
+ text += QChar(0xfc);
+ text += QChar(0xdf);
+ return text;
+}
+
void tst_QTemporaryFile::fileTemplate_data()
{
QTest::addColumn<QString>("constructorTemplate");
@@ -166,6 +199,14 @@ void tst_QTemporaryFile::fileTemplate_data()
QTest::newRow("set template, with xxx") << "" << "qt_" << ".xxx" << "qt_XXXXXX.xxx";
QTest::newRow("set template, with >6 X's") << "" << "qt_" << ".xxx" << "qt_XXXXXXXXXXXXXX.xxx";
QTest::newRow("set template, with >6 X's, no suffix") << "" << "qt_" << "" << "qt_XXXXXXXXXXXXXX";
+ if (canHandleUnicodeFileNames()) {
+ // Test Umlauts (contained in Latin1)
+ QString prefix = "qt_" + umlautTestText();
+ QTest::newRow("Umlauts") << (prefix + "XXXXXX") << prefix << QString() << QString();
+ // Test Chinese
+ prefix = "qt_" + hanTestText();
+ QTest::newRow("Chinese characters") << (prefix + "XXXXXX") << prefix << QString() << QString();
+ }
}
void tst_QTemporaryFile::fileTemplate()