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/qpauseanimation/tst_qpauseanimation.cpp64
-rw-r--r--tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp18
-rw-r--r--tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp2
-rw-r--r--tests/auto/corelib/codecs/utf8/tst_utf8.cpp33
-rw-r--r--tests/auto/corelib/global/global.pro1
-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/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp76
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp172
-rw-r--r--tests/auto/corelib/kernel/qobject/test/test.pro3
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp35
-rw-r--r--tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro7
-rw-r--r--tests/auto/corelib/kernel/qtimer/qtimer.pro3
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp8
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp18
-rw-r--r--tests/auto/corelib/thread/qfuture/qfuture.pro2
-rw-r--r--tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro2
-rw-r--r--tests/auto/corelib/thread/qresultstore/qresultstore.pro2
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp39
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp11
-rw-r--r--tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp2
22 files changed, 674 insertions, 97 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/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp
index 25b6216075..290c2abc98 100644
--- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp
+++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp
@@ -40,6 +40,16 @@
#ifdef BAD_TIMER_RESOLUTION
static const char timerError[] = "On this platform, consistent timing is not working properly due to bad timer resolution";
+
+# define WAIT_FOR_STOPPED(animation, duration) \
+ QTest::qWait(duration); \
+ if (animation.state() != QAbstractAnimation::Stopped) \
+ QEXPECT_FAIL("", timerError, Abort); \
+ QCOMPARE(animation.state(), QAbstractAnimation::Stopped)
+#else
+// Use QTRY_COMPARE with one additional timer tick
+# define WAIT_FOR_STOPPED(animation, duration) \
+ QTRY_COMPARE_WITH_TIMEOUT(animation.state(), QAbstractAnimation::Stopped, (duration))
#endif
class TestablePauseAnimation : public QPauseAnimation
@@ -108,11 +118,10 @@ void tst_QPauseAnimation::changeDirectionWhileRunning()
TestablePauseAnimation animation;
animation.setDuration(400);
animation.start();
- QTest::qWait(100);
- QCOMPARE(animation.state(), QAbstractAnimation::Running);
+ QTRY_COMPARE(animation.state(), QAbstractAnimation::Running);
animation.setDirection(QAbstractAnimation::Backward);
- QTest::qWait(animation.totalDuration() + 50);
- QCOMPARE(animation.state(), QAbstractAnimation::Stopped);
+ const int expectedDuration = animation.totalDuration() + 100;
+ WAIT_FOR_STOPPED(animation, expectedDuration);
}
void tst_QPauseAnimation::noTimerUpdates_data()
@@ -137,14 +146,9 @@ void tst_QPauseAnimation::noTimerUpdates()
animation.setDuration(duration);
animation.setLoopCount(loopCount);
animation.start();
- QTest::qWait(animation.totalDuration() + 100);
-
-#ifdef BAD_TIMER_RESOLUTION
- if (animation.state() != QAbstractAnimation::Stopped)
- QEXPECT_FAIL("", timerError, Abort);
-#endif
+ const int expectedDuration = animation.totalDuration() + 150;
+ WAIT_FOR_STOPPED(animation, expectedDuration);
- QCOMPARE(animation.state(), QAbstractAnimation::Stopped);
const int expectedLoopCount = 1 + loopCount;
#ifdef BAD_TIMER_RESOLUTION
@@ -166,13 +170,9 @@ void tst_QPauseAnimation::multiplePauseAnimations()
animation.start();
animation2.start();
- QTest::qWait(animation.totalDuration() + 100);
-#ifdef BAD_TIMER_RESOLUTION
- if (animation.state() != QAbstractAnimation::Stopped)
- QEXPECT_FAIL("", timerError, Abort);
-#endif
- QCOMPARE(animation.state(), QAbstractAnimation::Stopped);
+ const int expectedDuration = animation.totalDuration() + 150;
+ WAIT_FOR_STOPPED(animation, expectedDuration);
#ifdef BAD_TIMER_RESOLUTION
if (animation2.state() != QAbstractAnimation::Running)
@@ -192,13 +192,7 @@ void tst_QPauseAnimation::multiplePauseAnimations()
#endif
QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
- QTest::qWait(550);
-
-#ifdef BAD_TIMER_RESOLUTION
- if (animation2.state() != QAbstractAnimation::Stopped)
- QEXPECT_FAIL("", timerError, Abort);
-#endif
- QCOMPARE(animation2.state(), QAbstractAnimation::Stopped);
+ WAIT_FOR_STOPPED(animation2, 600);
#ifdef BAD_TIMER_RESOLUTION
if (animation2.m_updateCurrentTimeCount != 3)
@@ -229,13 +223,9 @@ void tst_QPauseAnimation::pauseAndPropertyAnimations()
QCOMPARE(pause.state(), QAbstractAnimation::Running);
QCOMPARE(pause.m_updateCurrentTimeCount, 2);
- QTest::qWait(animation.totalDuration() + 100);
+ const int expectedDuration = animation.totalDuration() + 150;
+ WAIT_FOR_STOPPED(animation, expectedDuration);
-#ifdef BAD_TIMER_RESOLUTION
- if (animation.state() != QAbstractAnimation::Stopped)
- QEXPECT_FAIL("", timerError, Abort);
-#endif
- QCOMPARE(animation.state(), QAbstractAnimation::Stopped);
QCOMPARE(pause.state(), QAbstractAnimation::Stopped);
QVERIFY(pause.m_updateCurrentTimeCount > 3);
}
@@ -405,13 +395,8 @@ void tst_QPauseAnimation::multipleSequentialGroups()
// This is a pretty long animation so it tends to get rather out of sync
// when using the consistent timer, so run for an extra half second for good
// measure...
- QTest::qWait(group.totalDuration() + 500);
-
-#ifdef BAD_TIMER_RESOLUTION
- if (group.state() != QAbstractAnimation::Stopped)
- QEXPECT_FAIL("", timerError, Abort);
-#endif
- QCOMPARE(group.state(), QAbstractAnimation::Stopped);
+ const int expectedDuration = group.totalDuration() + 550;
+ WAIT_FOR_STOPPED(group, expectedDuration);
#ifdef BAD_TIMER_RESOLUTION
if (subgroup1.state() != QAbstractAnimation::Stopped)
@@ -449,8 +434,9 @@ void tst_QPauseAnimation::zeroDuration()
TestablePauseAnimation animation;
animation.setDuration(0);
animation.start();
- QTest::qWait(animation.totalDuration() + 100);
- QCOMPARE(animation.state(), QAbstractAnimation::Stopped);
+ const int expectedDuration = animation.totalDuration() + 150;
+ WAIT_FOR_STOPPED(animation, expectedDuration);
+
QCOMPARE(animation.m_updateCurrentTimeCount, 1);
}
diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
index c1a8fde504..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()
@@ -441,10 +441,8 @@ void tst_QPropertyAnimation::noStartValue()
a.setDuration(250);
a.start();
- QTest::qWait(300);
-
- QTRY_COMPARE(o.values.first(), 42);
- QCOMPARE(o.values.last(), 420);
+ QTRY_COMPARE(o.values.value(o.values.size() - 1, -1), 420);
+ QCOMPARE(o.values.first(), 42);
}
void tst_QPropertyAnimation::noStartValueWithLoop()
@@ -674,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/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp
index 5666726a8c..8f78aa937c 100644
--- a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp
+++ b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp
@@ -237,39 +237,6 @@ void tst_Utf8::nonCharacters_data()
QTest::addColumn<QByteArray>("utf8");
QTest::addColumn<QString>("utf16");
- // Unicode has a couple of "non-characters" that one can use internally
- // These characters may be used for interchange;
- // see: http://www.unicode.org/versions/corrigendum9.html
- //
- // Those are the last two entries each Unicode Plane (U+FFFE, U+FFFF,
- // U+1FFFE, U+1FFFF, etc.) as well as the entries between U+FDD0 and
- // U+FDEF (inclusive)
-
- // U+FDD0 through U+FDEF
- for (int i = 0; i < 32; ++i) {
- char utf8[] = { char(0357), char(0267), char(0220 + i), 0 };
- QString utf16 = QChar(0xfdd0 + i);
- QTest::newRow(qPrintable(QString::number(0xfdd0 + i, 16))) << QByteArray(utf8) << utf16;
- }
-
- // the last two in Planes 1 through 16
- for (uint plane = 1; plane <= 16; ++plane) {
- for (uint lower = 0xfffe; lower < 0x10000; ++lower) {
- uint ucs4 = (plane << 16) | lower;
- char utf8[] = { char(0xf0 | uchar(ucs4 >> 18)),
- char(0x80 | (uchar(ucs4 >> 12) & 0x3f)),
- char(0x80 | (uchar(ucs4 >> 6) & 0x3f)),
- char(0x80 | (uchar(ucs4) & 0x3f)),
- 0 };
- ushort utf16[] = { QChar::highSurrogate(ucs4), QChar::lowSurrogate(ucs4), 0 };
-
- QTest::newRow(qPrintable(QString::number(ucs4, 16))) << QByteArray(utf8) << QString::fromUtf16(utf16);
- }
- }
-
- QTest::newRow("fffe") << QByteArray("\xEF\xBF\xBE") << QString(QChar(0xfffe));
- QTest::newRow("ffff") << QByteArray("\xEF\xBF\xBF") << QString(QChar(0xffff));
-
extern void loadNonCharactersRows();
loadNonCharactersRows();
}
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/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/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
index e946f3104a..564b8547b1 100644
--- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
@@ -68,6 +68,8 @@ private slots:
void itemData();
+ void persistIndexOnLayoutChange();
+
protected:
void verifyIdentity(QAbstractItemModel *model, const QModelIndex &parent = QModelIndex());
@@ -377,5 +379,79 @@ void tst_QIdentityProxyModel::itemData()
QCOMPARE(proxy.itemData(topIndex).value(Qt::DisplayRole).toString(), QStringLiteral("Monday_appended"));
}
+void dump(QAbstractItemModel* model, QString const& indent = " - ", QModelIndex const& parent = {})
+{
+ for (auto row = 0; row < model->rowCount(parent); ++row)
+ {
+ auto idx = model->index(row, 0, parent);
+ qDebug() << (indent + idx.data().toString());
+ dump(model, indent + "- ", idx);
+ }
+}
+
+void tst_QIdentityProxyModel::persistIndexOnLayoutChange()
+{
+ DynamicTreeModel model;
+
+ QList<int> ancestors;
+ for (auto i = 0; i < 3; ++i)
+ {
+ Q_UNUSED(i);
+ ModelInsertCommand insertCommand(&model);
+ insertCommand.setAncestorRowNumbers(ancestors);
+ insertCommand.setStartRow(0);
+ insertCommand.setEndRow(0);
+ insertCommand.doCommand();
+ ancestors.push_back(0);
+ }
+ ModelInsertCommand insertCommand(&model);
+ insertCommand.setAncestorRowNumbers(ancestors);
+ insertCommand.setStartRow(0);
+ insertCommand.setEndRow(1);
+ insertCommand.doCommand();
+
+ // dump(&model);
+ // " - 1"
+ // " - - 2"
+ // " - - - 3"
+ // " - - - - 4"
+ // " - - - - 5"
+
+ QIdentityProxyModel proxy;
+ proxy.setSourceModel(&model);
+
+ QPersistentModelIndex persistentIndex;
+
+ QPersistentModelIndex sourcePersistentIndex = model.match(model.index(0, 0), Qt::DisplayRole, "5", 1, Qt::MatchRecursive).first();
+
+ QCOMPARE(sourcePersistentIndex.data().toString(), QStringLiteral("5"));
+
+ bool gotLayoutAboutToBeChanged = false;
+ bool gotLayoutChanged = false;
+
+ QObject::connect(&proxy, &QAbstractItemModel::layoutAboutToBeChanged, &proxy, [&proxy, &persistentIndex, &gotLayoutAboutToBeChanged]
+ {
+ gotLayoutAboutToBeChanged = true;
+ persistentIndex = proxy.match(proxy.index(0, 0), Qt::DisplayRole, "5", 1, Qt::MatchRecursive).first();
+ });
+
+ QObject::connect(&proxy, &QAbstractItemModel::layoutChanged, &proxy, [&proxy, &persistentIndex, &sourcePersistentIndex, &gotLayoutChanged]
+ {
+ gotLayoutChanged = true;
+ QCOMPARE(QModelIndex(persistentIndex), proxy.mapFromSource(sourcePersistentIndex));
+ });
+
+ ModelChangeChildrenLayoutsCommand layoutChangeCommand(&model, 0);
+
+ layoutChangeCommand.setAncestorRowNumbers(QList<int>{0, 0, 0});
+ layoutChangeCommand.setSecondAncestorRowNumbers(QList<int>{0, 0});
+
+ layoutChangeCommand.doCommand();
+
+ QVERIFY(gotLayoutAboutToBeChanged);
+ QVERIFY(gotLayoutChanged);
+ QVERIFY(persistentIndex.isValid());
+}
+
QTEST_MAIN(tst_QIdentityProxyModel)
#include "tst_qidentityproxymodel.moc"
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 38e3c6890d..7b6c470dc4 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -145,6 +145,9 @@ private slots:
void canDropMimeData();
void filterHint();
+ void sourceLayoutChangeLeavesValidPersistentIndexes();
+ void rowMoveLeavesValidPersistentIndexes();
+
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
void checkHierarchy(const QStringList &data, const QAbstractItemModel *model);
@@ -4181,5 +4184,174 @@ void tst_QSortFilterProxyModel::filterHint()
QAbstractItemModel::NoLayoutChangeHint);
}
+/**
+
+ Creates a model where each item has one child, to a set depth,
+ and the last item has no children. For a model created with
+ setDepth(4):
+
+ - 1
+ - - 2
+ - - - 3
+ - - - - 4
+*/
+class StepTreeModel : public QAbstractItemModel
+{
+ Q_OBJECT
+public:
+ StepTreeModel(QObject * parent = 0)
+ : QAbstractItemModel(parent), m_depth(0) {}
+
+ int columnCount(const QModelIndex& = QModelIndex()) const override { return 1; }
+
+ int rowCount(const QModelIndex& parent = QModelIndex()) const override
+ {
+ quintptr parentId = (parent.isValid()) ? parent.internalId() : 0;
+ return (parentId < m_depth) ? 1 : 0;
+ }
+
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override
+ {
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ return QString::number(index.internalId());
+ }
+
+ QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override
+ {
+ quintptr parentId = (parent.isValid()) ? parent.internalId() : 0;
+ if (parentId >= m_depth)
+ return QModelIndex();
+
+ return createIndex(0, 0, parentId + 1);
+ }
+
+ QModelIndex parent(const QModelIndex& index) const override
+ {
+ if (index.internalId() == 0)
+ return QModelIndex();
+
+ return createIndex(0, 0, index.internalId() - 1);
+ }
+
+ void setDepth(quintptr depth)
+ {
+ int parentIdWithLayoutChange = (m_depth < depth) ? m_depth : depth;
+
+ QList<QPersistentModelIndex> parentsOfLayoutChange;
+ parentsOfLayoutChange.push_back(createIndex(0, 0, parentIdWithLayoutChange));
+
+ layoutAboutToBeChanged(parentsOfLayoutChange);
+
+ auto existing = persistentIndexList();
+
+ QList<QModelIndex> updated;
+
+ for (auto idx : existing) {
+ if (indexDepth(idx) <= depth)
+ updated.push_back(idx);
+ else
+ updated.push_back({});
+ }
+
+ m_depth = depth;
+
+ changePersistentIndexList(existing, updated);
+
+ layoutChanged(parentsOfLayoutChange);
+ }
+
+private:
+ static quintptr indexDepth(QModelIndex const& index)
+ {
+ return (index.isValid()) ? 1 + indexDepth(index.parent()) : 0;
+ }
+
+private:
+ quintptr m_depth;
+};
+
+void tst_QSortFilterProxyModel::sourceLayoutChangeLeavesValidPersistentIndexes()
+{
+ StepTreeModel model;
+ Q_SET_OBJECT_NAME(model);
+ model.setDepth(4);
+
+ QSortFilterProxyModel proxy1;
+ proxy1.setSourceModel(&model);
+ Q_SET_OBJECT_NAME(proxy1);
+
+ proxy1.setFilterRegExp("1|2");
+
+ // The current state of things:
+ // model proxy
+ // - 1 - 1
+ // - - 2 - - 2
+ // - - - 3
+ // - - - - 4
+
+ // The setDepth call below removes '4' with a layoutChanged call.
+ // Because the proxy filters that out anyway, the proxy doesn't need
+ // to emit any signals or update persistent indexes.
+
+ QPersistentModelIndex persistentIndex = proxy1.index(0, 0, proxy1.index(0, 0));
+
+ model.setDepth(3);
+
+ // Calling parent() causes the internalPointer to be used.
+ // Before fixing QTBUG-47711, that could be a dangling pointer.
+ // The use of qDebug here makes sufficient use of the heap to
+ // cause corruption at runtime with normal use on linux (before
+ // the fix). valgrind confirms the fix.
+ qDebug() << persistentIndex.parent();
+ QVERIFY(persistentIndex.parent().isValid());
+}
+
+void tst_QSortFilterProxyModel::rowMoveLeavesValidPersistentIndexes()
+{
+ DynamicTreeModel model;
+ Q_SET_OBJECT_NAME(model);
+
+ QList<int> ancestors;
+ for (auto i = 0; i < 5; ++i)
+ {
+ Q_UNUSED(i);
+ ModelInsertCommand insertCommand(&model);
+ insertCommand.setAncestorRowNumbers(ancestors);
+ insertCommand.setStartRow(0);
+ insertCommand.setEndRow(0);
+ insertCommand.doCommand();
+ ancestors.push_back(0);
+ }
+
+ QSortFilterProxyModel proxy1;
+ proxy1.setSourceModel(&model);
+ Q_SET_OBJECT_NAME(proxy1);
+
+ proxy1.setFilterRegExp("1|2");
+
+ auto item5 = model.match(model.index(0, 0), Qt::DisplayRole, "5", 1, Qt::MatchRecursive).first();
+ auto item3 = model.match(model.index(0, 0), Qt::DisplayRole, "3", 1, Qt::MatchRecursive).first();
+
+ Q_ASSERT(item5.isValid());
+ Q_ASSERT(item3.isValid());
+
+ QPersistentModelIndex persistentIndex = proxy1.match(proxy1.index(0, 0), Qt::DisplayRole, "2", 1, Qt::MatchRecursive).first();
+
+ ModelMoveCommand moveCommand(&model, 0);
+ moveCommand.setAncestorRowNumbers(QList<int>{0, 0, 0, 0});
+ moveCommand.setStartRow(0);
+ moveCommand.setEndRow(0);
+ moveCommand.setDestRow(0);
+ moveCommand.setDestAncestors(QList<int>{0, 0, 0});
+ moveCommand.doCommand();
+
+ // Calling parent() causes the internalPointer to be used.
+ // Before fixing QTBUG-47711 (moveRows case), that could be
+ // a dangling pointer.
+ QVERIFY(persistentIndex.parent().isValid());
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/corelib/kernel/qobject/test/test.pro b/tests/auto/corelib/kernel/qobject/test/test.pro
index f3bc045455..4e77cb48c5 100644
--- a/tests/auto/corelib/kernel/qobject/test/test.pro
+++ b/tests/auto/corelib/kernel/qobject/test/test.pro
@@ -3,5 +3,8 @@ TARGET = ../tst_qobject
QT = core-private network testlib
SOURCES = ../tst_qobject.cpp
+# Force C++17 if available (needed due to P0012R1)
+contains(QT_CONFIG, c++1z): CONFIG += c++1z
+
!winrt: TEST_HELPER_INSTALLS = ../signalbug/signalbug
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 5eea858107..f44c40c27f 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -120,6 +120,7 @@ private slots:
void connectCxx0x();
void connectToStaticCxx0x();
void connectCxx0xTypeMatching();
+ void connectCxx17Noexcept();
void connectConvert();
void connectWithReference();
void connectManyArguments();
@@ -4755,10 +4756,13 @@ class LotsOfSignalsAndSlots: public QObject
public slots:
void slot_v() {}
+ void slot_v_noexcept() Q_DECL_NOTHROW {}
void slot_vi(int) {}
+ void slot_vi_noexcept() Q_DECL_NOTHROW {}
void slot_vii(int, int) {}
void slot_viii(int, int, int) {}
int slot_i() { return 0; }
+ int slot_i_noexcept() Q_DECL_NOTHROW { return 0; }
int slot_ii(int) { return 0; }
int slot_iii(int, int) { return 0; }
int slot_iiii(int, int, int) { return 0; }
@@ -4772,13 +4776,18 @@ class LotsOfSignalsAndSlots: public QObject
void slot_vPFvvE(fptr) {}
void const_slot_v() const {};
+ void const_slot_v_noexcept() const Q_DECL_NOTHROW {}
void const_slot_vi(int) const {};
+ void const_slot_vi_noexcept(int) const Q_DECL_NOTHROW {}
static void static_slot_v() {}
+ static void static_slot_v_noexcept() Q_DECL_NOTHROW {}
static void static_slot_vi(int) {}
+ static void static_slot_vi_noexcept(int) Q_DECL_NOTHROW {}
static void static_slot_vii(int, int) {}
static void static_slot_viii(int, int, int) {}
static int static_slot_i() { return 0; }
+ static int static_slot_i_noexcept() Q_DECL_NOTHROW { return 0; }
static int static_slot_ii(int) { return 0; }
static int static_slot_iii(int, int) { return 0; }
static int static_slot_iiii(int, int, int) { return 0; }
@@ -4941,6 +4950,32 @@ void tst_QObject::connectCxx0xTypeMatching()
}
+void receiverFunction_noexcept() Q_DECL_NOTHROW {}
+struct Functor_noexcept { void operator()() Q_DECL_NOTHROW {} };
+void tst_QObject::connectCxx17Noexcept()
+{
+ // this is about connecting signals to slots with the Q_DECL_NOTHROW qualifier
+ // as semantics changed due to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html
+ typedef LotsOfSignalsAndSlots Foo;
+ Foo obj;
+
+ QObject::connect(&obj, &Foo::signal_v, &obj, &Foo::slot_v_noexcept);
+ QObject::connect(&obj, &Foo::signal_v, &obj, &Foo::slot_i_noexcept);
+ QObject::connect(&obj, &Foo::signal_v, &obj, &Foo::slot_vi_noexcept);
+
+ QObject::connect(&obj, &Foo::signal_vii, &Foo::static_slot_v_noexcept);
+ QObject::connect(&obj, &Foo::signal_vii, &Foo::static_slot_i_noexcept);
+ QObject::connect(&obj, &Foo::signal_vii, &Foo::static_slot_vi_noexcept);
+
+ QVERIFY(QObject::connect(&obj, &Foo::signal_vi, &obj, &Foo::const_slot_vi_noexcept));
+ QVERIFY(QObject::connect(&obj, &Foo::signal_vi, &obj, &Foo::const_slot_v_noexcept));
+
+ QObject::connect(&obj, &Foo::signal_v, receiverFunction_noexcept);
+
+ Functor_noexcept fn;
+ QObject::connect(&obj, &Foo::signal_v, fn);
+}
+
class StringVariant : public QObject
{ Q_OBJECT
signals:
diff --git a/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro b/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro
index 69062a9741..3a4697750e 100644
--- a/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro
+++ b/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro
@@ -1,5 +1,6 @@
TEMPLATE = subdirs
-!winrt: SUBDIRS = sharedmemoryhelper
-
-SUBDIRS += test
+qtConfig(sharedmemory) {
+ !winrt: SUBDIRS = sharedmemoryhelper
+ SUBDIRS += test
+}
diff --git a/tests/auto/corelib/kernel/qtimer/qtimer.pro b/tests/auto/corelib/kernel/qtimer/qtimer.pro
index 8afdbb148e..b27d862bc5 100644
--- a/tests/auto/corelib/kernel/qtimer/qtimer.pro
+++ b/tests/auto/corelib/kernel/qtimer/qtimer.pro
@@ -2,3 +2,6 @@ CONFIG += testcase
TARGET = tst_qtimer
QT = core testlib
SOURCES = tst_qtimer.cpp
+
+# Force C++17 if available
+contains(QT_CONFIG, c++1z): CONFIG += c++1z
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index fe97695d19..29ff552f6a 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -767,6 +767,11 @@ class StaticEventLoop
public:
static void quitEventLoop()
{
+ quitEventLoop_noexcept();
+ }
+
+ static void quitEventLoop_noexcept() Q_DECL_NOTHROW
+ {
QVERIFY(!_e.isNull());
_e->quit();
if (_t)
@@ -787,6 +792,9 @@ void tst_QTimer::singleShotToFunctors()
QTimer::singleShot(0, &StaticEventLoop::quitEventLoop);
QCOMPARE(_e->exec(), 0);
+ QTimer::singleShot(0, &StaticEventLoop::quitEventLoop_noexcept);
+ QCOMPARE(_e->exec(), 0);
+
QThread t1;
QObject c1;
c1.moveToThread(&t1);
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 75fa424ab1..2a9b9c0a7f 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)
@@ -400,6 +400,17 @@ void tst_QVariant::isNull()
QVERIFY( !varLL.isNull() );
QVariant var7(QString::null);
QVERIFY(var7.isNull());
+ var7 = QVariant::fromValue<QString>(QString::null);
+ QVERIFY(var7.isNull());
+
+ QVariant var8(QMetaType::Nullptr, nullptr);
+ QVERIFY(var8.isNull());
+ var8 = QVariant::fromValue<std::nullptr_t>(nullptr);
+ QVERIFY(var8.isNull());
+ QVariant var9 = QVariant(QJsonValue(QJsonValue::Null));
+ QVERIFY(var9.isNull());
+ var9 = QVariant::fromValue<QJsonValue>(QJsonValue(QJsonValue::Null));
+ QVERIFY(var9.isNull());
}
void tst_QVariant::swap()
@@ -4660,7 +4671,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>());
@@ -4721,7 +4732,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;
}
@@ -4743,6 +4754,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/thread/qfuture/qfuture.pro b/tests/auto/corelib/thread/qfuture/qfuture.pro
index ed9e189668..b1667760d6 100644
--- a/tests/auto/corelib/thread/qfuture/qfuture.pro
+++ b/tests/auto/corelib/thread/qfuture/qfuture.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
TARGET = tst_qfuture
-QT = core core-private testlib concurrent
+QT = core core-private testlib
SOURCES = tst_qfuture.cpp
DEFINES += QT_STRICT_ITERATORS
diff --git a/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro b/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro
index 5eebd12deb..0d20117ed0 100644
--- a/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro
+++ b/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro
@@ -1,4 +1,4 @@
CONFIG += testcase
TARGET = tst_qfuturesynchronizer
-QT = core testlib concurrent
+QT = core testlib
SOURCES = tst_qfuturesynchronizer.cpp
diff --git a/tests/auto/corelib/thread/qresultstore/qresultstore.pro b/tests/auto/corelib/thread/qresultstore/qresultstore.pro
index 2f6c18f64c..bbebe0976b 100644
--- a/tests/auto/corelib/thread/qresultstore/qresultstore.pro
+++ b/tests/auto/corelib/thread/qresultstore/qresultstore.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
TARGET = tst_qresultstore
-QT = core-private testlib concurrent
+QT = core-private testlib
SOURCES = tst_qresultstore.cpp
DEFINES += QT_STRICT_ITERATORS
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index 7681f4755c..f56cff4d29 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -186,12 +186,50 @@ void tst_QLocale::ctor()
QVERIFY(l.country() == default_country);
}
+#define TEST_CTOR(req_lang, req_script, req_country, exp_lang, exp_script, exp_country) \
+ { \
+ QLocale l(QLocale::req_lang, QLocale::req_script, QLocale::req_country); \
+ QCOMPARE((int)l.language(), (int)exp_lang); \
+ QCOMPARE((int)l.script(), (int)exp_script); \
+ QCOMPARE((int)l.country(), (int)exp_country); \
+ }
+
+ // Exact matches
+ TEST_CTOR(Chinese, SimplifiedHanScript, China, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+ TEST_CTOR(Chinese, TraditionalHanScript, Taiwan, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan);
+ TEST_CTOR(Chinese, TraditionalHanScript, HongKong, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::HongKong);
+
+ // Best match for AnyCountry
+ TEST_CTOR(Chinese, SimplifiedHanScript, AnyCountry, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+ TEST_CTOR(Chinese, TraditionalHanScript, AnyCountry, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan);
+
+ // Best match for AnyScript (and change country to supported one, if necessary)
+ TEST_CTOR(Chinese, AnyScript, China, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+ TEST_CTOR(Chinese, AnyScript, Taiwan, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan);
+ TEST_CTOR(Chinese, AnyScript, HongKong, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::HongKong);
+ TEST_CTOR(Chinese, AnyScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+
+ // Fully-specified not found; find best alternate country
+ TEST_CTOR(Chinese, SimplifiedHanScript, Taiwan, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+ TEST_CTOR(Chinese, SimplifiedHanScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+ TEST_CTOR(Chinese, TraditionalHanScript, China, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan);
+ TEST_CTOR(Chinese, TraditionalHanScript, UnitedStates, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan);
+
+ // Fully-specified not found; find best alternate script
+ TEST_CTOR(Chinese, LatinScript, China, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+ TEST_CTOR(Chinese, LatinScript, Taiwan, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan);
+
+ // Fully-specified not found; find best alternate country and script
+ TEST_CTOR(Chinese, LatinScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+
+#undef TEST_CTOR
#define TEST_CTOR(req_lang, req_country, exp_lang, exp_country) \
{ \
QLocale l(QLocale::req_lang, QLocale::req_country); \
QCOMPARE((int)l.language(), (int)exp_lang); \
QCOMPARE((int)l.country(), (int)exp_country); \
}
+
{
QLocale l(QLocale::C, QLocale::AnyCountry);
QCOMPARE(l.language(), QLocale::C);
@@ -295,7 +333,6 @@ void tst_QLocale::ctor()
TEST_CTOR(Uzbek, AnyCountry, QLocale::Uzbek, QLocale::Uzbekistan)
#undef TEST_CTOR
-
#define TEST_CTOR(req_lc, exp_lang, exp_country) \
{ \
QLocale l(req_lc); \
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 414ba2d8cf..727eda7456 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()
{
@@ -6070,6 +6071,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 +6346,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/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
index 383f357206..b68c582732 100644
--- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
+++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
@@ -189,7 +189,7 @@ void tst_QTimeLine::frameRate()
void tst_QTimeLine::value()
{
- QTimeLine timeLine(5000);
+ QTimeLine timeLine(4500); // Should be at least 5% under 5000ms
QCOMPARE(timeLine.currentValue(), 0.0);
// Default speed