summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp3
-rw-r--r--tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp12
-rw-r--r--tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp2
-rw-r--r--tests/auto/corelib/global/global.pro1
-rw-r--r--tests/auto/corelib/global/qflags/tst_qflags.cpp8
-rw-r--r--tests/auto/corelib/global/qfloat16/qfloat16.pro4
-rw-r--r--tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp266
-rw-r--r--tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp8
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp7
-rw-r--r--tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro1
-rw-r--r--tests/auto/corelib/global/qlogging/test/test.pro2
-rw-r--r--tests/auto/corelib/io/io.pro13
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp23
-rw-r--r--tests/auto/corelib/io/qfile/test/test.pro2
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp4
-rw-r--r--tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp2
-rw-r--r--tests/auto/corelib/io/qfilesystemmetadata/qfilesystemmetadata.pro4
-rw-r--r--tests/auto/corelib/io/qfilesystemmetadata/tst_qfilesystemmetadata.cpp93
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.pro1
-rw-r--r--tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro2
-rw-r--r--tests/auto/corelib/io/qprocess/test/test.pro2
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp2
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp73
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp2
-rw-r--r--tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp25
-rw-r--r--tests/auto/corelib/json/json.pro1
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/Info.plist8
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro3
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp35
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h1
-rw-r--r--tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro1
-rw-r--r--tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro1
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp8
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp2
-rw-r--r--tests/auto/corelib/kernel/qsharedmemory/test/test.pro1
-rw-r--r--tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro1
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp7
-rw-r--r--tests/auto/corelib/plugin/qfactoryloader/test/test.pro2
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst/tst.pro1
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro11
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst/tst.pro1
-rw-r--r--tests/auto/corelib/thread/qmutex/tst_qmutex.cpp2
-rw-r--r--tests/auto/corelib/thread/qsemaphore/BLACKLIST5
-rw-r--r--tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp6
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp92
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/test/test.pro2
-rw-r--r--tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp8
-rw-r--r--tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp50
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp77
-rw-r--r--tests/auto/corelib/tools/qbytearraymatcher/qbytearraymatcher.pro1
-rw-r--r--tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp109
-rw-r--r--tests/auto/corelib/tools/qchar/tst_qchar.cpp2
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp83
-rw-r--r--tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp6
-rw-r--r--tests/auto/corelib/tools/qlocale/test/test.pro1
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp26
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp21
-rw-r--r--tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp196
-rw-r--r--tests/auto/corelib/tools/qtimezone/qtimezone.pro5
-rw-r--r--tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp81
-rw-r--r--tests/auto/corelib/tools/qtimezone/tst_qtimezone_darwin.mm68
61 files changed, 1381 insertions, 106 deletions
diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
index a8d64f1cd9..18a6268ec0 100644
--- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
@@ -786,6 +786,9 @@ struct AnimState {
int time;
int state;
};
+QT_BEGIN_NAMESPACE
+Q_DECLARE_TYPEINFO(AnimState, Q_MOVABLE_TYPE);
+QT_END_NAMESPACE
#define Running QAbstractAnimation::Running
#define Stopped QAbstractAnimation::Stopped
diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
index b0b0a307e9..cf4c4e1bdb 100644
--- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -427,7 +427,7 @@ public:
void setOle(int v) { o = v; values << v; }
int o;
- QList<int> values;
+ QVector<int> values;
};
void tst_QPropertyAnimation::noStartValue()
@@ -672,19 +672,15 @@ struct Number
Number(int n)
: n(n) {}
- Number(const Number &other)
- : n(other.n){}
-
- Number &operator=(const Number &other) {
- n = other.n;
- return *this;
- }
bool operator==(const Number &other) const {
return n == other.n;
}
int n;
};
+QT_BEGIN_NAMESPACE
+Q_DECLARE_TYPEINFO(Number, Q_PRIMITIVE_TYPE);
+QT_END_NAMESPACE
Q_DECLARE_METATYPE(Number)
diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index 6d66f05835..06e9fe7a66 100644
--- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -563,7 +563,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped);
}
-typedef QList<QAbstractAnimation::State> StateList;
+typedef QVector<QAbstractAnimation::State> StateList;
static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates)
{
diff --git a/tests/auto/corelib/global/global.pro b/tests/auto/corelib/global/global.pro
index 219e9de818..b4cc8035e6 100644
--- a/tests/auto/corelib/global/global.pro
+++ b/tests/auto/corelib/global/global.pro
@@ -5,6 +5,7 @@ SUBDIRS=\
qgetputenv \
qglobal \
qnumeric \
+ qfloat16 \
qrand \
qlogging \
qtendian \
diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp
index 634d9a2df3..d70b099fe3 100644
--- a/tests/auto/corelib/global/qflags/tst_qflags.cpp
+++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp
@@ -134,11 +134,11 @@ void tst_QFlags::signedness()
// underlying type is implementation-defined, we need to allow for
// a different signedness, so we only check that the relative
// signedness of the types matches:
- Q_STATIC_ASSERT((QtPrivate::QIsUnsignedEnum<Qt::MouseButton>::value ==
- QtPrivate::QIsUnsignedEnum<Qt::MouseButtons::Int>::value));
+ Q_STATIC_ASSERT((std::is_unsigned<typename std::underlying_type<Qt::MouseButton>::type>::value ==
+ std::is_unsigned<Qt::MouseButtons::Int>::value));
- Q_STATIC_ASSERT((QtPrivate::QIsSignedEnum<Qt::AlignmentFlag>::value ==
- QtPrivate::QIsSignedEnum<Qt::Alignment::Int>::value));
+ Q_STATIC_ASSERT((std::is_signed<typename std::underlying_type<Qt::AlignmentFlag>::type>::value ==
+ std::is_signed<Qt::Alignment::Int>::value));
}
#if defined(Q_COMPILER_CLASS_ENUM)
diff --git a/tests/auto/corelib/global/qfloat16/qfloat16.pro b/tests/auto/corelib/global/qfloat16/qfloat16.pro
new file mode 100644
index 0000000000..42081181b4
--- /dev/null
+++ b/tests/auto/corelib/global/qfloat16/qfloat16.pro
@@ -0,0 +1,4 @@
+CONFIG += testcase
+TARGET = tst_qfloat16
+QT = core testlib
+SOURCES = tst_qfloat16.cpp
diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
new file mode 100644
index 0000000000..c894a9c897
--- /dev/null
+++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
@@ -0,0 +1,266 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 by Southwest Research Institute (R)
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QFloat16>
+
+#include <math.h>
+
+class tst_qfloat16: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void fuzzyCompare_data();
+ void fuzzyCompare();
+ void ltgt_data();
+ void ltgt();
+ void qNan();
+ void float_cast();
+ void float_cast_data();
+ void promotionTests();
+};
+
+void tst_qfloat16::fuzzyCompare_data()
+{
+ QTest::addColumn<qfloat16>("val1");
+ QTest::addColumn<qfloat16>("val2");
+ QTest::addColumn<bool>("fuzEqual");
+ QTest::addColumn<bool>("isEqual");
+
+ QTest::newRow("zero") << qfloat16(0.0f) << qfloat16(0.0f) << true << true;
+ QTest::newRow("ten") << qfloat16(1e1f) << qfloat16(1e1f) << true << true;
+ QTest::newRow("large") << qfloat16(1e4f) << qfloat16(1e4f) << true << true;
+ QTest::newRow("small") << qfloat16(1e-5f) << qfloat16(1e-5f) << true << true;
+ QTest::newRow("eps") << qfloat16(10.01f) << qfloat16(10.02f) << true << false;
+ QTest::newRow("eps2") << qfloat16(1024.f) << qfloat16(1033.f) << true << false;
+
+ QTest::newRow("mis1") << qfloat16(0.0f) << qfloat16(1.0f) << false << false;
+ QTest::newRow("mis2") << qfloat16(0.0f) << qfloat16(1e7f) << false << false;
+ QTest::newRow("mis3") << qfloat16(0.0f) << qfloat16(1e-4f) << false << false;
+ QTest::newRow("mis4") << qfloat16(1e8f) << qfloat16(1e-8f) << false << false;
+ QTest::newRow("mis5") << qfloat16(1e-4f) << qfloat16(1e-5) << false << false;
+ QTest::newRow("mis6") << qfloat16(1024.f) << qfloat16(1034.f) << false << false;
+}
+
+void tst_qfloat16::fuzzyCompare()
+{
+ QFETCH(qfloat16, val1);
+ QFETCH(qfloat16, val2);
+ QFETCH(bool, fuzEqual);
+ QFETCH(bool, isEqual);
+
+ if (!isEqual && (val1==val2))
+ qWarning() << "Identical arguments provided unintentionally!";
+
+ if (fuzEqual) {
+ QVERIFY(::qFuzzyCompare(val1, val2));
+ QVERIFY(::qFuzzyCompare(val2, val1));
+ QVERIFY(::qFuzzyCompare(-val1, -val2));
+ QVERIFY(::qFuzzyCompare(-val2, -val1));
+ } else {
+ QVERIFY(!::qFuzzyCompare(val1, val2));
+ QVERIFY(!::qFuzzyCompare(val2, val1));
+ QVERIFY(!::qFuzzyCompare(-val1, -val2));
+ QVERIFY(!::qFuzzyCompare(-val2, -val1));
+ }
+}
+
+void tst_qfloat16::ltgt_data()
+{
+ QTest::addColumn<float>("val1");
+ QTest::addColumn<float>("val2");
+
+ QTest::newRow("zero") << 0.0f << 0.0f;
+ QTest::newRow("ten") << 10.0f << 10.0f;
+ QTest::newRow("large") << 100000.0f << 100000.0f;
+ QTest::newRow("small") << 0.0000001f << 0.0000001f;
+ QTest::newRow("eps") << 10.000000000000001f << 10.00000000000002f;
+ QTest::newRow("eps2") << 10.000000000000001f << 10.000000000000009f;
+
+ QTest::newRow("mis1") << 0.0f << 1.0f;
+ QTest::newRow("mis2") << 0.0f << 10000000.0f;
+ QTest::newRow("mis3") << 0.0f << 0.0001f;
+ QTest::newRow("mis4") << 100000000.0f << 0.000000001f;
+ QTest::newRow("mis5") << 0.0001f << 0.00001f;
+
+ QTest::newRow("45,23") << 45.f << 23.f;
+ QTest::newRow("1000,76") << 1000.f << 76.f;
+}
+
+void tst_qfloat16::ltgt()
+{
+ QFETCH(float, val1);
+ QFETCH(float, val2);
+
+ QCOMPARE(qfloat16(val1) == qfloat16(val2), val1 == val2);
+ QCOMPARE(qfloat16(val1) < qfloat16(val2), val1 < val2);
+ QCOMPARE(qfloat16(val1) <= qfloat16(val2), val1 <= val2);
+ QCOMPARE(qfloat16(val1) > qfloat16(val2), val1 > val2);
+ QCOMPARE(qfloat16(val1) >= qfloat16(val2), val1 >= val2);
+
+ QCOMPARE(qfloat16(val1) == qfloat16(-val2), val1 == -val2);
+ QCOMPARE(qfloat16(val1) < qfloat16(-val2), val1 < -val2);
+ QCOMPARE(qfloat16(val1) <= qfloat16(-val2), val1 <= -val2);
+ QCOMPARE(qfloat16(val1) > qfloat16(-val2), val1 > -val2);
+ QCOMPARE(qfloat16(val1) >= qfloat16(-val2), val1 >= -val2);
+
+ QCOMPARE(qfloat16(-val1) == qfloat16(val2), -val1 == val2);
+ QCOMPARE(qfloat16(-val1) < qfloat16(val2), -val1 < val2);
+ QCOMPARE(qfloat16(-val1) <= qfloat16(val2), -val1 <= val2);
+ QCOMPARE(qfloat16(-val1) > qfloat16(val2), -val1 > val2);
+ QCOMPARE(qfloat16(-val1) >= qfloat16(val2), -val1 >= val2);
+
+ QCOMPARE(qfloat16(-val1) == qfloat16(-val2), -val1 == -val2);
+ QCOMPARE(qfloat16(-val1) < qfloat16(-val2), -val1 < -val2);
+ QCOMPARE(qfloat16(-val1) <= qfloat16(-val2), -val1 <= -val2);
+ QCOMPARE(qfloat16(-val1) > qfloat16(-val2), -val1 > -val2);
+ QCOMPARE(qfloat16(-val1) >= qfloat16(-val2), -val1 >= -val2);
+}
+
+#if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ >= 404)
+ // turn -ffast-math off
+# pragma GCC optimize "no-fast-math"
+#endif
+
+void tst_qfloat16::qNan()
+{
+#if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ < 404)
+ QSKIP("Non-conformant fast math mode is enabled, cannot run test");
+#endif
+ qfloat16 nan = qQNaN();
+ QVERIFY(!(0. > nan));
+ QVERIFY(!(0. < nan));
+ QVERIFY(qIsNaN(nan));
+ QVERIFY(qIsNaN(nan + 1.f));
+ QVERIFY(qIsNaN(-nan));
+ qfloat16 inf = qInf();
+ QVERIFY(inf > qfloat16(0));
+ QVERIFY(-inf < qfloat16(0));
+ QVERIFY(qIsInf(inf));
+ QVERIFY(qIsInf(-inf));
+ QVERIFY(qIsInf(2.f*inf));
+ QVERIFY(qIsInf(inf*2.f));
+ QCOMPARE(qfloat16(1.f/inf), qfloat16(0.f));
+#ifdef Q_CC_INTEL
+ QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue);
+#endif
+ QVERIFY(qIsNaN(nan*0.f));
+#ifdef Q_CC_INTEL
+ QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue);
+#endif
+ QVERIFY(qIsNaN(inf*0.f));
+ QVERIFY(qFuzzyCompare(qfloat16(1.f/inf), qfloat16(0.0)));
+}
+
+void tst_qfloat16::float_cast_data()
+{
+ QTest::addColumn<float>("val");
+
+ QTest::newRow("zero") << 0.f;
+ QTest::newRow("one") << 1e0f;
+ QTest::newRow("ten") << 1e1f;
+ QTest::newRow("hund") << 1e2f;
+ QTest::newRow("thou") << 1e3f;
+ QTest::newRow("tthou") << 1e4f;
+ //QTest::newRow("hthou") << 1e5f;
+ //QTest::newRow("mil") << 1e6f;
+ //QTest::newRow("tmil") << 1e7f;
+ //QTest::newRow("hmil") << 1e8f;
+}
+
+void tst_qfloat16::float_cast()
+{
+ QFETCH(float, val);
+
+ QVERIFY(qFuzzyCompare(float(qfloat16(val)),val));
+ QVERIFY(qFuzzyCompare(float(qfloat16(-val)),-val));
+}
+
+void tst_qfloat16::promotionTests()
+{
+ QCOMPARE(sizeof(qfloat16),sizeof(qfloat16(1.f)+qfloat16(1.f)));
+ QCOMPARE(sizeof(qfloat16),sizeof(qfloat16(1.f)-qfloat16(1.f)));
+ QCOMPARE(sizeof(qfloat16),sizeof(qfloat16(1.f)*qfloat16(1.f)));
+ QCOMPARE(sizeof(qfloat16),sizeof(qfloat16(1.f)/qfloat16(1.f)));
+
+ QCOMPARE(sizeof(float),sizeof(1.f+qfloat16(1.f)));
+ QCOMPARE(sizeof(float),sizeof(1.f-qfloat16(1.f)));
+ QCOMPARE(sizeof(float),sizeof(1.f*qfloat16(1.f)));
+ QCOMPARE(sizeof(float),sizeof(1.f/qfloat16(1.f)));
+
+ QCOMPARE(sizeof(float),sizeof(qfloat16(1.f)+1.f));
+ QCOMPARE(sizeof(float),sizeof(qfloat16(1.f)-1.f));
+ QCOMPARE(sizeof(float),sizeof(qfloat16(1.f)*1.f));
+ QCOMPARE(sizeof(float),sizeof(qfloat16(1.f)/1.f));
+
+ QCOMPARE(sizeof(double),sizeof(1.+qfloat16(1.f)));
+ QCOMPARE(sizeof(double),sizeof(1.-qfloat16(1.f)));
+ QCOMPARE(sizeof(double),sizeof(1.*qfloat16(1.f)));
+ QCOMPARE(sizeof(double),sizeof(1./qfloat16(1.f)));
+
+ QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)+1.));
+ QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)-1.));
+ QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)*1.));
+ QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)/1.));
+
+ QCOMPARE(sizeof(long double),sizeof((long double)(1.)+qfloat16(1.f)));
+ QCOMPARE(sizeof(long double),sizeof((long double)(1.)-qfloat16(1.f)));
+ QCOMPARE(sizeof(long double),sizeof((long double)(1.)*qfloat16(1.f)));
+ QCOMPARE(sizeof(long double),sizeof((long double)(1.)/qfloat16(1.f)));
+
+ QCOMPARE(sizeof(long double),sizeof(qfloat16(1.f)+(long double)(1.)));
+ QCOMPARE(sizeof(long double),sizeof(qfloat16(1.f)-(long double)(1.)));
+ QCOMPARE(sizeof(long double),sizeof(qfloat16(1.f)*(long double)(1.)));
+ QCOMPARE(sizeof(long double),sizeof(qfloat16(1.f)/(long double)(1.)));
+
+ QCOMPARE(sizeof(double),sizeof(1+qfloat16(1.f)));
+ QCOMPARE(sizeof(double),sizeof(1-qfloat16(1.f)));
+ QCOMPARE(sizeof(double),sizeof(1*qfloat16(1.f)));
+ QCOMPARE(sizeof(double),sizeof(1/qfloat16(1.f)));
+
+ QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)+1));
+ QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)-1));
+ QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)*1));
+ QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)/1));
+}
+
+QTEST_APPLESS_MAIN(tst_qfloat16)
+#include "tst_qfloat16.moc"
diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
index 7ffb5d0fd7..66fc578d5f 100644
--- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
+++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
@@ -112,13 +112,13 @@ void tst_QGetPutEnv::intValue_data()
ROW(0xffffffff, 0, false);
const int bases[] = {10, 8, 16};
for (size_t i = 0; i < sizeof bases / sizeof *bases; ++i) {
- QTest::newRow(qPrintable(QString::asprintf("INT_MAX, base %d", bases[i])))
+ QTest::addRow("INT_MAX, base %d", bases[i])
<< QByteArray::number(INT_MAX) << INT_MAX << true;
- QTest::newRow(qPrintable(QString::asprintf("INT_MAX+1, base %d", bases[i])))
+ QTest::addRow("INT_MAX+1, base %d", bases[i])
<< QByteArray::number(qlonglong(INT_MAX) + 1) << 0 << false;
- QTest::newRow(qPrintable(QString::asprintf("INT_MIN, base %d", bases[i])))
+ QTest::addRow("INT_MIN, base %d", bases[i])
<< QByteArray::number(INT_MIN) << INT_MIN << true;
- QTest::newRow(qPrintable(QString::asprintf("INT_MIN-1, base %d", bases[i])))
+ QTest::addRow("INT_MIN-1, base %d", bases[i])
<< QByteArray::number(qlonglong(INT_MIN) - 1) << 0 << false;
};
}
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index bb6ec1c8e7..083526fdc4 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -102,6 +102,13 @@ void tst_QGlobal::for_each()
QCOMPARE(i, counter++);
}
QCOMPARE(counter, list.count());
+
+ // check whether we can use a lambda
+ counter = 0;
+ foreach (int i, [&](){ return list; }()) {
+ QCOMPARE(i, counter++);
+ }
+ QCOMPARE(counter, list.count());
}
void tst_QGlobal::qassert()
diff --git a/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro b/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro
index 056d940da7..21bb040b8d 100644
--- a/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro
+++ b/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro
@@ -5,7 +5,6 @@ QT -= gui
TARGET = tst_qglobalstatic
CONFIG += console
-CONFIG -= app_bundle
CONFIG += exceptions
SOURCES += tst_qglobalstatic.cpp
diff --git a/tests/auto/corelib/global/qlogging/test/test.pro b/tests/auto/corelib/global/qlogging/test/test.pro
index 93eee7307a..7c46ae9d16 100644
--- a/tests/auto/corelib/global/qlogging/test/test.pro
+++ b/tests/auto/corelib/global/qlogging/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
qtConfig(c++11): CONFIG += c++11
qtConfig(c++14): CONFIG += c++14
TARGET = ../tst_qlogging
diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro
index 5e20f5de5c..470a1dde26 100644
--- a/tests/auto/corelib/io/io.pro
+++ b/tests/auto/corelib/io/io.pro
@@ -11,6 +11,7 @@ SUBDIRS=\
largefile \
qfileinfo \
qfileselector \
+ qfilesystemmetadata \
qfilesystementry \
qfilesystemwatcher \
qiodevice \
@@ -56,14 +57,16 @@ SUBDIRS=\
qurlinternal \
qloggingregistry
-!qtConfig(process): SUBDIRS -= \
- qprocess \
- qprocess-noapplication \
- qprocessenvironment
-
win32:!qtConfig(private_tests): SUBDIRS -= \
qfilesystementry
+!qtConfig(processenvironment): SUBDIRS -= \
+ qprocessenvironment
+
+!qtConfig(process): SUBDIRS -= \
+ qprocess \
+ qprocess-noapplication
+
winrt: SUBDIRS -= \
qstorageinfo \
qwinoverlappedionotifier
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index 6232ce4c66..762cb539e0 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -211,6 +211,9 @@ private slots:
void cdBelowRoot_data();
void cdBelowRoot();
+ void emptyDir();
+ void nonEmptyDir();
+
private:
#ifdef BUILTIN_TESTDATA
QString m_dataPath;
@@ -2281,6 +2284,26 @@ void tst_QDir::cdBelowRoot()
QCOMPARE(dir.path(), rootPath);
}
+void tst_QDir::emptyDir()
+{
+ const QString tempDir = QDir::currentPath() + "/tmpdir/";
+ QVERIFY(QDir().mkdir(tempDir));
+ QVERIFY(QDir(tempDir).mkdir("emptyDirectory"));
+
+ QDir testDir(tempDir + "emptyDirectory");
+ QVERIFY(testDir.isEmpty());
+ QVERIFY(!testDir.isEmpty(QDir::AllEntries));
+ QVERIFY(!testDir.isEmpty(QDir::AllEntries | QDir::NoDot));
+ QVERIFY(!testDir.isEmpty(QDir::AllEntries | QDir::NoDotDot));
+ QVERIFY(QDir(tempDir).removeRecursively());
+}
+
+void tst_QDir::nonEmptyDir()
+{
+ const QDir dir(m_dataPath);
+ QVERIFY(!dir.isEmpty());
+}
+
QTEST_MAIN(tst_QDir)
#include "tst_qdir.moc"
diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro
index c0c4b9d5d2..5f1963cf5f 100644
--- a/tests/auto/corelib/io/qfile/test/test.pro
+++ b/tests/auto/corelib/io/qfile/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT = core-private core testlib
qtHaveModule(network): QT += network
else: DEFINES += QT_NO_NETWORK
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 8595c048b2..a6da6d8e69 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -1375,10 +1375,8 @@ void tst_QFile::copyFallback()
#ifdef Q_OS_WIN
#include <objbase.h>
-#ifndef Q_OS_WINPHONE
#include <shlobj.h>
#endif
-#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
static QString getWorkingDirectoryForLink(const QString &linkFileName)
@@ -1688,7 +1686,7 @@ void tst_QFile::isSequential()
void tst_QFile::encodeName()
{
- QCOMPARE(QFile::encodeName(QString::null), QByteArray());
+ QCOMPARE(QFile::encodeName(QString()), QByteArray());
}
void tst_QFile::truncate()
diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
index e5ede1ad06..8c2886f337 100644
--- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
+++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
@@ -138,7 +138,7 @@ void tst_QFileSelector::basicTest_data()
<< QString(":/extras/test2");
QTest::newRow("custom1-withselector-nobasefile") << QString(":/extras/test3") << (QStringList() << custom1)
- << QString(":/extras/test3");
+ << QString(":/extras/+custom1/test3");
QString custom2("custom2");
QString custom3("custom3");
diff --git a/tests/auto/corelib/io/qfilesystemmetadata/qfilesystemmetadata.pro b/tests/auto/corelib/io/qfilesystemmetadata/qfilesystemmetadata.pro
new file mode 100644
index 0000000000..a7d50ece43
--- /dev/null
+++ b/tests/auto/corelib/io/qfilesystemmetadata/qfilesystemmetadata.pro
@@ -0,0 +1,4 @@
+CONFIG += testcase parallel_test
+TARGET = tst_qfilesystemmetadata
+QT = core-private testlib
+SOURCES = tst_qfilesystemmetadata.cpp
diff --git a/tests/auto/corelib/io/qfilesystemmetadata/tst_qfilesystemmetadata.cpp b/tests/auto/corelib/io/qfilesystemmetadata/tst_qfilesystemmetadata.cpp
new file mode 100644
index 0000000000..d17dffe830
--- /dev/null
+++ b/tests/auto/corelib/io/qfilesystemmetadata/tst_qfilesystemmetadata.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/private/qfilesystemmetadata_p.h>
+
+class tst_QFileSystemMetaData : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void timeSinceEpoch();
+};
+
+#if defined(QT_BUILD_INTERNAL) && defined(QT_SHARED)
+#ifdef Q_OS_WIN
+static FILETIME epochToFileTime(long seconds)
+{
+ const qint64 sec = 10000000;
+ // FILETIME is time in 1e-7s units since 1601's start: epoch is 1970's
+ // start, 369 years (of which 3*24 +69/4 = 89 were leap) later.
+ const qint64 offset = qint64(365 * 369 + 89) * 24 * 3600;
+ const qint64 convert = (offset + seconds) * sec;
+ FILETIME parts;
+ parts.dwHighDateTime = convert >> 32;
+ parts.dwLowDateTime = convert & 0xffffffff;
+ return parts;
+}
+#endif
+
+void tst_QFileSystemMetaData::timeSinceEpoch()
+{
+ // Regression test for QTBUG-48306, used to fail for TZ=Russia/Moscow
+ // Oct 22 2014 6:00 UTC; TZ=Russia/Moscow changed from +4 to +3 on Oct 26.
+ const long afterEpochUtc = 1413957600L;
+ QFileSystemMetaData meta;
+#ifdef Q_OS_WIN
+ WIN32_FIND_DATA data;
+ memset(&data, 0, sizeof(data));
+ data.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
+ /* data.ftLastAccessTime = data.ftLastWriteTime = */
+ data.ftCreationTime = epochToFileTime(afterEpochUtc);
+ meta.fillFromFindData(data);
+#else
+ QT_STATBUF data;
+ memset(&data, 0, sizeof(data));
+ data.st_ctime = afterEpochUtc;
+ meta.fillFromStatBuf(data);
+#endif
+ QCOMPARE(meta.creationTime().toUTC(),
+ QDateTime::fromMSecsSinceEpoch(afterEpochUtc * qint64(1000), Qt::UTC));
+}
+#else // i.e. no Q_AUTOTEST_EXPORT
+void tst_QFileSystemMetaData::timeSinceEpoch()
+{
+ QSKIP("QFileSystemMetaData methods aren't available to test");
+}
+#endif
+QTEST_MAIN(tst_QFileSystemMetaData)
+#include <tst_qfilesystemmetadata.moc>
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
index 7b83d5dbe8..7a304fe779 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-CONFIG -= app_bundle
TARGET = tst_qlockfile
SOURCES += tst_qlockfile.cpp
diff --git a/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro b/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro
index e46e7e1100..8e46320e0c 100644
--- a/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro
+++ b/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro
@@ -1,4 +1,4 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT = core testlib
SOURCES = tst_qprocessnoapplication.cpp
diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro
index 96d105a4b4..7d6a7973dc 100644
--- a/tests/auto/corelib/io/qprocess/test/test.pro
+++ b/tests/auto/corelib/io/qprocess/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT = core-private testlib network
SOURCES = ../tst_qprocess.cpp
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 82efbdcb2c..0783a65d8b 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -1015,7 +1015,7 @@ void tst_QProcess::softExitInSlots()
SoftExitProcess proc(signalToConnect);
proc.writeAfterStart("OLEBOLE", 8); // include the \0
proc.start(appName);
- QTRY_VERIFY_WITH_TIMEOUT(proc.waitedForFinished, 10000);
+ QTRY_VERIFY_WITH_TIMEOUT(proc.waitedForFinished, 60000);
QCOMPARE(proc.state(), QProcess::NotRunning);
}
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index 199ab442c4..332c2dcc01 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -184,6 +184,7 @@ private slots:
void embeddedZeroByte_data();
void embeddedZeroByte();
+ void testXdg();
private:
void cleanupTestFiles();
@@ -3565,5 +3566,77 @@ void tst_QSettings::consistentRegistryStorage()
}
#endif
+#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(QT_NO_STANDARDPATHS)
+QT_BEGIN_NAMESPACE
+extern void clearDefaultPaths();
+QT_END_NAMESPACE
+#endif
+void tst_QSettings::testXdg()
+{
+#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(QT_NO_STANDARDPATHS)
+ // Note: The XDG_CONFIG_DIRS test must be done before overriding the system path
+ // by QSettings::setPath/setSystemIniPath (used in cleanupTestFiles()).
+ clearDefaultPaths();
+
+ // Initialize the env. variable & populate testing files.
+ const QStringList config_dirs = { settingsPath("xdg_1st"), settingsPath("xdg_2nd"), settingsPath("xdg_3rd") };
+ qputenv("XDG_CONFIG_DIRS", config_dirs.join(':').toUtf8());
+ QList<QSettings *> xdg_orgs, xdg_apps;
+ for (const auto & dir : config_dirs) {
+ xdg_orgs << new QSettings{dir + "/software.org.conf", QSettings::NativeFormat};
+ xdg_apps << new QSettings{dir + "/software.org/KillerAPP.conf", QSettings::NativeFormat};
+ }
+ Q_ASSERT(config_dirs.size() == 3 && xdg_orgs.size() == 3 && xdg_apps.size() == 3);
+ for (int i = 0; i < 3; ++i) {
+ xdg_orgs[i]->setValue("all", QString{"all_org%1"}.arg(i));
+ xdg_apps[i]->setValue("all", QString{"all_app%1"}.arg(i));
+ xdg_orgs[i]->setValue("all_only_org", QString{"all_only_org%1"}.arg(i));
+ xdg_apps[i]->setValue("all_only_app", QString{"all_only_app%1"}.arg(i));
+
+ if (i > 0) {
+ xdg_orgs[i]->setValue("from2nd", QString{"from2nd_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from2nd", QString{"from2nd_app%1"}.arg(i));
+ xdg_orgs[i]->setValue("from2nd_only_org", QString{"from2nd_only_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from2nd_only_app", QString{"from2nd_only_app%1"}.arg(i));
+ }
+
+ if (i > 1) {
+ xdg_orgs[i]->setValue("from3rd", QString{"from3rd_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from3rd", QString{"from3rd_app%1"}.arg(i));
+ xdg_orgs[i]->setValue("from3rd_only_org", QString{"from3rd_only_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from3rd_only_app", QString{"from3rd_only_app%1"}.arg(i));
+ }
+ }
+ qDeleteAll(xdg_apps);
+ qDeleteAll(xdg_orgs);
+
+ // Do the test.
+ QSettings app{QSettings::SystemScope, "software.org", "KillerAPP"}, org{QSettings::SystemScope, "software.org"};
+
+ QVERIFY(app.value("all").toString() == "all_app0");
+ QVERIFY(org.value("all").toString() == "all_org0");
+ QVERIFY(app.value("all_only_org").toString() == "all_only_org0");
+ QVERIFY(org.value("all_only_org").toString() == "all_only_org0");
+ QVERIFY(app.value("all_only_app").toString() == "all_only_app0");
+ QVERIFY(org.value("all_only_app").toString() == QString{});
+
+ QVERIFY(app.value("from2nd").toString() == "from2nd_app1");
+ QVERIFY(org.value("from2nd").toString() == "from2nd_org1");
+ QVERIFY(app.value("from2nd_only_org").toString() == "from2nd_only_org1");
+ QVERIFY(org.value("from2nd_only_org").toString() == "from2nd_only_org1");
+ QVERIFY(app.value("from2nd_only_app").toString() == "from2nd_only_app1");
+ QVERIFY(org.value("from2nd_only_app").toString() == QString{});
+
+ QVERIFY(app.value("from3rd").toString() == "from3rd_app2");
+ QVERIFY(org.value("from3rd").toString() == "from3rd_org2");
+ QVERIFY(app.value("from3rd_only_org").toString() == "from3rd_only_org2");
+ QVERIFY(org.value("from3rd_only_org").toString() == "from3rd_only_org2");
+ QVERIFY(app.value("from3rd_only_app").toString() == "from3rd_only_app2");
+ QVERIFY(org.value("from3rd_only_app").toString() == QString{});
+#else
+ QSKIP("This test is performed in QT_BUILD_INTERNAL on Q_XDG_PLATFORM with use of standard paths only.");
+#endif
+}
+
QTEST_MAIN(tst_QSettings)
#include "tst_qsettings.moc"
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index a7a761a2da..0a00e00d83 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -385,7 +385,7 @@ void tst_qstandardpaths::testFindExecutable_data()
QTest::newRow("win-cmd-nosuffix")
<< QString() << QString::fromLatin1("cmd") << cmdPath;
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8) {
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8) {
// The logo executable on Windows 8 is perfectly suited for testing that the
// suffix mechanism is not thrown off by dots in the name.
// Note: Requires disabling WOW64 redirection, see initTestCase()
diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
index 487c13be94..758bbead84 100644
--- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
+++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
@@ -57,6 +57,8 @@ private slots:
void fileTemplate_data();
void getSetCheck();
void fileName();
+ void filePath_data();
+ void filePath();
void autoRemove();
void nonWritableCurrentDir();
void openOnRootDrives();
@@ -204,6 +206,29 @@ void tst_QTemporaryDir::fileName()
QCOMPARE(absoluteFilePath, absoluteTempPath);
}
+void tst_QTemporaryDir::filePath_data()
+{
+ QTest::addColumn<QString>("templatePath");
+ QTest::addColumn<QString>("fileName");
+
+ QTest::newRow("0") << QString() << "/tmpfile";
+ QTest::newRow("1") << QString() << "tmpfile";
+ QTest::newRow("2") << "XXXXX" << "tmpfile";
+ QTest::newRow("3") << "YYYYY" << "subdir/file";
+}
+
+void tst_QTemporaryDir::filePath()
+{
+ QFETCH(QString, templatePath);
+ QFETCH(QString, fileName);
+
+ QTemporaryDir dir(templatePath);
+ const QString filePath = dir.filePath(fileName);
+ const QString expectedFilePath = QDir::isAbsolutePath(fileName) ?
+ QString() : dir.path() + QLatin1Char('/') + fileName;
+ QCOMPARE(filePath, expectedFilePath);
+}
+
void tst_QTemporaryDir::autoRemove()
{
// Test auto remove
diff --git a/tests/auto/corelib/json/json.pro b/tests/auto/corelib/json/json.pro
index 16c2ae2fb7..8fa17c5c38 100644
--- a/tests/auto/corelib/json/json.pro
+++ b/tests/auto/corelib/json/json.pro
@@ -1,6 +1,5 @@
TARGET = tst_json
QT = core-private testlib
-CONFIG -= app_bundle
CONFIG += testcase
!android:TESTDATA += bom.json test.json test.bjson test3.json test2.json
diff --git a/tests/auto/corelib/kernel/qcoreapplication/Info.plist b/tests/auto/corelib/kernel/qcoreapplication/Info.plist
new file mode 100644
index 0000000000..a2927358bc
--- /dev/null
+++ b/tests/auto/corelib/kernel/qcoreapplication/Info.plist
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleVersion</key>
+ <string>1.2.3</string>
+</dict>
+</plist>
diff --git a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro
index d166351490..e37542be65 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro
+++ b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro
@@ -3,4 +3,7 @@ TARGET = tst_qcoreapplication
QT = core testlib core-private
SOURCES = tst_qcoreapplication.cpp
HEADERS = tst_qcoreapplication.h
+win32: VERSION = 1.2.3.4
+else: VERSION = 1.2.3
+darwin: QMAKE_LFLAGS += -Wl,-sectcreate,__TEXT,__info_plist,$$shell_quote($$PWD/Info.plist)
requires(qtConfig(private_tests))
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
index 0feffe0e96..31e76c4407 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
@@ -153,6 +153,41 @@ void tst_QCoreApplication::qAppName()
QCOMPARE(QCoreApplication::applicationName(), QString());
}
+void tst_QCoreApplication::qAppVersion()
+{
+#if defined(Q_OS_WIN)
+ const char appVersion[] = "1.2.3.4";
+#elif defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID)
+ const char appVersion[] = "1.2.3";
+#else
+ const char appVersion[] = "";
+#endif
+
+ {
+ int argc = 0;
+ char *argv[] = { nullptr };
+ TestApplication app(argc, argv);
+ QCOMPARE(QCoreApplication::applicationVersion(), QString::fromLatin1(appVersion));
+ }
+ // The application version should still be available after destruction
+ QCOMPARE(QCoreApplication::applicationVersion(), QString::fromLatin1(appVersion));
+
+ // Setting the appversion before creating the application should work
+ const QString wantedAppVersion("0.0.1");
+ {
+ int argc = 0;
+ char *argv[] = { nullptr };
+ QCoreApplication::setApplicationVersion(wantedAppVersion);
+ TestApplication app(argc, argv);
+ QCOMPARE(QCoreApplication::applicationVersion(), wantedAppVersion);
+ }
+ QCOMPARE(QCoreApplication::applicationVersion(), wantedAppVersion);
+
+ // Restore to initial value
+ QCoreApplication::setApplicationVersion(QString());
+ QCOMPARE(QCoreApplication::applicationVersion(), QString());
+}
+
void tst_QCoreApplication::argc()
{
#if defined(Q_OS_WINRT)
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
index 381ff5d497..b6c20a915f 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
@@ -39,6 +39,7 @@ private slots:
void sendEventsOnProcessEvents(); // this must be the first test
void getSetCheck();
void qAppName();
+ void qAppVersion();
void argc();
void postEvent();
void removePostedEvents();
diff --git a/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro b/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro
index a42cd60236..9dfa29b0fc 100644
--- a/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro
+++ b/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro
@@ -2,4 +2,3 @@ CONFIG += testcase
TARGET = tst_qmetamethod
QT = core testlib
SOURCES = tst_qmetamethod.cpp
-mac:CONFIG -= app_bundle
diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro b/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro
index f3153b3fd4..4da90c1096 100644
--- a/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro
+++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro
@@ -2,4 +2,3 @@ CONFIG += testcase
TARGET = tst_qmetaobjectbuilder
QT = core-private testlib
SOURCES = tst_qmetaobjectbuilder.cpp
-mac:CONFIG -= app_bundle
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 7d9f56ef38..f693d14029 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -377,6 +377,8 @@ void tst_QMetaType::typeName_data()
QT_FOR_EACH_STATIC_TYPE(TYPENAME_DATA)
QTest::newRow("QMetaType::UnknownType") << int(QMetaType::UnknownType) << static_cast<const char*>(0);
+ QTest::newRow("QMetaType::User-1") << (int(QMetaType::User) - 1) << static_cast<const char *>(nullptr);
+ QTest::newRow("QMetaType::FirstWidgetsType-1") << (int(QMetaType::FirstWidgetsType) - 1) << static_cast<const char *>(nullptr);
QTest::newRow("Whity<double>") << ::qMetaTypeId<Whity<double> >() << QString::fromLatin1("Whity<double>");
QTest::newRow("Whity<int>") << ::qMetaTypeId<Whity<int> >() << QString::fromLatin1("Whity<int>");
@@ -404,10 +406,12 @@ void tst_QMetaType::typeName()
QFETCH(int, aType);
QFETCH(QString, aTypeName);
- QString name = QString::fromLatin1(QMetaType::typeName(aType));
+ const char *rawname = QMetaType::typeName(aType);
+ QString name = QString::fromLatin1(rawname);
QCOMPARE(name, aTypeName);
QCOMPARE(name.toLatin1(), QMetaObject::normalizedType(name.toLatin1().constData()));
+ QCOMPARE(rawname == nullptr, aTypeName.isNull());
}
void tst_QMetaType::type_data()
@@ -731,7 +735,7 @@ QT_FOR_EACH_STATIC_CORE_POINTER(ADD_METATYPE_TEST_ROW)
QTest::newRow("QPair<P,C>") << ::qMetaTypeId<QPair<P,C> >() << false << true << false << false;
QTest::newRow("QPair<P,M>") << ::qMetaTypeId<QPair<P,M> >() << true << true << false << false;
QTest::newRow("QPair<P,P>") << ::qMetaTypeId<QPair<P,P> >() << true << false << false << false;
- QTest::newRow("FlagsDataEnum") << ::qMetaTypeId<FlagsDataEnum>() << true << true << false << true;
+ QTest::newRow("FlagsDataEnum") << ::qMetaTypeId<FlagsDataEnum>() << true << false << false << true;
// invalid ids.
QTest::newRow("-1") << -1 << false << false << false << false;
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 50f0061905..e4677c6e34 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -3403,14 +3403,12 @@ void tst_QObject::dumpObjectInfo()
QObject a, b;
QObject::connect(&a, SIGNAL(destroyed(QObject*)), &b, SLOT(deleteLater()));
a.disconnect(&b);
-#ifdef QT_DEBUG
QTest::ignoreMessage(QtDebugMsg, "OBJECT QObject::unnamed");
QTest::ignoreMessage(QtDebugMsg, " SIGNALS OUT");
QTest::ignoreMessage(QtDebugMsg, " signal: destroyed(QObject*)");
QTest::ignoreMessage(QtDebugMsg, " <Disconnected receiver>");
QTest::ignoreMessage(QtDebugMsg, " SIGNALS IN");
QTest::ignoreMessage(QtDebugMsg, " <None>");
-#endif
a.dumpObjectInfo(); // should not crash
}
diff --git a/tests/auto/corelib/kernel/qsharedmemory/test/test.pro b/tests/auto/corelib/kernel/qsharedmemory/test/test.pro
index fabd2cf7a3..61124c27ee 100644
--- a/tests/auto/corelib/kernel/qsharedmemory/test/test.pro
+++ b/tests/auto/corelib/kernel/qsharedmemory/test/test.pro
@@ -2,7 +2,6 @@ CONFIG += testcase
QT = core-private testlib
-mac:CONFIG -= app_bundle
linux:LIBS += -lrt
SOURCES += tst_qsharedmemory.cpp
diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro b/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro
index a0f63741d3..f60207eb01 100644
--- a/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro
+++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro
@@ -2,7 +2,6 @@ CONFIG += testcase
QT = core testlib
win32: CONFIG += console
-mac:CONFIG -= app_bundle
SOURCES += tst_qsystemsemaphore.cpp
TARGET = tst_qsystemsemaphore
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 442f7e80d1..6cb23023c7 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -80,7 +80,7 @@ public:
enum MetaEnumTest_Enum1 { MetaEnumTest_Enum1_value = 42, MetaEnumTest_Enum1_bigValue = (Q_INT64_C(1) << 33) + 50 };
Q_ENUM(MetaEnumTest_Enum1)
- enum MetaEnumTest_Enum3 ENUM_SIZE(qint64) { MetaEnumTest_Enum3_value = -47, MetaEnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5 };
+ enum MetaEnumTest_Enum3 ENUM_SIZE(qint64) { MetaEnumTest_Enum3_value = -47, MetaEnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5, MetaEnumTest_Enum3_bigNegValue = -(Q_INT64_C(1) << 56) - 3 };
Q_ENUM(MetaEnumTest_Enum3)
enum MetaEnumTest_Enum4 ENUM_SIZE(quint64) { MetaEnumTest_Enum4_value = 47, MetaEnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 };
Q_ENUM(MetaEnumTest_Enum4)
@@ -4682,7 +4682,7 @@ template<typename Enum> void testVariant(Enum value, bool *ok)
QVERIFY(var2.convert(QMetaType::Int));
QCOMPARE(var2.value<int>(), static_cast<int>(value));
- if (static_cast<qint64>(value) <= INT_MAX) {
+ if ((static_cast<qint64>(value) <= INT_MAX) && (static_cast<qint64>(value) >= INT_MIN)) {
int intValue = static_cast<int>(value);
QVariant intVar = intValue;
QVERIFY(intVar.canConvert<Enum>());
@@ -4743,7 +4743,7 @@ template<typename Enum> void testVariantMeta(Enum value, bool *ok, const char *s
QVariant strVar = QString::fromLatin1(string);
QVERIFY(strVar.canConvert<Enum>());
- if (value > INT_MAX) {
+ if ((static_cast<qint64>(value) > INT_MAX) || (static_cast<qint64>(value) < INT_MIN)) {
QEXPECT_FAIL("", "QMetaEnum api uses 'int' as return type QTBUG-27451", Abort);
*ok = true;
}
@@ -4765,6 +4765,7 @@ void tst_QVariant::metaEnums()
METAENUMS_TEST(MetaEnumTest_Enum1_bigValue);
METAENUMS_TEST(MetaEnumTest_Enum3_value);
METAENUMS_TEST(MetaEnumTest_Enum3_bigValue);
+ METAENUMS_TEST(MetaEnumTest_Enum3_bigNegValue);
METAENUMS_TEST(MetaEnumTest_Enum4_value);
METAENUMS_TEST(MetaEnumTest_Enum4_bigValue);
METAENUMS_TEST(MetaEnumTest_Enum5_value);
diff --git a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro
index 3345651730..9338f4ecc9 100644
--- a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro
+++ b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro
@@ -17,8 +17,6 @@ win32 {
}
}
-mac: CONFIG -= app_bundle
-
!qtConfig(library) {
LIBS += -L ../bin/ -lplugin1 -lplugin2
}
diff --git a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
index d59cd738bf..6e71ec8ff9 100644
--- a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
+++ b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-CONFIG -= app_bundle
TARGET = ../tst_qlibrary
QT = core testlib
SOURCES = ../tst_qlibrary.cpp
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
index e3d5bff5ff..7f7caa7f76 100644
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
@@ -6,11 +6,16 @@ OTHER_FILES += \
# Needs explicit load()ing due to aux template. Relies on QT being non-empty.
load(qt)
+i386_d.target = good.i386.dylib
+i386_d.depends = EXPORT_VALID_ARCHS=i386
i386.target = good.i386.dylib
-i386.commands = $(CXX) $(CXXFLAGS) -shared -arch i386 -o $@ -I$(INCPATH) $<
+i386.commands = $(CXX) $(CXXFLAGS) -shared -o $@ -I$(INCPATH) $<
i386.depends += $$PWD/../fakeplugin.cpp
+
+x86_64_d.target = good.x86_64.dylib
+x86_64_d.depends = EXPORT_VALID_ARCHS=x86_64
x86_64.target = good.x86_64.dylib
-x86_64.commands = $(CXX) $(CXXFLAGS) -shared -arch x86_64 -o $@ -I$(INCPATH) $<
+x86_64.commands = $(CXX) $(CXXFLAGS) -shared -o $@ -I$(INCPATH) $<
x86_64.depends += $$PWD/../fakeplugin.cpp
# Current Mac OS X toolchains have no compiler for PPC anymore
@@ -49,7 +54,7 @@ bad.depends += $$PWD/generate-bad.pl
MYTARGETS = $$fat_all.depends fat_all fat_no_x86_64 fat_no_i386 \
fat_stub_i386 fat_stub_x86_64 bad
all.depends += $$MYTARGETS
-QMAKE_EXTRA_TARGETS += $$MYTARGETS all
+QMAKE_EXTRA_TARGETS += i386_d x86_64_d $$MYTARGETS all
QMAKE_CLEAN += $$i386.target $$x86_64.target $$ppc64.target $$fat_all.target \
$$fat_no_i386.target $$fat_no_x86_64.target \
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
index 5f9fa6664b..c20e56ba4c 100644
--- a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
@@ -4,7 +4,6 @@ QT = core testlib
qtConfig(private_tests): QT += core-private
SOURCES = ../tst_qpluginloader.cpp ../fakeplugin.cpp
HEADERS = ../theplugin/plugininterface.h
-CONFIG -= app_bundle
win32 {
CONFIG(debug, debug|release) {
diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
index 3e4a6eb7e7..0962001741 100644
--- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
+++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
@@ -102,7 +102,7 @@ void tst_QMutex::convertToMilliseconds_data()
auto add = [](TimeUnit unit, double d, long long i, qint64 expected) {
const QScopedArrayPointer<char> enumName(QTest::toString(unit));
- QTest::newRow(qPrintable(QString::asprintf("%s:%f:%lld", enumName.data(), d, i)))
+ QTest::addRow("%s:%f:%lld", enumName.data(), d, i)
<< unit << d << qint64(i) << expected;
};
diff --git a/tests/auto/corelib/thread/qsemaphore/BLACKLIST b/tests/auto/corelib/thread/qsemaphore/BLACKLIST
index 9f6f6e3ba6..22e30d0fd6 100644
--- a/tests/auto/corelib/thread/qsemaphore/BLACKLIST
+++ b/tests/auto/corelib/thread/qsemaphore/BLACKLIST
@@ -1,3 +1,2 @@
-# Times out randomly on linux, windows, osx
-[tryAcquireWithTimeout]
-*
+[tryAcquireWithTimeout:0.2s]
+windows
diff --git a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp
index e984618bdb..2970b2e118 100644
--- a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp
+++ b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp
@@ -202,8 +202,8 @@ void tst_QSemaphore::tryAcquireWithTimeout_data()
{
QTest::addColumn<int>("timeout");
- QTest::newRow("1s") << 1000;
- QTest::newRow("10s") << 10000;
+ QTest::newRow("0.2s") << 200;
+ QTest::newRow("2s") << 2000;
}
void tst_QSemaphore::tryAcquireWithTimeout()
@@ -212,7 +212,7 @@ void tst_QSemaphore::tryAcquireWithTimeout()
// timers are not guaranteed to be accurate down to the last millisecond,
// so we permit the elapsed times to be up to this far from the expected value.
- int fuzz = 50;
+ int fuzz = 50 + (timeout / 20);
QSemaphore semaphore;
QElapsedTimer time;
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
index 5b7242fddb..fdc4ecb5c8 100644
--- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
@@ -89,6 +89,7 @@ private slots:
void waitForDone();
void clear();
void cancel();
+ void tryTake();
void waitForDoneTimeout();
void destroyingWaitsForTasksToFinish();
void stressTest();
@@ -1042,6 +1043,97 @@ void tst_QThreadPool::cancel()
delete runnables[runs-1];
}
+void tst_QThreadPool::tryTake()
+{
+ QSemaphore sem(0);
+ QSemaphore startedThreads(0);
+
+ class SemaphoreReleaser
+ {
+ QSemaphore &sem;
+ int n;
+ Q_DISABLE_COPY(SemaphoreReleaser)
+ public:
+ explicit SemaphoreReleaser(QSemaphore &sem, int n)
+ : sem(sem), n(n) {}
+
+ ~SemaphoreReleaser()
+ {
+ sem.release(n);
+ }
+ };
+
+ class BlockingRunnable : public QRunnable
+ {
+ public:
+ QSemaphore &sem;
+ QSemaphore &startedThreads;
+ QAtomicInt &dtorCounter;
+ QAtomicInt &runCounter;
+ int dummy;
+
+ explicit BlockingRunnable(QSemaphore &s, QSemaphore &started, QAtomicInt &c, QAtomicInt &r)
+ : sem(s), startedThreads(started), dtorCounter(c), runCounter(r) {}
+
+ ~BlockingRunnable()
+ {
+ dtorCounter.fetchAndAddRelaxed(1);
+ }
+
+ void run() override
+ {
+ startedThreads.release();
+ runCounter.fetchAndAddRelaxed(1);
+ sem.acquire();
+ count.ref();
+ }
+ };
+
+ enum {
+ MaxThreadCount = 3,
+ OverProvisioning = 2,
+ Runs = MaxThreadCount * OverProvisioning
+ };
+
+ QThreadPool threadPool;
+ threadPool.setMaxThreadCount(MaxThreadCount);
+ BlockingRunnable *runnables[Runs];
+
+ // ensure that the QThreadPool doesn't deadlock if any of the checks fail
+ // and cause an early return:
+ const SemaphoreReleaser semReleaser(sem, Runs);
+
+ count.store(0);
+ QAtomicInt dtorCounter = 0;
+ QAtomicInt runCounter = 0;
+ for (int i = 0; i < Runs; i++) {
+ runnables[i] = new BlockingRunnable(sem, startedThreads, dtorCounter, runCounter);
+ runnables[i]->setAutoDelete(i != 0 && i != Runs - 1); // one which will run and one which will not
+ QVERIFY(!threadPool.tryTake(runnables[i])); // verify NOOP for jobs not in the queue
+ threadPool.start(runnables[i]);
+ }
+ // wait for all worker threads to have started up:
+ QVERIFY(startedThreads.tryAcquire(MaxThreadCount, 60*1000 /* 1min */));
+
+ for (int i = 0; i < MaxThreadCount; ++i) {
+ // check taking runnables doesn't work once they were started:
+ QVERIFY(!threadPool.tryTake(runnables[i]));
+ }
+ for (int i = MaxThreadCount; i < Runs ; ++i) {
+ QVERIFY(threadPool.tryTake(runnables[i]));
+ delete runnables[i];
+ }
+
+ runnables[0]->dummy = 0; // valgrind will catch this if tryTake() is crazy enough to delete currently running jobs
+ QCOMPARE(dtorCounter.load(), int(Runs - MaxThreadCount));
+ sem.release(MaxThreadCount);
+ threadPool.waitForDone();
+ QCOMPARE(runCounter.load(), int(MaxThreadCount));
+ QCOMPARE(count.load(), int(MaxThreadCount));
+ QCOMPARE(dtorCounter.load(), int(Runs - 1));
+ delete runnables[0]; // if the pool deletes them then we'll get double-free crash
+}
+
void tst_QThreadPool::destroyingWaitsForTasksToFinish()
{
QTime total, pass;
diff --git a/tests/auto/corelib/thread/qthreadstorage/test/test.pro b/tests/auto/corelib/thread/qthreadstorage/test/test.pro
index b9d661a9af..1a1fede186 100644
--- a/tests/auto/corelib/thread/qthreadstorage/test/test.pro
+++ b/tests/auto/corelib/thread/qthreadstorage/test/test.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = ../tst_qthreadstorage
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
CONFIG += console
QT = core testlib
SOURCES = ../tst_qthreadstorage.cpp
diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
index c14e9fadf7..e13c2894af 100644
--- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
+++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
@@ -1076,22 +1076,22 @@ void tst_QAlgorithms::popCount_data_impl(size_t sizeof_T_Int)
const uint bits = bitsSetInByte(byte);
const quint64 value = static_cast<quint64>(byte);
const quint64 input = value << ((i % sizeof_T_Int) * 8U);
- newRow(qPrintable(QString::asprintf("0x%016llx", input))) << input << bits;
+ QTest::addRow("0x%016llx", input) << input << bits;
}
// and some random ones:
if (sizeof_T_Int >= 8)
for (size_t i = 0; i < 1000; ++i) {
const quint64 input = quint64(qrand()) << 32 | quint32(qrand());
- newRow(qPrintable(QString::asprintf("0x%016llx", input))) << input << bitsSetInInt64(input);
+ QTest::addRow("0x%016llx", input) << input << bitsSetInInt64(input);
}
else if (sizeof_T_Int >= 2)
for (size_t i = 0; i < 1000 ; ++i) {
const quint32 input = qrand();
if (sizeof_T_Int >= 4)
- newRow(qPrintable(QString::asprintf("0x%08x", input))) << quint64(input) << bitsSetInInt(input);
+ QTest::addRow("0x%08x", input) << quint64(input) << bitsSetInInt(input);
else
- newRow(qPrintable(QString::asprintf("0x%04x", quint16(input & 0xFFFF)))) << quint64(input & 0xFFFF) << bitsSetInShort(input & 0xFFFF);
+ QTest::addRow("0x%04x", quint16(input & 0xFFFF)) << quint64(input & 0xFFFF) << bitsSetInShort(input & 0xFFFF);
}
}
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
index 3be8379d29..ba2adddca0 100644
--- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
+++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
@@ -65,6 +65,8 @@ private slots:
void simpleVectorReserve();
void allocate_data();
void allocate();
+ void reallocate_data() { allocate_data(); }
+ void reallocate();
void alignment_data();
void alignment();
void typedData();
@@ -742,6 +744,54 @@ void tst_QArrayData::allocate()
}
}
+void tst_QArrayData::reallocate()
+{
+ QFETCH(size_t, objectSize);
+ QFETCH(size_t, alignment);
+ QFETCH(QArrayData::AllocationOptions, allocateOptions);
+ QFETCH(bool, isCapacityReserved);
+ QFETCH(const QArrayData *, commonEmpty);
+
+ // Maximum alignment that can be requested is that of QArrayData,
+ // otherwise, we can't use reallocate().
+ Q_ASSERT(alignment <= Q_ALIGNOF(QArrayData));
+
+ // Minimum alignment that can be requested is that of QArrayData.
+ // Typically, this alignment is sizeof(void *) and ensured by malloc.
+ size_t minAlignment = qMax(alignment, Q_ALIGNOF(QArrayData));
+
+ int capacity = 10;
+ Deallocator keeper(objectSize, minAlignment);
+ QArrayData *data = QArrayData::allocate(objectSize, minAlignment, capacity,
+ QArrayData::AllocationOptions(allocateOptions) & ~QArrayData::Grow);
+ keeper.headers.append(data);
+
+ memset(data->data(), 'A', objectSize * capacity);
+ data->size = capacity;
+
+ // now try to reallocate
+ int newCapacity = 40;
+ data = QArrayData::reallocateUnaligned(data, objectSize, newCapacity,
+ QArrayData::AllocationOptions(allocateOptions));
+ QVERIFY(data);
+ keeper.headers.clear();
+ keeper.headers.append(data);
+
+ QCOMPARE(data->size, capacity);
+ if (allocateOptions & QArrayData::Grow)
+ QVERIFY(data->alloc > uint(newCapacity));
+ else
+ QCOMPARE(data->alloc, uint(newCapacity));
+ QCOMPARE(data->capacityReserved, uint(isCapacityReserved));
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
+ QFETCH(bool, isSharable);
+ QCOMPARE(data->ref.isSharable(), isSharable);
+#endif
+
+ for (int i = 0; i < capacity; ++i)
+ QCOMPARE(static_cast<char *>(data->data())[i], 'A');
+}
+
class Unaligned
{
char dummy[8];
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
index 310c5f6fd3..16a9c03351 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -43,6 +43,8 @@ public:
tst_QByteArray();
private slots:
void swap();
+ void qChecksum_data();
+ void qChecksum();
void qCompress_data();
#ifndef QT_NO_COMPRESS
void qCompress();
@@ -239,6 +241,34 @@ tst_QByteArray::tst_QByteArray()
{
}
+void tst_QByteArray::qChecksum_data()
+{
+ QTest::addColumn<QByteArray>("data");
+ QTest::addColumn<uint>("len");
+ QTest::addColumn<Qt::ChecksumType>("standard");
+ QTest::addColumn<uint>("checksum");
+
+ // Examples from ISO 14443-3
+ QTest::newRow("1") << QByteArray("\x00\x00") << 2U << Qt::ChecksumItuV41 << 0x1EA0U;
+ QTest::newRow("2") << QByteArray("\x12\x34") << 2U << Qt::ChecksumItuV41 << 0xCF26U;
+ QTest::newRow("3") << QByteArray("\x00\x00\x00") << 3U << Qt::ChecksumIso3309 << 0xC6CCU;
+ QTest::newRow("4") << QByteArray("\x0F\xAA\xFF") << 3U << Qt::ChecksumIso3309 << 0xD1FCU;
+ QTest::newRow("5") << QByteArray("\x0A\x12\x34\x56") << 4U << Qt::ChecksumIso3309 << 0xF62CU;
+}
+
+void tst_QByteArray::qChecksum()
+{
+ QFETCH(QByteArray, data);
+ QFETCH(uint, len);
+ QFETCH(Qt::ChecksumType, standard);
+ QFETCH(uint, checksum);
+
+ if (standard == Qt::ChecksumIso3309) {
+ QCOMPARE(::qChecksum(data.constData(), len), static_cast<quint16>(checksum));
+ }
+ QCOMPARE(::qChecksum(data.constData(), len, standard), static_cast<quint16>(checksum));
+}
+
void tst_QByteArray::qCompress_data()
{
QTest::addColumn<QByteArray>("ba");
@@ -1443,61 +1473,97 @@ void tst_QByteArray::appendAfterFromRawData()
void tst_QByteArray::toFromHex_data()
{
QTest::addColumn<QByteArray>("str");
+ QTest::addColumn<char>("sep");
QTest::addColumn<QByteArray>("hex");
QTest::addColumn<QByteArray>("hex_alt1");
- QTest::newRow("Qt is great!")
+ QTest::newRow("Qt is great! (default)")
<< QByteArray("Qt is great!")
+ << '\0'
<< QByteArray("517420697320677265617421")
<< QByteArray("51 74 20 69 73 20 67 72 65 61 74 21");
+ QTest::newRow("Qt is great! (with space)")
+ << QByteArray("Qt is great!")
+ << ' '
+ << QByteArray("51 74 20 69 73 20 67 72 65 61 74 21")
+ << QByteArray("51 74 20 69 73 20 67 72 65 61 74 21");
+
+ QTest::newRow("Qt is great! (with minus)")
+ << QByteArray("Qt is great!")
+ << '-'
+ << QByteArray("51-74-20-69-73-20-67-72-65-61-74-21")
+ << QByteArray("51-74-20-69-73-20-67-72-65-61-74-21");
+
QTest::newRow("Qt is so great!")
<< QByteArray("Qt is so great!")
+ << '\0'
<< QByteArray("517420697320736f20677265617421")
<< QByteArray("51 74 20 69 73 20 73 6f 20 67 72 65 61 74 21");
QTest::newRow("default-constructed")
<< QByteArray()
+ << '\0'
+ << QByteArray()
+ << QByteArray();
+
+ QTest::newRow("default-constructed (with space)")
+ << QByteArray()
+ << ' '
<< QByteArray()
<< QByteArray();
QTest::newRow("empty")
<< QByteArray("")
+ << '\0'
+ << QByteArray("")
+ << QByteArray("");
+
+ QTest::newRow("empty (with space)")
+ << QByteArray("")
+ << ' '
<< QByteArray("")
<< QByteArray("");
QTest::newRow("array-of-null")
<< QByteArray("\0", 1)
+ << '\0'
<< QByteArray("00")
<< QByteArray("0");
QTest::newRow("no-leading-zero")
<< QByteArray("\xf")
+ << '\0'
<< QByteArray("0f")
<< QByteArray("f");
QTest::newRow("single-byte")
<< QByteArray("\xaf")
+ << '\0'
<< QByteArray("af")
<< QByteArray("xaf");
QTest::newRow("no-leading-zero")
<< QByteArray("\xd\xde\xad\xc0\xde")
+ << '\0'
<< QByteArray("0ddeadc0de")
<< QByteArray("ddeadc0de");
QTest::newRow("garbage")
<< QByteArray("\xC\xde\xeC\xea\xee\xDe\xee\xee")
+ << '\0'
<< QByteArray("0cdeeceaeedeeeee")
<< QByteArray("Code less. Create more. Deploy everywhere.");
QTest::newRow("under-defined-1")
<< QByteArray("\x1\x23")
+ << '\0'
<< QByteArray("0123")
<< QByteArray("x123");
QTest::newRow("under-defined-2")
<< QByteArray("\x12\x34")
+ << '\0'
<< QByteArray("1234")
<< QByteArray("x1234");
}
@@ -1505,16 +1571,23 @@ void tst_QByteArray::toFromHex_data()
void tst_QByteArray::toFromHex()
{
QFETCH(QByteArray, str);
+ QFETCH(char, sep);
QFETCH(QByteArray, hex);
QFETCH(QByteArray, hex_alt1);
- {
+ if (sep == 0) {
const QByteArray th = str.toHex();
QCOMPARE(th.size(), hex.size());
QCOMPARE(th, hex);
}
{
+ const QByteArray th = str.toHex(sep);
+ QCOMPARE(th.size(), hex.size());
+ QCOMPARE(th, hex);
+ }
+
+ {
const QByteArray fh = QByteArray::fromHex(hex);
QCOMPARE(fh.size(), str.size());
QCOMPARE(fh, str);
diff --git a/tests/auto/corelib/tools/qbytearraymatcher/qbytearraymatcher.pro b/tests/auto/corelib/tools/qbytearraymatcher/qbytearraymatcher.pro
index 0624e1886c..9d4d5964c9 100644
--- a/tests/auto/corelib/tools/qbytearraymatcher/qbytearraymatcher.pro
+++ b/tests/auto/corelib/tools/qbytearraymatcher/qbytearraymatcher.pro
@@ -2,3 +2,4 @@ CONFIG += testcase
TARGET = tst_qbytearraymatcher
QT = core testlib
SOURCES = tst_qbytearraymatcher.cpp
+contains(QT_CONFIG, c++14):CONFIG += c++14
diff --git a/tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp b/tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp
index 82cc432d55..647a3ae379 100644
--- a/tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp
+++ b/tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp
@@ -43,10 +43,9 @@ class tst_QByteArrayMatcher : public QObject
private slots:
void interface();
void indexIn();
+ void staticByteArrayMatcher();
};
-static QByteArrayMatcher matcher1;
-
void tst_QByteArrayMatcher::interface()
{
const char needle[] = "abc123";
@@ -56,6 +55,8 @@ void tst_QByteArrayMatcher::interface()
haystack.insert(42, "abc123");
haystack.insert(84, "abc123");
+ QByteArrayMatcher matcher1;
+
matcher1 = QByteArrayMatcher(QByteArray(needle));
QByteArrayMatcher matcher2;
matcher2.setPattern(QByteArray(needle));
@@ -90,8 +91,10 @@ void tst_QByteArrayMatcher::interface()
QCOMPARE(matcher7.indexIn(haystack), 42);
}
-
-static QByteArrayMatcher matcher;
+#define LONG_STRING__32 "abcdefghijklmnopqrstuvwxyz012345"
+#define LONG_STRING__64 LONG_STRING__32 LONG_STRING__32
+#define LONG_STRING_128 LONG_STRING__64 LONG_STRING__64
+#define LONG_STRING_256 LONG_STRING_128 LONG_STRING_128
void tst_QByteArrayMatcher::indexIn()
{
@@ -101,6 +104,8 @@ void tst_QByteArrayMatcher::indexIn()
QByteArray haystack(8, '\0');
haystack[7] = 0x1;
+ QByteArrayMatcher matcher;
+
matcher = QByteArrayMatcher(pattern);
QCOMPARE(matcher.indexIn(haystack, 0), 5);
QCOMPARE(matcher.indexIn(haystack, 1), 5);
@@ -110,7 +115,103 @@ void tst_QByteArrayMatcher::indexIn()
QCOMPARE(matcher.indexIn(haystack, 0), 5);
QCOMPARE(matcher.indexIn(haystack, 1), 5);
QCOMPARE(matcher.indexIn(haystack, 2), 5);
+
+ QByteArray allChars(256, Qt::Uninitialized);
+ for (int i = 0; i < 256; ++i)
+ allChars[i] = char(i);
+
+ matcher = QByteArrayMatcher(allChars);
+ haystack = LONG_STRING__32 "x" + matcher.pattern();
+ QCOMPARE(matcher.indexIn(haystack, 0), 33);
+ QCOMPARE(matcher.indexIn(haystack, 1), 33);
+ QCOMPARE(matcher.indexIn(haystack, 2), 33);
+ QCOMPARE(matcher.indexIn(haystack, 33), 33);
+ QCOMPARE(matcher.indexIn(haystack, 34), -1);
+
+ matcher = QByteArrayMatcher(LONG_STRING_256);
+ haystack = LONG_STRING__32 "x" + matcher.pattern();
+ QCOMPARE(matcher.indexIn(haystack, 0), 33);
+ QCOMPARE(matcher.indexIn(haystack, 1), 33);
+ QCOMPARE(matcher.indexIn(haystack, 2), 33);
+ QCOMPARE(matcher.indexIn(haystack, 33), 33);
+ QCOMPARE(matcher.indexIn(haystack, 34), -1);
}
+void tst_QByteArrayMatcher::staticByteArrayMatcher()
+{
+ {
+ static Q_RELAXED_CONSTEXPR auto smatcher = qMakeStaticByteArrayMatcher("Hello");
+ QCOMPARE(smatcher.pattern(), QByteArrayLiteral("Hello"));
+
+ QCOMPARE(smatcher.indexIn(QByteArray("Hello, World!")), 0);
+ QCOMPARE(smatcher.indexIn(QByteArray("Hello, World!"), 0), 0);
+ QCOMPARE(smatcher.indexIn(QByteArray("Hello, World!"), 1), -1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aHello, World!")), 1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaHello, World!")), 2);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaHello, World!")), 3);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaHello, World!")), 4);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaaHello, World!")), 5);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaaaHello, World!")), 6);
+ QCOMPARE(smatcher.indexIn(QByteArray("HHello, World!")), 1);
+ QCOMPARE(smatcher.indexIn(QByteArray("HeHello, World!")), 2);
+ QCOMPARE(smatcher.indexIn(QByteArray("HelHello, World!")), 3);
+ QCOMPARE(smatcher.indexIn(QByteArray("HellHello, World!")), 4);
+ QCOMPARE(smatcher.indexIn(QByteArray("HellaHello, World!")), 5);
+ QCOMPARE(smatcher.indexIn(QByteArray("HellauHello, World!")), 6);
+ QCOMPARE(smatcher.indexIn(QByteArray("aHella, World!")), -1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaHella, World!")), -1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaHella, World!")), -1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaHella, World!")), -1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaaHella, World!")), -1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaaaHella, World!")), -1);
+
+ QCOMPARE(smatcher.indexIn(QByteArray("aHello")), 1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaHello")), 2);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaHello")), 3);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaHello")), 4);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaaHello")), 5);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaaaHello")), 6);
+ QCOMPARE(smatcher.indexIn(QByteArray("HHello")), 1);
+ QCOMPARE(smatcher.indexIn(QByteArray("HeHello")), 2);
+ QCOMPARE(smatcher.indexIn(QByteArray("HelHello")), 3);
+ QCOMPARE(smatcher.indexIn(QByteArray("HellHello")), 4);
+ QCOMPARE(smatcher.indexIn(QByteArray("HellaHello")), 5);
+ QCOMPARE(smatcher.indexIn(QByteArray("HellauHello")), 6);
+ QCOMPARE(smatcher.indexIn(QByteArray("aHella")), -1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaHella")), -1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaHella")), -1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaHella")), -1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaaHella")), -1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaaaHella")), -1);
+ }
+
+ {
+ static Q_RELAXED_CONSTEXPR auto smatcher = qMakeStaticByteArrayMatcher(LONG_STRING_256);
+ QCOMPARE(smatcher.pattern(), QByteArrayLiteral(LONG_STRING_256));
+
+ QCOMPARE(smatcher.indexIn(QByteArray("a" LONG_STRING_256)), 1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aa" LONG_STRING_256)), 2);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaa" LONG_STRING_256)), 3);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaa" LONG_STRING_256)), 4);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaa" LONG_STRING_256)), 5);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaaa" LONG_STRING_256)), 6);
+ QCOMPARE(smatcher.indexIn(QByteArray("a" LONG_STRING_256 "a")), 1);
+ QCOMPARE(smatcher.indexIn(QByteArray("aa" LONG_STRING_256 "a")), 2);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaa" LONG_STRING_256 "a")), 3);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaa" LONG_STRING_256 "a")), 4);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaa" LONG_STRING_256 "a")), 5);
+ QCOMPARE(smatcher.indexIn(QByteArray("aaaaaa" LONG_STRING_256 "a")), 6);
+ QCOMPARE(smatcher.indexIn(QByteArray(LONG_STRING__32 "x" LONG_STRING_256)), 33);
+ QCOMPARE(smatcher.indexIn(QByteArray(LONG_STRING__64 "x" LONG_STRING_256)), 65);
+ QCOMPARE(smatcher.indexIn(QByteArray(LONG_STRING_128 "x" LONG_STRING_256)), 129);
+ }
+
+}
+
+#undef LONG_STRING_256
+#undef LONG_STRING_128
+#undef LONG_STRING__64
+#undef LONG_STRING__32
+
QTEST_APPLESS_MAIN(tst_QByteArrayMatcher)
#include "tst_qbytearraymatcher.moc"
diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
index fb436b67d6..13898ace7b 100644
--- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp
+++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
@@ -108,7 +108,7 @@ void tst_QChar::operators_data()
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j)
- QTest::newRow(qPrintable(QString::asprintf("'\\%d' (op) '\\%d'", i, j)))
+ QTest::addRow("'\\%d' (op) '\\%d'", i, j)
<< QChar(ushort(i)) << QChar(ushort(j));
}
}
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index b6c740998e..28ad2d193c 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -80,8 +80,10 @@ private slots:
void fromMSecsSinceEpoch();
void toString_isoDate_data();
void toString_isoDate();
+ void toString_isoDate_extra();
void toString_textDate_data();
void toString_textDate();
+ void toString_textDate_extra();
void toString_rfcDate_data();
void toString_rfcDate();
void toString_enumformat();
@@ -158,8 +160,6 @@ private:
QDateTime invalidDateTime() const { return QDateTime(invalidDate(), invalidTime()); }
QDate invalidDate() const { return QDate(); }
QTime invalidTime() const { return QTime(-1, -1, -1); }
- qint64 minJd() const { return QDateTimePrivate::minJd(); }
- qint64 maxJd() const { return QDateTimePrivate::maxJd(); }
class TimeZoneRollback
{
@@ -642,10 +642,8 @@ void tst_QDateTime::setMSecsSinceEpoch_data()
<< QDateTime(QDate::fromJulianDay(0x7fffffff), QTime(21, 59, 59, 999), Qt::UTC)
<< QDateTime(QDate::fromJulianDay(0x7fffffff), QTime(23, 59, 59, 999));
QTest::newRow("min")
- // + 1 because, in the reference check below, calling addMSecs(qint64min)
- // will internally apply unary minus to -qint64min, resulting in a
- // positive value 1 too big for qint64max, causing an overflow.
- << std::numeric_limits<qint64>::min() + 1
+ // Use -max(), which is min() + 1, to simplify filtering out overflow cases:
+ << -std::numeric_limits<qint64>::max()
<< QDateTime(QDate(-292275056, 5, 16), QTime(16, 47, 4, 193), Qt::UTC)
<< QDateTime(QDate(-292275056, 5, 16), QTime(17, 47, 4, 193), Qt::LocalTime);
QTest::newRow("max")
@@ -746,8 +744,8 @@ void tst_QDateTime::fromMSecsSinceEpoch()
QDateTime dtUtc = QDateTime::fromMSecsSinceEpoch(msecs, Qt::UTC);
QDateTime dtOffset = QDateTime::fromMSecsSinceEpoch(msecs, Qt::OffsetFromUTC, 60*60);
- // LocalTime will overflow for min or max, depending on whether you're
- // East or West of Greenwich. The test passes at GMT.
+ // LocalTime will overflow for "min" or "max" tests, depending on whether
+ // you're East or West of Greenwich. In UTC, we won't overflow.
if (localTimeType == LocalTimeIsUtc
|| msecs != std::numeric_limits<qint64>::max() * localTimeType)
QCOMPARE(dtLocal, utc);
@@ -853,6 +851,28 @@ void tst_QDateTime::toString_isoDate()
QLocale::setDefault(oldLocale);
}
+void tst_QDateTime::toString_isoDate_extra()
+{
+ QDateTime dt = QDateTime::fromMSecsSinceEpoch(0, Qt::UTC);
+ QCOMPARE(dt.toString(Qt::ISODate), QLatin1String("1970-01-01T00:00:00Z"));
+#if QT_CONFIG(timezone)
+ QTimeZone PST("America/Vancouver");
+ if (PST.isValid()) {
+ dt = QDateTime::fromMSecsSinceEpoch(0, PST);
+ QCOMPARE(dt.toString(Qt::ISODate), QLatin1String("1969-12-31T16:00:00-08:00"));
+ } else {
+ qDebug("Missed zone test: no America/Vancouver zone available");
+ }
+ QTimeZone CET("Europe/Berlin");
+ if (CET.isValid()) {
+ dt = QDateTime::fromMSecsSinceEpoch(0, CET);
+ QCOMPARE(dt.toString(Qt::ISODate), QLatin1String("1970-01-01T01:00:00+01:00"));
+ } else {
+ qDebug("Missed zone test: no Europe/Berlin zone available");
+ }
+#endif // timezone
+}
+
void tst_QDateTime::toString_textDate_data()
{
QTest::addColumn<QDateTime>("datetime");
@@ -890,6 +910,49 @@ void tst_QDateTime::toString_textDate()
QCOMPARE(resultDatetime.utcOffset(), datetime.utcOffset());
}
+void tst_QDateTime::toString_textDate_extra()
+{
+ QLatin1String GMT("GMT");
+ QDateTime dt = QDateTime::fromMSecsSinceEpoch(0, Qt::LocalTime);
+ QVERIFY(!dt.toString().endsWith(GMT));
+ dt = QDateTime::fromMSecsSinceEpoch(0, Qt::UTC).toLocalTime();
+ QVERIFY(!dt.toString().endsWith(GMT));
+ if (QTimeZone::systemTimeZone().offsetFromUtc(dt))
+ QVERIFY(dt.toString() != QLatin1String("Thu Jan 1 00:00:00 1970"));
+ else
+ QCOMPARE(dt.toString(), QLatin1String("Thu Jan 1 00:00:00 1970"));
+#if QT_CONFIG(timezone)
+ QTimeZone PST("America/Vancouver");
+ if (PST.isValid()) {
+ dt = QDateTime::fromMSecsSinceEpoch(0, PST);
+# if defined Q_OS_UNIX && !defined Q_OS_DARWIN
+ QCOMPARE(dt.toString(), QLatin1String("Wed Dec 31 16:00:00 1969 PST"));
+# else // QTBUG-57320, QTBUG-57298
+ QVERIFY(dt.toString().startsWith(QLatin1String("Wed Dec 31 16:00:00 1969 ")));
+# endif
+ dt = dt.toLocalTime();
+ QVERIFY(!dt.toString().endsWith(GMT));
+ } else {
+ qDebug("Missed zone test: no America/Vancouver zone available");
+ }
+ QTimeZone CET("Europe/Berlin");
+ if (CET.isValid()) {
+ dt = QDateTime::fromMSecsSinceEpoch(0, CET);
+# if defined Q_OS_UNIX && !defined Q_OS_DARWIN
+ QCOMPARE(dt.toString(), QLatin1String("Thu Jan 1 01:00:00 1970 CET"));
+# else // QTBUG-57320, QTBUG-57298
+ QVERIFY(dt.toString().startsWith(QLatin1String("Thu Jan 1 01:00:00 1970 ")));
+# endif
+ dt = dt.toLocalTime();
+ QVERIFY(!dt.toString().endsWith(GMT));
+ } else {
+ qDebug("Missed zone test: no Europe/Berlin zone available");
+ }
+#endif // timezone
+ dt = QDateTime::fromMSecsSinceEpoch(0, Qt::UTC);
+ QVERIFY(dt.toString().endsWith(GMT));
+}
+
void tst_QDateTime::toString_rfcDate_data()
{
QTest::addColumn<QDateTime>("dt");
@@ -3232,17 +3295,17 @@ void tst_QDateTime::timeZones() const
// Test local to MSecs
// - Test first occurrence 02:00:00 = 1 hour before tran
hourBeforeStd = QDateTime(QDate(2013, 10, 27), QTime(2, 0, 0), cet);
+ QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QCOMPARE(hourBeforeStd.toMSecsSinceEpoch(), dstToStdMSecs - 3600000);
// - Test first occurrence 02:59:59.999 = 1 msec before tran
msecBeforeStd = QDateTime(QDate(2013, 10, 27), QTime(2, 59, 59, 999), cet);
+ QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QCOMPARE(msecBeforeStd.toMSecsSinceEpoch(), dstToStdMSecs - 1);
// - Test second occurrence 02:00:00 = at tran
atStd = QDateTime(QDate(2013, 10, 27), QTime(2, 0, 0), cet);
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QCOMPARE(atStd.toMSecsSinceEpoch(), dstToStdMSecs);
// - Test second occurrence 03:00:00 = 59 mins after tran
afterStd = QDateTime(QDate(2013, 10, 27), QTime(2, 59, 59, 999), cet);
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QCOMPARE(afterStd.toMSecsSinceEpoch(), dstToStdMSecs + 3600000 - 1);
// - Test 03:00:00 = 1 hour after tran
hourAfterStd = QDateTime(QDate(2013, 10, 27), QTime(3, 0, 0), cet);
diff --git a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp
index 06e2e1cc45..a68671d899 100644
--- a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp
+++ b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp
@@ -176,9 +176,9 @@ void tst_QLatin1String::relationalOperators_data()
for (Data *lhs = data; lhs != data + sizeof data / sizeof *data; ++lhs) {
for (Data *rhs = data; rhs != data + sizeof data / sizeof *data; ++rhs) {
QLatin1StringContainer l = { lhs->l1 }, r = { rhs->l1 };
- QTest::newRow(qPrintable(QString::asprintf("\"%s\" <> \"%s\"",
- lhs->l1.data() ? lhs->l1.data() : "nullptr",
- rhs->l1.data() ? rhs->l1.data() : "nullptr")))
+ QTest::addRow("\"%s\" <> \"%s\"",
+ lhs->l1.data() ? lhs->l1.data() : "nullptr",
+ rhs->l1.data() ? rhs->l1.data() : "nullptr")
<< l << lhs->order << r << rhs->order;
}
}
diff --git a/tests/auto/corelib/tools/qlocale/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro
index 595ee258e7..c87e29e764 100644
--- a/tests/auto/corelib/tools/qlocale/test/test.pro
+++ b/tests/auto/corelib/tools/qlocale/test/test.pro
@@ -1,5 +1,4 @@
CONFIG += console testcase
-CONFIG -= app_bundle
QT = core testlib core-private
embedded: QT += gui
SOURCES = ../tst_qlocale.cpp
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index d18af71e20..5d13d9e454 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -1601,9 +1601,7 @@ void tst_QLocale::macDefaultLocale()
// To run this test make sure "Curreny" is US Dollar in System Preferences->Language & Region->Advanced.
if (locale.currencySymbol() == QString("$")) {
QCOMPARE(locale.toCurrencyString(qulonglong(1234)), systemLocaleFormatNumber(QString("$1,234.00")));
- QCOMPARE(locale.toCurrencyString(qlonglong(-1234)), systemLocaleFormatNumber(QString("($1,234.00)")));
QCOMPARE(locale.toCurrencyString(double(1234.56)), systemLocaleFormatNumber(QString("$1,234.56")));
- QCOMPARE(locale.toCurrencyString(double(-1234.56)), systemLocaleFormatNumber(QString("($1,234.56)")));
}
// Depending on the configured time zone, the time string might not
@@ -1803,6 +1801,30 @@ void tst_QLocale::numberOptions()
QVERIFY(ok);
locale.toDouble(QString("1.24e+01"), &ok);
QVERIFY(!ok);
+
+ QCOMPARE(locale.toString(12.4, 'g', 5), QString("12.4"));
+ locale.setNumberOptions(QLocale::IncludeTrailingZeroesAfterDot);
+ QCOMPARE(locale.numberOptions(), QLocale::IncludeTrailingZeroesAfterDot);
+ QCOMPARE(locale.toString(12.4, 'g', 5), QString("12.400"));
+
+ locale.toDouble(QString("1.24e+01"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("1.2400e+01"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("12.4"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("12.400"), &ok);
+ QVERIFY(ok);
+ locale.setNumberOptions(QLocale::RejectTrailingZeroesAfterDot);
+ QCOMPARE(locale.numberOptions(), QLocale::RejectTrailingZeroesAfterDot);
+ locale.toDouble(QString("1.24e+01"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("1.2400e+01"), &ok);
+ QVERIFY(!ok);
+ locale.toDouble(QString("12.4"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("12.400"), &ok);
+ QVERIFY(!ok);
}
void tst_QLocale::negativeNumbers()
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 414ba2d8cf..03436375dd 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -1066,6 +1066,7 @@ void tst_QString::acc_01()
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wformat-security")
+QT_WARNING_DISABLE_CLANG("-Wformat-security")
void tst_QString::isNull()
{
@@ -3817,7 +3818,7 @@ void tst_QString::startsWith()
QVERIFY( !a.startsWith(QLatin1Char('x')) );
QVERIFY( !a.startsWith(QChar()) );
- a = QString::null;
+ a = QString();
QVERIFY( !a.startsWith("") );
QVERIFY( a.startsWith(QString::null) );
QVERIFY( !a.startsWith("ABC") );
@@ -3927,7 +3928,7 @@ void tst_QString::endsWith()
QVERIFY( a.endsWith(QLatin1String(0)) );
QVERIFY( !a.endsWith(QLatin1String("ABC")) );
- a = QString::null;
+ a = QString();
QVERIFY( !a.endsWith("") );
QVERIFY( a.endsWith(QString::null) );
QVERIFY( !a.endsWith("ABC") );
@@ -4272,11 +4273,7 @@ void tst_QString::local8Bit_data()
QTest::addColumn<QString>("local8Bit");
QTest::addColumn<QByteArray>("result");
-/*
- QString::local8Bit() called on a null QString returns an _empty_
- QByteArray.
-*/
- QTest::newRow("nullString") << QString() << QByteArray("");
+ QTest::newRow("nullString") << QString() << QByteArray();
QTest::newRow("emptyString") << QString("") << QByteArray("");
QTest::newRow("string") << QString("test") << QByteArray("test");
@@ -6070,6 +6067,14 @@ void tst_QString::compare_data()
lower += QChar(QChar::lowSurrogate(0x10428));
QTest::newRow("data8") << upper << lower << -1 << 0;
+ QTest::newRow("vectorized-boundaries-7") << QString("1234567") << QString("abcdefg") << -1 << -1;
+ QTest::newRow("vectorized-boundaries-8") << QString("12345678") << QString("abcdefgh") << -1 << -1;
+ QTest::newRow("vectorized-boundaries-9") << QString("123456789") << QString("abcdefghi") << -1 << -1;
+
+ QTest::newRow("vectorized-boundaries-15") << QString("123456789012345") << QString("abcdefghiklmnop") << -1 << -1;
+ QTest::newRow("vectorized-boundaries-16") << QString("1234567890123456") << QString("abcdefghiklmnopq") << -1 << -1;
+ QTest::newRow("vectorized-boundaries-17") << QString("12345678901234567") << QString("abcdefghiklmnopqr") << -1 << -1;
+
// embedded nulls
// These don't work as of now. It's OK that these don't work since \0 is not a valid unicode
/*QTest::newRow("data10") << QString(QByteArray("\0", 1)) << QString(QByteArray("\0", 1)) << 0 << 0;
@@ -6337,7 +6342,7 @@ void tst_QString::repeatedSignature() const
{
/* repated() should be a const member. */
const QString string;
- string.repeated(3);
+ (void) string.repeated(3);
}
void tst_QString::repeated() const
diff --git a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp
index 7305a00d94..9d9b47b61e 100644
--- a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp
+++ b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp
@@ -34,6 +34,7 @@
#include <QChar>
#include <QStringRef>
#include <QLatin1String>
+#include <QVector>
#include <QTest>
@@ -71,6 +72,10 @@ class tst_QStringApiSymmetry : public QObject
{
Q_OBJECT
+ //
+ // Mixed UTF-16, UTF-8, Latin-1 checks:
+ //
+
void compare_data(bool hasConceptOfNullAndEmpty=true);
template <typename LHS, typename RHS>
void compare_impl() const;
@@ -155,6 +160,44 @@ private Q_SLOTS:
//void compare_const_char_star_const_char_star_data() { compare_data(); }
//void compare_const_char_star_const_char_star() { compare_impl<const char *, const char *>(); }
+ //
+ // UTF-16-only checks:
+ //
+private:
+
+ void toLocal8Bit_data();
+ template <typename String> void toLocal8Bit_impl();
+
+ void toLatin1_data();
+ template <typename String> void toLatin1_impl();
+
+ void toUtf8_data();
+ template <typename String> void toUtf8_impl();
+
+ void toUcs4_data();
+ template <typename String> void toUcs4_impl();
+
+private Q_SLOTS:
+
+ void toLocal8Bit_QString_data() { toLocal8Bit_data(); }
+ void toLocal8Bit_QString() { toLocal8Bit_impl<QString>(); }
+ void toLocal8Bit_QStringRef_data() { toLocal8Bit_data(); }
+ void toLocal8Bit_QStringRef() { toLocal8Bit_impl<QStringRef>(); }
+
+ void toLatin1_QString_data() { toLatin1_data(); }
+ void toLatin1_QString() { toLatin1_impl<QString>(); }
+ void toLatin1_QStringRef_data() { toLatin1_data(); }
+ void toLatin1_QStringRef() { toLatin1_impl<QStringRef>(); }
+
+ void toUtf8_QString_data() { toUtf8_data(); }
+ void toUtf8_QString() { toUtf8_impl<QString>(); }
+ void toUtf8_QStringRef_data() { toUtf8_data(); }
+ void toUtf8_QStringRef() { toUtf8_impl<QStringRef>(); }
+
+ void toUcs4_QString_data() { toUcs4_data(); }
+ void toUcs4_QString() { toUcs4_impl<QString>(); }
+ void toUcs4_QStringRef_data() { toUcs4_data(); }
+ void toUcs4_QStringRef() { toUcs4_impl<QStringRef>(); }
};
void tst_QStringApiSymmetry::compare_data(bool hasConceptOfNullAndEmpty)
@@ -257,6 +300,159 @@ void tst_QStringApiSymmetry::compare_impl() const
#undef CHECK
}
+//
+//
+// UTF-16-only checks:
+//
+//
+
+template <class Str> Str make(const QString &s);
+template <> QStringRef make(const QString &s) { return QStringRef(&s); }
+template <> QString make(const QString &s) { return s; }
+
+#define REPEAT_16X(X) X X X X X X X X X X X X X X X X
+#define LONG_STRING_256 REPEAT_16X("0123456789abcdef")
+
+void tst_QStringApiSymmetry::toLocal8Bit_data()
+{
+ QTest::addColumn<QString>("unicode");
+ QTest::addColumn<QByteArray>("local");
+
+ auto add = [](const char *local) {
+ const QByteArray ba(local);
+ QString s;
+ for (char c : ba)
+ s += QLatin1Char(c);
+ QTest::addRow("\"%s\" (%d)", ba.left(16).constData(), ba.size()) << s << ba;
+ };
+
+ QTest::addRow("null") << QString() << QByteArray();
+ QTest::addRow("empty") << QString("") << QByteArray("");
+
+ add("Moebius");
+ add(LONG_STRING_256);
+}
+
+template <typename String>
+void tst_QStringApiSymmetry::toLocal8Bit_impl()
+{
+ QFETCH(const QString, unicode);
+ QFETCH(const QByteArray, local);
+
+ const auto str = make<String>(unicode);
+
+ const auto result = str.toLocal8Bit();
+
+ QCOMPARE(result, local);
+ QCOMPARE(unicode.isEmpty(), result.isEmpty());
+ QCOMPARE(unicode.isNull(), result.isNull());
+}
+
+void tst_QStringApiSymmetry::toLatin1_data()
+{
+ QTest::addColumn<QString>("unicode");
+ QTest::addColumn<QByteArray>("latin1");
+
+ auto add = [](const char *l1) {
+ const QByteArray ba(l1);
+ QString s;
+ for (char c : ba)
+ s += QLatin1Char(c);
+ QTest::addRow("\"%s\" (%d)", ba.left(16).constData(), ba.size()) << s << ba;
+ };
+
+ QTest::addRow("null") << QString() << QByteArray();
+ QTest::addRow("empty") << QString("") << QByteArray("");
+
+ add("M\xF6" "bius");
+ add(LONG_STRING_256);
+}
+
+template <typename String>
+void tst_QStringApiSymmetry::toLatin1_impl()
+{
+ QFETCH(const QString, unicode);
+ QFETCH(const QByteArray, latin1);
+
+ const auto str = make<String>(unicode);
+
+ const auto result = str.toLatin1();
+
+ QCOMPARE(result, latin1);
+ QCOMPARE(unicode.isEmpty(), result.isEmpty());
+ QCOMPARE(unicode.isNull(), result.isNull());
+}
+
+void tst_QStringApiSymmetry::toUtf8_data()
+{
+ QTest::addColumn<QString>("unicode");
+ QTest::addColumn<QByteArray>("utf8");
+
+ auto add = [](const char *u8) {
+ QByteArray ba(u8);
+ QString s = ba;
+ QTest::addRow("\"%s\" (%d)", ba.left(16).constData(), ba.size()) << s << ba;
+ };
+
+ QTest::addRow("null") << QString() << QByteArray();
+ QTest::addRow("empty") << QString("") << QByteArray("");
+
+ add("M\xC3\xB6" "bius");
+ add(LONG_STRING_256);
+}
+
+template <typename String>
+void tst_QStringApiSymmetry::toUtf8_impl()
+{
+ QFETCH(const QString, unicode);
+ QFETCH(const QByteArray, utf8);
+
+ const auto str = make<String>(unicode);
+
+ const auto result = str.toUtf8();
+
+ QCOMPARE(result, utf8);
+ QCOMPARE(unicode.isEmpty(), result.isEmpty());
+ QCOMPARE(unicode.isNull(), result.isNull());
+}
+
+void tst_QStringApiSymmetry::toUcs4_data()
+{
+ QTest::addColumn<QString>("unicode");
+ QTest::addColumn<QVector<uint>>("ucs4");
+
+ auto add = [](const char *l1) {
+ const QByteArray ba(l1);
+ QString s;
+ QVector<uint> ucs4;
+ for (char c : ba) {
+ s += QLatin1Char(c);
+ ucs4.append(uint(uchar(c)));
+ }
+ QTest::addRow("\"%s\" (%d)", ba.left(16).constData(), ba.size()) << s << ucs4;
+ };
+
+ QTest::addRow("null") << QString() << QVector<uint>();
+ QTest::addRow("empty") << QString("") << QVector<uint>();
+
+ add("M\xF6" "bius");
+ add(LONG_STRING_256);
+}
+
+template <typename String>
+void tst_QStringApiSymmetry::toUcs4_impl()
+{
+ QFETCH(const QString, unicode);
+ QFETCH(const QVector<uint>, ucs4);
+
+ const auto str = make<String>(unicode);
+
+ const auto result = str.toUcs4();
+
+ QCOMPARE(result, ucs4);
+ QCOMPARE(unicode.isEmpty(), ucs4.isEmpty());
+}
+
QTEST_APPLESS_MAIN(tst_QStringApiSymmetry)
#include "tst_qstringapisymmetry.moc"
diff --git a/tests/auto/corelib/tools/qtimezone/qtimezone.pro b/tests/auto/corelib/tools/qtimezone/qtimezone.pro
index afc4c59dfe..19ebc13306 100644
--- a/tests/auto/corelib/tools/qtimezone/qtimezone.pro
+++ b/tests/auto/corelib/tools/qtimezone/qtimezone.pro
@@ -5,3 +5,8 @@ SOURCES = tst_qtimezone.cpp
qtConfig(icu) {
DEFINES += QT_USE_ICU
}
+
+darwin {
+ OBJECTIVE_SOURCES += tst_qtimezone_darwin.mm
+ LIBS += -framework Foundation
+}
diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
index c631b395f8..c1f2822b74 100644
--- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
@@ -45,6 +45,8 @@ private slots:
void dataStreamTest();
void isTimeZoneIdAvailable();
void availableTimeZoneIds();
+ void transitionEachZone_data();
+ void transitionEachZone();
void stressTest();
void windowsId();
void isValidId_data();
@@ -54,23 +56,24 @@ private slots:
void icuTest();
void tzTest();
void macTest();
+ void darwinTypes();
void winTest();
private:
- void printTimeZone(const QTimeZone tz);
+ void printTimeZone(const QTimeZone &tz);
#ifdef QT_BUILD_INTERNAL
void testCetPrivate(const QTimeZonePrivate &tzp);
#endif // QT_BUILD_INTERNAL
- bool debug;
+ const bool debug;
};
tst_QTimeZone::tst_QTimeZone()
-{
// Set to true to print debug output, test Display Names and run long stress tests
- debug = false;
+ : debug(false)
+{
}
-void tst_QTimeZone::printTimeZone(const QTimeZone tz)
+void tst_QTimeZone::printTimeZone(const QTimeZone &tz)
{
QDateTime now = QDateTime::currentDateTime();
QDateTime jan = QDateTime(QDate(2012, 1, 1), QTime(0, 0, 0), Qt::UTC);
@@ -343,6 +346,7 @@ void tst_QTimeZone::isTimeZoneIdAvailable()
foreach (const QByteArray &id, available)
QVERIFY(QTimeZone::isTimeZoneIdAvailable(id));
+#ifdef QT_BUILD_INTERNAL
// a-z, A-Z, 0-9, '.', '-', '_' are valid chars
// Can't start with '-'
// Parts separated by '/', each part min 1 and max of 14 chars
@@ -365,6 +369,57 @@ void tst_QTimeZone::isTimeZoneIdAvailable()
QCOMPARE(QTimeZonePrivate::isValidId("123456789012345"), false);
QCOMPARE(QTimeZonePrivate::isValidId("123456789012345/12345678901234"), false);
QCOMPARE(QTimeZonePrivate::isValidId("12345678901234/123456789012345"), false);
+#endif // QT_BUILD_INTERNAL
+}
+
+void tst_QTimeZone::transitionEachZone_data()
+{
+ QTest::addColumn<QByteArray>("zone");
+ QTest::addColumn<qint64>("secs");
+ QTest::addColumn<int>("start");
+ QTest::addColumn<int>("stop");
+
+ struct {
+ qint64 baseSecs;
+ int start, stop;
+ int year;
+ } table[] = {
+ { 25666200, 3, 12, 1970 }, // 1970-10-25 01:30 UTC; North America
+ { 1288488600, -4, 8, 2010 } // 2010-10-31 01:30 UTC; Europe, Russia
+ };
+
+ QString name;
+ for (int k = sizeof(table) / sizeof(table[0]); k-- > 0; ) {
+ foreach (QByteArray zone, QTimeZone::availableTimeZoneIds()) {
+ name.sprintf("%s@%d", zone.constData(), table[k].year);
+ QTest::newRow(name.toUtf8().constData())
+ << zone
+ << table[k].baseSecs
+ << table[k].start
+ << table[k].stop;
+ }
+ }
+}
+
+void tst_QTimeZone::transitionEachZone()
+{
+ // Regression test: round-trip fromMsecs/toMSecs should be idempotent; but
+ // various zones failed during fall-back transitions.
+ QFETCH(QByteArray, zone);
+ QFETCH(qint64, secs);
+ QFETCH(int, start);
+ QFETCH(int, stop);
+ QTimeZone named(zone);
+
+ for (int i = start; i < stop; i++) {
+ qint64 here = secs + i * 3600;
+ QDateTime when = QDateTime::fromMSecsSinceEpoch(here * 1000, named);
+ qint64 stamp = when.toMSecsSinceEpoch();
+ if (here * 1000 != stamp) // (The +1 is due to using *1*:30 as baseSecs.)
+ qDebug() << "Failing for" << zone << "at half past" << (i + 1) << "UTC";
+ QCOMPARE(stamp % 1000, 0);
+ QCOMPARE(here - stamp / 1000, 0);
+ }
}
void tst_QTimeZone::availableTimeZoneIds()
@@ -704,9 +759,9 @@ void tst_QTimeZone::tzTest()
// Test display names by type, either ICU or abbreviation only
QLocale enUS("en_US");
-#ifdef QT_USE_ICU
// Only test names in debug mode, names used can vary by ICU version installed
if (debug) {
+#ifdef QT_USE_ICU
QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::LongName, enUS),
QString("Central European Standard Time"));
QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::ShortName, enUS),
@@ -726,9 +781,7 @@ void tst_QTimeZone::tzTest()
QString("GMT+01:00"));
QCOMPARE(tzp.displayName(QTimeZone::GenericTime, QTimeZone::OffsetName, enUS),
QString("UTC+01:00"));
- }
#else
- if (debug) {
QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::LongName, enUS),
QString("CET"));
QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::ShortName, enUS),
@@ -747,10 +800,8 @@ void tst_QTimeZone::tzTest()
QString("CET"));
QCOMPARE(tzp.displayName(QTimeZone::GenericTime, QTimeZone::OffsetName, enUS),
QString("CET"));
- }
#endif // QT_USE_ICU
- if (debug) {
// Test Abbreviations
QCOMPARE(tzp.abbreviation(std), QString("CET"));
QCOMPARE(tzp.abbreviation(dst), QString("CEST"));
@@ -907,6 +958,16 @@ void tst_QTimeZone::macTest()
#endif // Q_OS_MAC
}
+void tst_QTimeZone::darwinTypes()
+{
+#ifndef Q_OS_DARWIN
+ QSKIP("This is an Apple-only test");
+#else
+ extern void tst_QTimeZone_darwinTypes(); // in tst_qtimezone_darwin.mm
+ tst_QTimeZone_darwinTypes();
+#endif
+}
+
void tst_QTimeZone::winTest()
{
#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN)
diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone_darwin.mm b/tests/auto/corelib/tools/qtimezone/tst_qtimezone_darwin.mm
new file mode 100644
index 0000000000..de801e55d0
--- /dev/null
+++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone_darwin.mm
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QTimeZone>
+#include <QtTest/QtTest>
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <Foundation/Foundation.h>
+
+void tst_QTimeZone_darwinTypes()
+{
+#if !defined(QT_NO_SYSTEMLOCALE)
+ // QTimeZone <-> CFTimeZone
+ {
+ QTimeZone qtTimeZone("America/Los_Angeles");
+ const CFTimeZoneRef cfTimeZone = qtTimeZone.toCFTimeZone();
+ QCOMPARE(QTimeZone::fromCFTimeZone(cfTimeZone), qtTimeZone);
+ CFRelease(cfTimeZone);
+ }
+ {
+ CFTimeZoneRef cfTimeZone = CFTimeZoneCreateWithName(kCFAllocatorDefault,
+ CFSTR("America/Los_Angeles"), false);
+ const QTimeZone qtTimeZone = QTimeZone::fromCFTimeZone(cfTimeZone);
+ QVERIFY(CFEqual(qtTimeZone.toCFTimeZone(), cfTimeZone));
+ CFRelease(cfTimeZone);
+ }
+ // QTimeZone <-> NSTimeZone
+ {
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QTimeZone qtTimeZone("America/Los_Angeles");
+ const NSTimeZone *nsTimeZone = qtTimeZone.toNSTimeZone();
+ QCOMPARE(QTimeZone::fromNSTimeZone(nsTimeZone), qtTimeZone);
+ [autoreleasepool release];
+ }
+ {
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ NSTimeZone *nsTimeZone = [NSTimeZone timeZoneWithName:@"America/Los_Angeles"];
+ const QTimeZone qtTimeZone = QTimeZone::fromNSTimeZone(nsTimeZone);
+ QVERIFY([qtTimeZone.toNSTimeZone() isEqual:nsTimeZone]);
+ [autoreleasepool release];
+ }
+#endif
+}