summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/animation/qpauseanimation/BLACKLIST8
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp191
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST4
-rw-r--r--tests/auto/corelib/io/qprocess/BLACKLIST1
-rw-r--r--tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp2
-rw-r--r--tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp83
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp30
-rw-r--r--tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST3
-rw-r--r--tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp14
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp48
-rw-r--r--tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST3
-rw-r--r--tests/auto/corelib/kernel/qtimer/BLACKLIST9
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp27
-rw-r--r--tests/auto/corelib/serialization/qtextstream/BLACKLIST3
-rw-r--r--tests/auto/corelib/text/qlatin1string/tst_qlatin1string.cpp8
-rw-r--r--tests/auto/corelib/text/qstringview/tst_qstringview.cpp12
-rw-r--r--tests/auto/corelib/thread/qsemaphore/BLACKLIST3
-rw-r--r--tests/auto/corelib/thread/qthread/BLACKLIST4
-rw-r--r--tests/auto/corelib/thread/qthreadpool/BLACKLIST7
-rw-r--r--tests/auto/corelib/time/qcalendar/qcalendar.pro5
-rw-r--r--tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp236
-rw-r--r--tests/auto/corelib/time/time.pro1
-rw-r--r--tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp57
-rw-r--r--tests/auto/corelib/tools/qlinkedlist/qlinkedlist.pro2
-rw-r--r--tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp28
-rw-r--r--tests/auto/corelib/tools/qlist/qlist.pro2
-rw-r--r--tests/auto/corelib/tools/qlist/tst_qlist.cpp28
-rw-r--r--tests/auto/corelib/tools/qpoint/tst_qpoint.cpp7
-rw-r--r--tests/auto/corelib/tools/qpointf/tst_qpointf.cpp7
-rw-r--r--tests/auto/corelib/tools/qset/qset.pro2
-rw-r--r--tests/auto/corelib/tools/qset/tst_qset.cpp28
-rw-r--r--tests/auto/corelib/tools/qsize/tst_qsize.cpp44
-rw-r--r--tests/auto/corelib/tools/qsizef/tst_qsizef.cpp44
-rw-r--r--tests/auto/corelib/tools/qtimeline/BLACKLIST4
-rw-r--r--tests/auto/corelib/tools/qvarlengtharray/qvarlengtharray.pro2
-rw-r--r--tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp29
-rw-r--r--tests/auto/corelib/tools/qvector/qvector.pro2
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp28
38 files changed, 852 insertions, 164 deletions
diff --git a/tests/auto/corelib/animation/qpauseanimation/BLACKLIST b/tests/auto/corelib/animation/qpauseanimation/BLACKLIST
index 53372ce9ae..33cd53d788 100644
--- a/tests/auto/corelib/animation/qpauseanimation/BLACKLIST
+++ b/tests/auto/corelib/animation/qpauseanimation/BLACKLIST
@@ -1,9 +1,5 @@
[pauseAndPropertyAnimations]
-osx-10.12
-osx-10.14
-osx-10.13
+osx
[multipleSequentialGroups]
-osx-10.12
-osx-10.14
-osx-10.13
+osx
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 734694abeb..c21af435a1 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -237,6 +237,15 @@ private slots:
void isSymLink_data();
void isSymLink();
+ void isSymbolicLink_data();
+ void isSymbolicLink();
+
+ void isShortcut_data();
+ void isShortcut();
+
+ void link_data();
+ void link();
+
void isHidden_data();
void isHidden();
#if defined(Q_OS_MAC)
@@ -1337,6 +1346,176 @@ void tst_QFileInfo::isSymLink()
#endif
}
+void tst_QFileInfo::isShortcut_data()
+{
+ QFile::remove("link.lnk");
+ QFile::remove("symlink.lnk");
+ QFile::remove("link");
+ QFile::remove("symlink");
+ QFile::remove("directory.lnk");
+ QFile::remove("directory");
+
+ QTest::addColumn<QString>("path");
+ QTest::addColumn<bool>("isShortcut");
+
+ QFile regularFile(m_sourceFile);
+ QTest::newRow("regular")
+ << regularFile.fileName() << false;
+ QTest::newRow("directory")
+ << QDir::currentPath() << false;
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+ // windows shortcuts
+ QVERIFY(regularFile.link("link.lnk"));
+ QTest::newRow("shortcut")
+ << "link.lnk" << true;
+ QVERIFY(regularFile.link("link"));
+ QTest::newRow("invalid-shortcut")
+ << "link" << false;
+ QVERIFY(QFile::link(QDir::currentPath(), "directory.lnk"));
+ QTest::newRow("directory-shortcut")
+ << "directory.lnk" << true;
+#endif
+}
+
+void tst_QFileInfo::isShortcut()
+{
+ QFETCH(QString, path);
+ QFETCH(bool, isShortcut);
+
+ QFileInfo fi(path);
+ QCOMPARE(fi.isShortcut(), isShortcut);
+}
+
+void tst_QFileInfo::isSymbolicLink_data()
+{
+ QTest::addColumn<QString>("path");
+ QTest::addColumn<bool>("isSymbolicLink");
+
+ QFile regularFile(m_sourceFile);
+ QTest::newRow("regular")
+ << regularFile.fileName() << false;
+ QTest::newRow("directory")
+ << QDir::currentPath() << false;
+
+#ifndef Q_NO_SYMLINKS
+#if defined(Q_OS_WIN)
+#if !defined(Q_OS_WINRT)
+ QString errorMessage;
+ const DWORD creationResult = createSymbolicLink("symlink", m_sourceFile, &errorMessage);
+ if (creationResult == ERROR_PRIVILEGE_NOT_HELD) {
+ QWARN(msgInsufficientPrivileges(errorMessage));
+ } else {
+ QVERIFY2(creationResult == ERROR_SUCCESS, qPrintable(errorMessage));
+ QTest::newRow("NTFS-symlink")
+ << "symlink" << true;
+ }
+#endif // !Q_OS_WINRT
+#else // Unix:
+ QVERIFY(regularFile.link("symlink.lnk"));
+ QTest::newRow("symlink.lnk")
+ << "symlink.lnk" << true;
+ QVERIFY(regularFile.link("symlink"));
+ QTest::newRow("symlink")
+ << "symlink" << true;
+ QVERIFY(QFile::link(QDir::currentPath(), "directory"));
+ QTest::newRow("directory-symlink")
+ << "directory" << true;
+#endif
+#endif // !Q_NO_SYMLINKS
+}
+
+void tst_QFileInfo::isSymbolicLink()
+{
+ QFETCH(QString, path);
+ QFETCH(bool, isSymbolicLink);
+
+ QFileInfo fi(path);
+ QCOMPARE(fi.isSymbolicLink(), isSymbolicLink);
+}
+
+void tst_QFileInfo::link_data()
+{
+ QFile::remove("link");
+ QFile::remove("link.lnk");
+ QFile::remove("brokenlink");
+ QFile::remove("brokenlink.lnk");
+ QFile::remove("dummyfile");
+ QFile::remove("relative/link");
+
+ QTest::addColumn<QString>("path");
+ QTest::addColumn<bool>("isShortcut");
+ QTest::addColumn<bool>("isSymbolicLink");
+ QTest::addColumn<QString>("linkTarget");
+
+ QFile file1(m_sourceFile);
+ QFile file2("dummyfile");
+ file2.open(QIODevice::WriteOnly);
+
+ QTest::newRow("existent file") << m_sourceFile << false << false << "";
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+ // windows shortcuts
+ QVERIFY(file1.link("link.lnk"));
+ QTest::newRow("link.lnk")
+ << "link.lnk" << true << false << QFileInfo(m_sourceFile).absoluteFilePath();
+
+ QVERIFY(file2.link("brokenlink.lnk"));
+ QTest::newRow("broken link.lnk")
+ << "brokenlink.lnk" << true << false << QFileInfo("dummyfile").absoluteFilePath();
+#endif
+
+#ifndef Q_NO_SYMLINKS
+#if defined(Q_OS_WIN)
+#if !defined(Q_OS_WINRT)
+ QString errorMessage;
+ DWORD creationResult = createSymbolicLink("link", m_sourceFile, &errorMessage);
+ if (creationResult == ERROR_PRIVILEGE_NOT_HELD) {
+ QWARN(msgInsufficientPrivileges(errorMessage));
+ } else {
+ QVERIFY2(creationResult == ERROR_SUCCESS, qPrintable(errorMessage));
+ QTest::newRow("link")
+ << "link" << false << true << QFileInfo(m_sourceFile).absoluteFilePath();
+ }
+
+ creationResult = createSymbolicLink("brokenlink", "dummyfile", &errorMessage);
+ if (creationResult == ERROR_PRIVILEGE_NOT_HELD) {
+ QWARN(msgInsufficientPrivileges(errorMessage));
+ } else {
+ QVERIFY2(creationResult == ERROR_SUCCESS, qPrintable(errorMessage));
+ QTest::newRow("broken link")
+ << "brokenlink" << false << true << QFileInfo("dummyfile").absoluteFilePath();
+ }
+#endif // !Q_OS_WINRT
+#else // Unix:
+ QVERIFY(file1.link("link"));
+ QTest::newRow("link")
+ << "link" << false << true << QFileInfo(m_sourceFile).absoluteFilePath();
+
+ QVERIFY(file2.link("brokenlink"));
+ QTest::newRow("broken link")
+ << "brokenlink" << false << true << QFileInfo("dummyfile").absoluteFilePath();
+
+ QDir::current().mkdir("relative");
+ QFile::link("../dummyfile", "relative/link");
+ QTest::newRow("relative link")
+ << "relative/link" << false << true << QFileInfo("dummyfile").absoluteFilePath();
+#endif
+#endif // !Q_NO_SYMLINKS
+ file2.remove();
+}
+
+void tst_QFileInfo::link()
+{
+ QFETCH(QString, path);
+ QFETCH(bool, isShortcut);
+ QFETCH(bool, isSymbolicLink);
+ QFETCH(QString, linkTarget);
+
+ QFileInfo fi(path);
+ QCOMPARE(fi.isShortcut(), isShortcut);
+ QCOMPARE(fi.isSymbolicLink(), isSymbolicLink);
+ QCOMPARE(fi.symLinkTarget(), linkTarget);
+}
+
void tst_QFileInfo::isHidden_data()
{
QTest::addColumn<QString>("path");
@@ -1638,7 +1817,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks()
QVERIFY2(creationResult == ERROR_SUCCESS, qPrintable(errorMessage));
QFileInfo fi(path);
- const bool actualIsSymLink = fi.isSymLink();
+ const bool actualIsSymLink = fi.isSymbolicLink();
const QString actualSymLinkTarget = isSymLink ? fi.symLinkTarget() : QString();
const QString actualCanonicalFilePath = isSymLink ? fi.canonicalFilePath() : QString();
// Ensure that junctions, mountpoints are removed. If this fails, do not remove
@@ -1667,14 +1846,16 @@ void tst_QFileInfo::brokenShortcut()
file.close();
QFileInfo info(linkName);
- QVERIFY(info.isSymLink());
+ QVERIFY(!info.isSymbolicLink());
+ QVERIFY(info.isShortcut());
QVERIFY(!info.exists());
QFile::remove(linkName);
QDir current; // QTBUG-21863
QVERIFY(current.mkdir(linkName));
QFileInfo dirInfo(linkName);
- QVERIFY(!dirInfo.isSymLink());
+ QVERIFY(!dirInfo.isSymbolicLink());
+ QVERIFY(!dirInfo.isShortcut());
QVERIFY(dirInfo.isDir());
current.rmdir(linkName);
}
@@ -2032,7 +2213,8 @@ static void stateCheck(const QFileInfo &info, const QString &dirname, const QStr
QVERIFY(!info.isHidden());
QVERIFY(!info.isFile());
QVERIFY(!info.isDir());
- QVERIFY(!info.isSymLink());
+ QVERIFY(!info.isSymbolicLink());
+ QVERIFY(!info.isShortcut());
QVERIFY(!info.isBundle());
QVERIFY(!info.isRoot());
QCOMPARE(info.isNativePath(), !filename.isEmpty());
@@ -2089,5 +2271,6 @@ void tst_QFileInfo::nonExistingFile()
stateCheck(info, dirname, filename);
}
+
QTEST_MAIN(tst_QFileInfo)
#include "tst_qfileinfo.moc"
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST b/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST
index 9b210b0d5f..457499591d 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST
+++ b/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST
@@ -1,9 +1,7 @@
# QTBUG-33574 QTBUG-30943
[signalsEmittedAfterFileMoved]
-windows-10 msvc-2017
-windows-10 msvc-2019
-windows-10 msvc-2015
windows-7sp1
+windows-10
[watchFileAndItsDirectory:native backend-testfile]
osx
windows
diff --git a/tests/auto/corelib/io/qprocess/BLACKLIST b/tests/auto/corelib/io/qprocess/BLACKLIST
index aa9fdab64d..682bcbc60c 100644
--- a/tests/auto/corelib/io/qprocess/BLACKLIST
+++ b/tests/auto/corelib/io/qprocess/BLACKLIST
@@ -2,6 +2,5 @@
redhatenterpriselinuxworkstation-6.6
# QTBUG-48455
[fileWriterProcess]
-windows-10 msvc-2015
windows-10 msvc-2017
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
index 3a4493474b..f305edb2c5 100644
--- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -1830,7 +1830,7 @@ void ListenerObject::slotAboutToBeReset()
void ListenerObject::slotReset()
{
- foreach (const QModelIndex &idx, m_persistentIndexes) {
+ for (const auto &idx : qAsConst(m_persistentIndexes)) {
QVERIFY(!idx.isValid());
}
}
diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
index f78f5bc138..c74101928a 100644
--- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -32,6 +32,9 @@
#include <algorithm>
+Q_DECLARE_METATYPE(QItemSelectionModel::SelectionFlag)
+Q_DECLARE_METATYPE(Qt::SortOrder)
+
class tst_QItemSelectionModel : public QObject
{
Q_OBJECT
@@ -1463,7 +1466,7 @@ void tst_QItemSelectionModel::persistentselections()
QFETCH(IntList, insertColumns);
QFETCH(IntList, deleteRows);
QFETCH(IntList, deleteColumns);
- QFETCH(PairList, expectedList);
+ QFETCH(const PairList, expectedList);
// make sure the model is sane (5x5)
QCOMPARE(model->rowCount(QModelIndex()), 5);
@@ -1504,7 +1507,7 @@ void tst_QItemSelectionModel::persistentselections()
// check that the selected items are the correct number and indexes
QModelIndexList selectedList = selection->selectedIndexes();
QCOMPARE(selectedList.count(), expectedList.count());
- foreach(IntPair pair, expectedList) {
+ for (const auto &pair : expectedList) {
QModelIndex index = model->index(pair.first, pair.second, QModelIndex());
QVERIFY(selectedList.contains(index));
}
@@ -1679,7 +1682,7 @@ void tst_QItemSelectionModel::modelLayoutChanged_data()
{
QTest::addColumn<IntListList>("items");
QTest::addColumn<IntPairPairList>("initialSelectedRanges");
- QTest::addColumn<int>("sortOrder");
+ QTest::addColumn<Qt::SortOrder>("sortOrder");
QTest::addColumn<int>("sortColumn");
QTest::addColumn<IntPairPairList>("expectedSelectedRanges");
@@ -1689,7 +1692,7 @@ void tst_QItemSelectionModel::modelLayoutChanged_data()
<< (IntList() << 3 << 2 << 1 << 0))
<< (IntPairPairList()
<< IntPairPair(IntPair(0, 0), IntPair(3, 1)))
- << int(Qt::DescendingOrder)
+ << Qt::DescendingOrder
<< 0
<< (IntPairPairList()
<< IntPairPair(IntPair(0, 0), IntPair(3, 1)));
@@ -1699,7 +1702,7 @@ void tst_QItemSelectionModel::modelLayoutChanged_data()
<< (IntList() << 3 << 2 << 1 << 0))
<< (IntPairPairList()
<< IntPairPair(IntPair(0, 0), IntPair(1, 1)))
- << int(Qt::DescendingOrder)
+ << Qt::DescendingOrder
<< 0
<< (IntPairPairList()
<< IntPairPair(IntPair(2, 0), IntPair(3, 1)));
@@ -1709,7 +1712,7 @@ void tst_QItemSelectionModel::modelLayoutChanged_data()
<< (IntList() << 3 << 2 << 1 << 0))
<< (IntPairPairList()
<< IntPairPair(IntPair(1, 0), IntPair(2, 1)))
- << int(Qt::DescendingOrder)
+ << Qt::DescendingOrder
<< 0
<< (IntPairPairList()
<< IntPairPair(IntPair(1, 0), IntPair(2, 1)));
@@ -1720,7 +1723,7 @@ void tst_QItemSelectionModel::modelLayoutChanged_data()
<< (IntPairPairList()
<< IntPairPair(IntPair(1, 0), IntPair(1, 1))
<< IntPairPair(IntPair(3, 0), IntPair(3, 1)))
- << int(Qt::AscendingOrder)
+ << Qt::AscendingOrder
<< 0
<< (IntPairPairList()
<< IntPairPair(IntPair(0, 0), IntPair(0, 1))
@@ -1730,8 +1733,8 @@ void tst_QItemSelectionModel::modelLayoutChanged_data()
void tst_QItemSelectionModel::modelLayoutChanged()
{
QFETCH(IntListList, items);
- QFETCH(IntPairPairList, initialSelectedRanges);
- QFETCH(int, sortOrder);
+ QFETCH(const IntPairPairList, initialSelectedRanges);
+ QFETCH(Qt::SortOrder, sortOrder);
QFETCH(int, sortColumn);
QFETCH(IntPairPairList, expectedSelectedRanges);
@@ -1746,9 +1749,9 @@ void tst_QItemSelectionModel::modelLayoutChanged()
// select initial ranges
QItemSelectionModel selectionModel(&model);
- foreach (IntPairPair range, initialSelectedRanges) {
- IntPair tl = range.first;
- IntPair br = range.second;
+ for (const auto &range : initialSelectedRanges) {
+ const auto &tl = range.first;
+ const auto &br = range.second;
QItemSelection selection(
model.index(tl.first, tl.second),
model.index(br.first, br.second));
@@ -1756,7 +1759,7 @@ void tst_QItemSelectionModel::modelLayoutChanged()
}
// sort the model
- model.sort(sortColumn, Qt::SortOrder(sortOrder));
+ model.sort(sortColumn, sortOrder);
// verify that selection is as expected
QItemSelection selection = selectionModel.selection();
@@ -2126,43 +2129,43 @@ void tst_QItemSelectionModel::merge_data()
{
QTest::addColumn<QItemSelection>("init");
QTest::addColumn<QItemSelection>("other");
- QTest::addColumn<int>("command");
+ QTest::addColumn<QItemSelectionModel::SelectionFlag>("command");
QTest::addColumn<QItemSelection>("result");
QTest::newRow("Simple select")
<< QItemSelection()
<< QItemSelection(model->index(2, 1) , model->index(3, 4))
- << int(QItemSelectionModel::Select)
+ << QItemSelectionModel::Select
<< QItemSelection(model->index(2, 1) , model->index(3, 4));
QTest::newRow("Simple deselect")
<< QItemSelection(model->index(2, 1) , model->index(3, 4))
<< QItemSelection(model->index(2, 1) , model->index(3, 4))
- << int(QItemSelectionModel::Deselect)
+ << QItemSelectionModel::Deselect
<< QItemSelection();
QTest::newRow("Simple Toggle deselect")
<< QItemSelection(model->index(2, 1) , model->index(3, 4))
<< QItemSelection(model->index(2, 1) , model->index(3, 4))
- << int(QItemSelectionModel::Toggle)
+ << QItemSelectionModel::Toggle
<< QItemSelection();
QTest::newRow("Simple Toggle select")
<< QItemSelection()
<< QItemSelection(model->index(2, 1) , model->index(3, 4))
- << int(QItemSelectionModel::Toggle)
+ << QItemSelectionModel::Toggle
<< QItemSelection(model->index(2, 1) , model->index(3, 4));
QTest::newRow("Add select")
<< QItemSelection(model->index(2, 1) , model->index(3, 3))
<< QItemSelection(model->index(2, 2) , model->index(3, 4))
- << int(QItemSelectionModel::Select)
+ << QItemSelectionModel::Select
<< QItemSelection(model->index(2, 1) , model->index(3, 4));
QTest::newRow("Deselect")
<< QItemSelection(model->index(2, 1) , model->index(3, 4))
<< QItemSelection(model->index(2, 2) , model->index(3, 4))
- << int(QItemSelectionModel::Deselect)
+ << QItemSelectionModel::Deselect
<< QItemSelection(model->index(2, 1) , model->index(3, 1));
QItemSelection r1(model->index(2, 1) , model->index(3, 1));
@@ -2170,7 +2173,7 @@ void tst_QItemSelectionModel::merge_data()
QTest::newRow("Toggle")
<< QItemSelection(model->index(2, 1) , model->index(3, 3))
<< QItemSelection(model->index(2, 2) , model->index(3, 4))
- << int(QItemSelectionModel::Toggle)
+ << QItemSelectionModel::Toggle
<< r1;
}
@@ -2178,15 +2181,18 @@ void tst_QItemSelectionModel::merge()
{
QFETCH(QItemSelection, init);
QFETCH(QItemSelection, other);
- QFETCH(int, command);
+ QFETCH(QItemSelectionModel::SelectionFlag, command);
QFETCH(QItemSelection, result);
- init.merge(other, QItemSelectionModel::SelectionFlags(command));
+ init.merge(other, command);
- foreach(const QModelIndex &idx, init.indexes())
- QVERIFY(result.contains(idx));
- foreach(const QModelIndex &idx, result.indexes())
- QVERIFY(init.contains(idx));
+ auto verify = [](const QModelIndexList &a, const QItemSelection &b)
+ {
+ for (const QModelIndex &idx : a)
+ QVERIFY(b.contains(idx));
+ };
+ verify(init.indexes(), result);
+ verify(result.indexes(), init);
}
void tst_QItemSelectionModel::isRowSelected()
@@ -2267,13 +2273,12 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected1()
proxy.setFilterRegularExpression(QRegularExpression("f"));
QCOMPARE(proxy.rowCount(), 2);
- QList<QPersistentModelIndex> indexList;
- indexList << proxy.index(0,0) << proxy.index(1,0);
- selection.select( QItemSelection(indexList.first(), indexList.last()), QItemSelectionModel::Select);
+ const QList<QPersistentModelIndex> indexList({proxy.index(0,0), proxy.index(1,0)});
+ selection.select(QItemSelection(indexList.first(), indexList.last()), QItemSelectionModel::Select);
//let's check the selection hasn't changed
QCOMPARE(selection.selectedIndexes().count(), indexList.count());
- foreach(QPersistentModelIndex index, indexList)
+ for (const auto &index : indexList)
QVERIFY(selection.isSelected(index));
proxy.setFilterRegularExpression(QRegularExpression());
@@ -2281,7 +2286,7 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected1()
//let's check the selection hasn't changed
QCOMPARE(selection.selectedIndexes().count(), indexList.count());
- foreach(QPersistentModelIndex index, indexList)
+ for (const auto &index : indexList)
QVERIFY(selection.isSelected(index));
}
@@ -2321,9 +2326,8 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected2()
selection.select( QItemSelection(proxy.index(0,0), proxy.index(proxy.rowCount() - 1, proxy.columnCount() - 1)), QItemSelectionModel::Select);
- QList<QPersistentModelIndex> indexList;
- foreach(const QModelIndex &id, selection.selectedIndexes())
- indexList << id;
+ const auto selIndexes = selection.selectedIndexes();
+ const QList<QPersistentModelIndex> indexList(selIndexes.begin(), selIndexes.end());
proxy.filtering = false;
proxy.invalidate();
@@ -2331,7 +2335,7 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected2()
//let's check the selection hasn't changed
QCOMPARE(selection.selectedIndexes().count(), indexList.count());
- foreach(QPersistentModelIndex index, indexList)
+ for (const auto &index : indexList)
QVERIFY(selection.isSelected(index));
}
@@ -2375,7 +2379,8 @@ public:
public slots:
void selectionChanged(const QItemSelection & /* selected */, const QItemSelection &deselected)
{
- foreach(const QModelIndex &index, deselected.indexes()) {
+ const auto deselIndexes = deselected.indexes();
+ for (const auto &index : deselIndexes) {
QVERIFY(!m_itemSelectionModel->selection().contains(index));
}
QCOMPARE(m_itemSelectionModel->selection().size(), 2);
@@ -2633,9 +2638,9 @@ private slots:
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{
- foreach(const QItemSelectionRange &range, selected)
+ for (const auto &range : selected)
QVERIFY(range.isValid());
- foreach(const QItemSelectionRange &range, deselected)
+ for (const auto &range : deselected)
QVERIFY(range.isValid());
}
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp
index 0f7588a71a..624187349b 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp
@@ -829,7 +829,7 @@ void tst_QSortFilterProxyModel::removeRows_data()
void tst_QSortFilterProxyModel::removeRows()
{
- QFETCH(QStringList, initial);
+ QFETCH(const QStringList, initial);
QFETCH(int, sortOrder);
QFETCH(QString, filter);
QFETCH(int, position);
@@ -843,7 +843,7 @@ void tst_QSortFilterProxyModel::removeRows()
proxy.setSourceModel(&model);
// prepare model
- foreach (QString s, initial)
+ for (const auto &s : initial)
model.appendRow(new QStandardItem(s));
if (sortOrder != -1)
@@ -3035,15 +3035,15 @@ void tst_QSortFilterProxyModel::removeRowsRecursive()
QList<QPersistentModelIndex> sourceIndexes;
QList<QPersistentModelIndex> proxyIndexes;
- foreach (QStandardItem *item, items) {
+ for (const auto item : qAsConst(items)) {
QModelIndex idx = item->index();
sourceIndexes << idx;
proxyIndexes << proxy.mapFromSource(idx);
}
- foreach (const QPersistentModelIndex &pidx, sourceIndexes)
+ for (const auto &pidx : qAsConst(sourceIndexes))
QVERIFY(pidx.isValid());
- foreach (const QPersistentModelIndex &pidx, proxyIndexes)
+ for (const auto &pidx : qAsConst(proxyIndexes))
QVERIFY(pidx.isValid());
QList<QStandardItem*> itemRow = pItem1->takeRow(0);
@@ -3051,9 +3051,9 @@ void tst_QSortFilterProxyModel::removeRowsRecursive()
QCOMPARE(itemRow.count(), 1);
QCOMPARE(itemRow.first(), pItem11);
- foreach (const QPersistentModelIndex &pidx, sourceIndexes)
+ for (const auto &pidx : qAsConst(sourceIndexes))
QVERIFY(!pidx.isValid());
- foreach (const QPersistentModelIndex &pidx, proxyIndexes)
+ for (const auto &pidx : qAsConst(proxyIndexes))
QVERIFY(!pidx.isValid());
delete pItem11;
@@ -3280,10 +3280,8 @@ void tst_QSortFilterProxyModel::testMultipleProxiesWithSelection()
static bool isValid(const QItemSelection &selection)
{
- foreach (const QItemSelectionRange &range, selection)
- if (!range.isValid())
- return false;
- return true;
+ return std::all_of(selection.begin(), selection.end(),
+ [](const QItemSelectionRange &range) { return range.isValid(); });
}
void tst_QSortFilterProxyModel::mapSelectionFromSource()
@@ -3737,14 +3735,16 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged()
QVERIFY(beforeParents.first() == proxy.mapFromSource(model.indexFromItem(model.invisibleRootItem()->child(1))));
- QList<QPersistentModelIndex> proxy2BeforeList = proxy2ParentsAboutToBeChangedSpy.first().first().value<QList<QPersistentModelIndex> >();
- QList<QPersistentModelIndex> proxy2AfterList = proxy2ParentsChangedSpy.first().first().value<QList<QPersistentModelIndex> >();
+ const QList<QPersistentModelIndex> proxy2BeforeList =
+ proxy2ParentsAboutToBeChangedSpy.first().first().value<QList<QPersistentModelIndex> >();
+ const QList<QPersistentModelIndex> proxy2AfterList =
+ proxy2ParentsChangedSpy.first().first().value<QList<QPersistentModelIndex> >();
QCOMPARE(proxy2BeforeList.size(), beforeParents.size());
QCOMPARE(proxy2AfterList.size(), afterParents.size());
- foreach (const QPersistentModelIndex &idx, proxy2BeforeList)
+ for (const QPersistentModelIndex &idx : proxy2BeforeList)
QVERIFY(beforeParents.contains(proxy2.mapToSource(idx)));
- foreach (const QPersistentModelIndex &idx, proxy2AfterList)
+ for (const QPersistentModelIndex &idx : proxy2AfterList)
QVERIFY(afterParents.contains(proxy2.mapToSource(idx)));
}
diff --git a/tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST b/tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST
index 4c9fe53c14..569880e1db 100644
--- a/tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST
+++ b/tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST
@@ -1,4 +1,3 @@
[elapsed]
-windows-10 msvc-2015
osx-10.13
-windows-10 msvc-2017
+windows-10
diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
index 026c6a6324..60000316cc 100644
--- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
@@ -507,6 +507,7 @@ public slots:
{ QObject::moveToThread(t); }
void slotWithUnregisteredParameterType(MyUnregisteredType);
+ void slotWithOneUnregisteredParameterType(QString a1, MyUnregisteredType a2);
CountedStruct throwingSlot(const CountedStruct &, CountedStruct s2) {
#ifndef QT_NO_EXCEPTIONS
@@ -604,6 +605,9 @@ void QtTestObject::testSender()
void QtTestObject::slotWithUnregisteredParameterType(MyUnregisteredType)
{ slotResult = "slotWithUnregisteredReturnType"; }
+void QtTestObject::slotWithOneUnregisteredParameterType(QString a1, MyUnregisteredType)
+{ slotResult = "slotWithUnregisteredReturnType-" + a1; }
+
void QtTestObject::staticFunction0()
{
staticResult = "staticFunction0";
@@ -885,6 +889,16 @@ void tst_QMetaObject::invokeQueuedMetaMember()
QVERIFY(!QMetaObject::invokeMethod(&obj, "slotWithUnregisteredParameterType", Qt::QueuedConnection, Q_ARG(MyUnregisteredType, t)));
QVERIFY(obj.slotResult.isEmpty());
}
+
+ obj.slotResult.clear();
+ {
+ QString a1("Cannot happen");
+ MyUnregisteredType t;
+ QTest::ignoreMessage(QtWarningMsg, "QMetaMethod::invoke: Unable to handle unregistered datatype 'MyUnregisteredType'");
+ QVERIFY(!QMetaObject::invokeMethod(&obj, "slotWithOneUnregisteredParameterType", Qt::QueuedConnection,
+ Q_ARG(QString, a1), Q_ARG(MyUnregisteredType, t)));
+ QVERIFY(obj.slotResult.isEmpty());
+ }
}
void tst_QMetaObject::invokeQueuedPointer()
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index a805bfb747..676999a08c 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -81,9 +81,6 @@ private slots:
void senderTest();
void declareInterface();
void qpointerResetBeforeDestroyedSignal();
-#ifndef QT_NO_USERDATA
- void testUserData();
-#endif
void childDeletesItsSibling();
void dynamicProperties();
void floatProperty();
@@ -2341,51 +2338,6 @@ void tst_QObject::declareInterface()
}
-#ifndef QT_NO_USERDATA
-class CustomData : public QObjectUserData
-{
-public:
- int id;
-};
-
-void tst_QObject::testUserData()
-{
- const int USER_DATA_COUNT = 100;
- int user_data_ids[USER_DATA_COUNT];
-
- // Register a few
- for (int i=0; i<USER_DATA_COUNT; ++i) {
- user_data_ids[i] = QObject::registerUserData();
- }
-
- // Randomize the table a bit
- for (int i=0; i<100; ++i) {
- int p1 = QRandomGenerator::global()->bounded(USER_DATA_COUNT);
- int p2 = QRandomGenerator::global()->bounded(USER_DATA_COUNT);
-
- int tmp = user_data_ids[p1];
- user_data_ids[p1] = user_data_ids[p2];
- user_data_ids[p2] = tmp;
- }
-
- // insert the user data into an object
- QObject my_test_object;
- for (int i=0; i<USER_DATA_COUNT; ++i) {
- CustomData *data = new CustomData;
- data->id = user_data_ids[i];
- my_test_object.setUserData(data->id, data);
- }
-
- // verify that all ids and positions are matching
- for (int i=0; i<USER_DATA_COUNT; ++i) {
- int id = user_data_ids[i];
- CustomData *data = static_cast<CustomData *>(my_test_object.userData(id));
- QVERIFY(data != nullptr);
- QCOMPARE(data->id, id);
- }
-}
-#endif // QT_NO_USERDATA
-
class DestroyedListener : public QObject
{
Q_OBJECT
diff --git a/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST b/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST
index f3b7fc97b1..f2e5e78592 100644
--- a/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST
+++ b/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST
@@ -1,4 +1,3 @@
[unexpectedDisconnection]
-osx-10.12
-windows-10 msvc-2015
windows-7sp1
+windows-10 msvc-2015
diff --git a/tests/auto/corelib/kernel/qtimer/BLACKLIST b/tests/auto/corelib/kernel/qtimer/BLACKLIST
deleted file mode 100644
index dc8b8987e5..0000000000
--- a/tests/auto/corelib/kernel/qtimer/BLACKLIST
+++ /dev/null
@@ -1,9 +0,0 @@
-[remainingTime]
-osx-10.12
-osx-10.14
-osx-10.13
-windows-10 msvc-2017
-[basic_chrono]
-osx-10.14
-osx-10.13
-
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index 262dbea913..8e0bdac520 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -47,7 +47,11 @@
class tst_QTimer : public QObject
{
Q_OBJECT
+public:
+ static void initMain();
+
private slots:
+ void cleanupTestCase();
void zeroTimer();
void singleShotTimeout();
void timeout();
@@ -1138,22 +1142,27 @@ struct StaticSingleShotUser
}
};
+// NOTE: to prevent any static initialization order fiasco, we implement
+// initMain() to instantiate staticSingleShotUser before qApp
+
static StaticSingleShotUser *s_staticSingleShotUser = nullptr;
-void tst_QTimer::singleShot_static()
+void tst_QTimer::initMain()
{
- QCoreApplication::processEvents();
- QCOMPARE(s_staticSingleShotUser->helper.calls, s_staticSingleShotUser->calls());
+ s_staticSingleShotUser = new StaticSingleShotUser;
}
-// NOTE: to prevent any static initialization order fiasco, we handle QTEST_MAIN
-// ourselves, but instantiate the staticSingleShotUser before qApp
+void tst_QTimer::cleanupTestCase()
+{
+ delete s_staticSingleShotUser;
+}
-int main(int argc, char *argv[])
+void tst_QTimer::singleShot_static()
{
- StaticSingleShotUser staticSingleShotUser;
- s_staticSingleShotUser = &staticSingleShotUser;
- QTEST_MAIN_IMPL(tst_QTimer)
+ QCoreApplication::processEvents();
+ QCOMPARE(s_staticSingleShotUser->helper.calls, s_staticSingleShotUser->calls());
}
+QTEST_MAIN(tst_QTimer)
+
#include "tst_qtimer.moc"
diff --git a/tests/auto/corelib/serialization/qtextstream/BLACKLIST b/tests/auto/corelib/serialization/qtextstream/BLACKLIST
index b8c1b742f4..674569e204 100644
--- a/tests/auto/corelib/serialization/qtextstream/BLACKLIST
+++ b/tests/auto/corelib/serialization/qtextstream/BLACKLIST
@@ -1,4 +1,3 @@
[stillOpenWhenAtEnd]
-windows-10 msvc-2017
-winrt
windows-7sp1
+winrt
diff --git a/tests/auto/corelib/text/qlatin1string/tst_qlatin1string.cpp b/tests/auto/corelib/text/qlatin1string/tst_qlatin1string.cpp
index cf46159251..0427c81b85 100644
--- a/tests/auto/corelib/text/qlatin1string/tst_qlatin1string.cpp
+++ b/tests/auto/corelib/text/qlatin1string/tst_qlatin1string.cpp
@@ -70,7 +70,7 @@ void tst_QLatin1String::arg() const
do { \
auto p = QLatin1String(pattern); \
QCOMPARE(p.arg(QLatin1String(arg1)), expected); \
- QCOMPARE(p.arg(QStringViewLiteral(arg1)), expected); \
+ QCOMPARE(p.arg(u"" arg1), expected); \
QCOMPARE(p.arg(QStringLiteral(arg1)), expected); \
QCOMPARE(p.arg(QString(QLatin1String(arg1))), expected); \
} while (false) \
@@ -79,9 +79,9 @@ void tst_QLatin1String::arg() const
do { \
auto p = QLatin1String(pattern); \
QCOMPARE(p.arg(QLatin1String(arg1), QLatin1String(arg2)), expected); \
- QCOMPARE(p.arg(QStringViewLiteral(arg1), QLatin1String(arg2)), expected); \
- QCOMPARE(p.arg(QLatin1String(arg1), QStringViewLiteral(arg2)), expected); \
- QCOMPARE(p.arg(QStringViewLiteral(arg1), QStringViewLiteral(arg2)), expected); \
+ QCOMPARE(p.arg(u"" arg1, QLatin1String(arg2)), expected); \
+ QCOMPARE(p.arg(QLatin1String(arg1), u"" arg2), expected); \
+ QCOMPARE(p.arg(u"" arg1, u"" arg2), expected); \
} while (false) \
/*end*/
diff --git a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp
index 5d95f43d6a..47ce9a6f63 100644
--- a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp
+++ b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp
@@ -431,20 +431,20 @@ void tst_QStringView::arg() const
{
#define CHECK1(pattern, arg1, expected) \
do { \
- auto p = QStringViewLiteral(pattern); \
+ auto p = QStringView(u"" pattern); \
QCOMPARE(p.arg(QLatin1String(arg1)), expected); \
- QCOMPARE(p.arg(QStringViewLiteral(arg1)), expected); \
+ QCOMPARE(p.arg(u"" arg1), expected); \
QCOMPARE(p.arg(QStringLiteral(arg1)), expected); \
QCOMPARE(p.arg(QString(QLatin1String(arg1))), expected); \
} while (false) \
/*end*/
#define CHECK2(pattern, arg1, arg2, expected) \
do { \
- auto p = QStringViewLiteral(pattern); \
+ auto p = QStringView(u"" pattern); \
QCOMPARE(p.arg(QLatin1String(arg1), QLatin1String(arg2)), expected); \
- QCOMPARE(p.arg(QStringViewLiteral(arg1), QLatin1String(arg2)), expected); \
- QCOMPARE(p.arg(QLatin1String(arg1), QStringViewLiteral(arg2)), expected); \
- QCOMPARE(p.arg(QStringViewLiteral(arg1), QStringViewLiteral(arg2)), expected); \
+ QCOMPARE(p.arg(u"" arg1, QLatin1String(arg2)), expected); \
+ QCOMPARE(p.arg(QLatin1String(arg1), u"" arg2), expected); \
+ QCOMPARE(p.arg(u"" arg1, u"" arg2), expected); \
} while (false) \
/*end*/
diff --git a/tests/auto/corelib/thread/qsemaphore/BLACKLIST b/tests/auto/corelib/thread/qsemaphore/BLACKLIST
index f61f4c1a3b..d7af5c420b 100644
--- a/tests/auto/corelib/thread/qsemaphore/BLACKLIST
+++ b/tests/auto/corelib/thread/qsemaphore/BLACKLIST
@@ -1,6 +1,5 @@
[tryAcquireWithTimeout]
-osx-10.12
-osx-10.13
+osx
[tryAcquireWithTimeout:0.2s]
windows
osx-10.12
diff --git a/tests/auto/corelib/thread/qthread/BLACKLIST b/tests/auto/corelib/thread/qthread/BLACKLIST
index 87538a1048..c683154da1 100644
--- a/tests/auto/corelib/thread/qthread/BLACKLIST
+++ b/tests/auto/corelib/thread/qthread/BLACKLIST
@@ -1,7 +1,5 @@
[wait3_slowDestructor]
-windows-10 msvc-2015
-windows-7sp1
-windows-10 msvc-2017
+windows-10
[sleep]
windows-7sp1
diff --git a/tests/auto/corelib/thread/qthreadpool/BLACKLIST b/tests/auto/corelib/thread/qthreadpool/BLACKLIST
index e4f2fcd822..b8c1f3bf3f 100644
--- a/tests/auto/corelib/thread/qthreadpool/BLACKLIST
+++ b/tests/auto/corelib/thread/qthreadpool/BLACKLIST
@@ -1,7 +1,4 @@
[expiryTimeoutRace]
-rhel-7.6
opensuse-leap
-osx-10.13
-ubuntu-18.04
-osx-10.12
-opensuse-42.3
+ubuntu
+rhel
diff --git a/tests/auto/corelib/time/qcalendar/qcalendar.pro b/tests/auto/corelib/time/qcalendar/qcalendar.pro
new file mode 100644
index 0000000000..94e8fe8606
--- /dev/null
+++ b/tests/auto/corelib/time/qcalendar/qcalendar.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+TARGET = tst_qcalendar
+QT = core testlib
+SOURCES = \
+ tst_qcalendar.cpp
diff --git a/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp b/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp
new file mode 100644
index 0000000000..5cfdb6daf4
--- /dev/null
+++ b/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp
@@ -0,0 +1,236 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 <QtTest/QtTest>
+
+#include <QCalendar>
+Q_DECLARE_METATYPE(QCalendar::System)
+
+class tst_QCalendar : public QObject
+{
+ Q_OBJECT
+private:
+ void checkYear(const QCalendar &cal, int year, bool normal=false);
+
+private slots:
+ void basic_data();
+ void basic();
+ void nameCase();
+ void specific_data();
+ void specific();
+ void daily_data() { basic_data(); }
+ void daily();
+};
+
+// Support for basic():
+void tst_QCalendar::checkYear(const QCalendar &cal, int year, bool normal)
+{
+ const int moons = cal.monthsInYear(year);
+ // Months are numbered from 1 to moons:
+ QVERIFY(moons > 0);
+ QVERIFY(!cal.isDateValid(year, moons + 1, 1));
+ QVERIFY(!cal.isDateValid(year, 0, 1));
+ QVERIFY(moons <= cal.maxMonthsInYear());
+
+ const int days = cal.daysInYear(year);
+ QVERIFY(days > 0);
+
+ int sum = 0;
+ const int longest = cal.maxDaysInMonth();
+ for (int i = moons; i > 0; i--) {
+ const int last = cal.daysInMonth(i, year);
+ sum += last;
+ // Valid month has some days and no more than max:
+ QVERIFY(last > 0);
+ QVERIFY(last <= longest);
+ // Days are numbered from 1 to last:
+ QVERIFY(cal.isDateValid(year, i, 1));
+ QVERIFY(cal.isDateValid(year, i, last));
+ QVERIFY(!cal.isDateValid(year, i, 0));
+ QVERIFY(!cal.isDateValid(year, i, last + 1));
+ if (normal) // Unspecified year gets same daysInMonth():
+ QCOMPARE(cal.daysInMonth(i), last);
+ }
+ // Months add up to the whole year:
+ QCOMPARE(sum, days);
+}
+
+#define CHECKYEAR(cal, year) checkYear(cal, year); \
+ if (QTest::currentTestFailed()) \
+ return
+
+#define NORMALYEAR(cal, year) checkYear(cal, year, true); \
+ if (QTest::currentTestFailed()) \
+ return
+
+void tst_QCalendar::basic_data()
+{
+ QTest::addColumn<QCalendar::System>("system");
+
+ QMetaEnum e = QCalendar::staticMetaObject.enumerator(0);
+ Q_ASSERT(qstrcmp(e.name(), "System") == 0);
+
+ for (int i = 0; i <= int(QCalendar::System::Last); ++i) {
+ // There may be gaps in the enum's numbering; and Last is a duplicate:
+ if (e.value(i) != -1 && qstrcmp(e.key(i), "Last"))
+ QTest::newRow(e.key(i)) << QCalendar::System(e.value(i));
+ }
+}
+
+void tst_QCalendar::basic()
+{
+ QFETCH(QCalendar::System, system);
+ QCalendar cal(system);
+ QVERIFY(cal.isValid());
+ QCOMPARE(QCalendar(cal.name()).isGregorian(), cal.isGregorian());
+ QCOMPARE(QCalendar(cal.name()).name(), cal.name());
+
+ if (cal.hasYearZero()) {
+ CHECKYEAR(cal, 0);
+ } else {
+ QCOMPARE(cal.monthsInYear(0), 0);
+ QCOMPARE(cal.daysInYear(0), 0);
+ QVERIFY(!cal.isDateValid(0, 1, 1));
+ }
+
+ if (cal.isProleptic()) {
+ CHECKYEAR(cal, -1);
+ } else {
+ QCOMPARE(cal.monthsInYear(-1), 0);
+ QCOMPARE(cal.daysInYear(-1), 0);
+ QVERIFY(!cal.isDateValid(-1, 1, 1));
+ }
+
+ // Look for a leap year in the last decade.
+ int year = QDate::currentDate().year(cal);
+ for (int i = 10; i > 0 && !cal.isLeapYear(year); --i)
+ --year;
+ if (cal.isLeapYear(year)) {
+ // ... and a non-leap year within a decade before it.
+ int leap = year--;
+ for (int i = 10; i > 0 && cal.isLeapYear(year); --i)
+ year--;
+ if (!cal.isLeapYear(year))
+ QVERIFY(cal.daysInYear(year) < cal.daysInYear(leap));
+
+ CHECKYEAR(cal, leap);
+ }
+ // Either year is non-leap or we have a decade of leap years together;
+ // expect daysInMonth() to treat year the same as unspecified.
+ NORMALYEAR(cal, year);
+}
+
+void tst_QCalendar::nameCase()
+{
+ QVERIFY(QCalendar::availableCalendars().contains(QStringLiteral("Gregorian")));
+}
+
+void tst_QCalendar::specific_data()
+{
+ QTest::addColumn<QCalendar::System>("system");
+ // Date in that system:
+ QTest::addColumn<int>("sysyear");
+ QTest::addColumn<int>("sysmonth");
+ QTest::addColumn<int>("sysday");
+ // Gregorian equivalent:
+ QTest::addColumn<int>("gregyear");
+ QTest::addColumn<int>("gregmonth");
+ QTest::addColumn<int>("gregday");
+
+#define ADDROW(cal, year, month, day, gy, gm, gd) \
+ QTest::newRow(#cal) << QCalendar::System::cal << year << month << day << gy << gm << gd
+
+ ADDROW(Gregorian, 1970, 1, 1, 1970, 1, 1);
+
+ // One known specific date, for each calendar
+#ifndef QT_BOOTSTRAPPED
+ // Julian 1582-10-4 was followed by Gregorian 1582-10-15
+ ADDROW(Julian, 1582, 10, 4, 1582, 10, 14);
+ // Milankovic matches Gregorian for a few centuries
+ ADDROW(Milankovic, 1923, 3, 20, 1923, 3, 20);
+#endif
+
+#if QT_CONFIG(jalalicalendar)
+ // Jalali year 1355 started on Gregorian 1976-3-21:
+ ADDROW(Jalali, 1355, 1, 1, 1976, 3, 21);
+#endif // jalali
+#if QT_CONFIG(islamiccivilcalendar)
+ // TODO: confirm this is correct
+ ADDROW(IslamicCivil, 1, 1, 1, 622, 7, 19);
+#endif
+
+#undef ADDROW
+}
+
+void tst_QCalendar::specific()
+{
+ QFETCH(QCalendar::System, system);
+ QFETCH(int, sysyear);
+ QFETCH(int, sysmonth);
+ QFETCH(int, sysday);
+ QFETCH(int, gregyear);
+ QFETCH(int, gregmonth);
+ QFETCH(int, gregday);
+
+ const QCalendar cal(system);
+ const QDate date(sysyear, sysmonth, sysday, cal), gregory(gregyear, gregmonth, gregday);
+ QCOMPARE(date, gregory);
+ QCOMPARE(gregory.year(cal), sysyear);
+ QCOMPARE(gregory.month(cal), sysmonth);
+ QCOMPARE(gregory.day(cal), sysday);
+ QCOMPARE(date.year(), gregyear);
+ QCOMPARE(date.month(), gregmonth);
+ QCOMPARE(date.day(), gregday);
+}
+
+void tst_QCalendar::daily()
+{
+ QFETCH(QCalendar::System, system);
+ QCalendar calendar(system);
+ const quint64 startJDN = 0, endJDN = 2488070;
+ // Iterate from -4713-01-01 (Julian calendar) to 2100-01-01
+ for (quint64 expect = startJDN; expect <= endJDN; ++expect)
+ {
+ QDate date = QDate::fromJulianDay(expect);
+ auto parts = calendar.partsFromDate(date);
+ if (!parts.isValid())
+ continue;
+
+ const int year = date.year(calendar);
+ QCOMPARE(year, parts.year);
+ const int month = date.month(calendar);
+ QCOMPARE(month, parts.month);
+ const int day = date.day(calendar);
+ QCOMPARE(day, parts.day);
+ const quint64 actual = QDate(year, month, day, calendar).toJulianDay();
+ QCOMPARE(actual, expect);
+ }
+}
+
+QTEST_APPLESS_MAIN(tst_QCalendar)
+#include "tst_qcalendar.moc"
diff --git a/tests/auto/corelib/time/time.pro b/tests/auto/corelib/time/time.pro
index 6f9ff038db..6f1ee9a8bd 100644
--- a/tests/auto/corelib/time/time.pro
+++ b/tests/auto/corelib/time/time.pro
@@ -1,5 +1,6 @@
TEMPLATE = subdirs
SUBDIRS = \
+ qcalendar \
qdate \
qdatetime \
qtime \
diff --git a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
index d19eac7530..9a7c099228 100644
--- a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
+++ b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
@@ -84,6 +84,8 @@ private slots:
void operator_noteq();
void resize();
+ void fromBits_data();
+ void fromBits();
};
void tst_QBitArray::size_data()
@@ -610,5 +612,60 @@ void tst_QBitArray::resize()
}
+void tst_QBitArray::fromBits_data()
+{
+ QTest::addColumn<QByteArray>("data");
+ QTest::addColumn<int>("size");
+ QTest::addColumn<QBitArray>("expected");
+
+ QTest::newRow("empty") << QByteArray() << 0 << QBitArray();
+
+ auto add = [](const QByteArray &tag, const char *data) {
+ QTest::newRow(tag) << QByteArray(data, (tag.size() + 7) / 8) << tag.size()
+ << QStringToQBitArray(tag);
+ };
+
+ // "0" to "0000000000000000"
+ for (int i = 1; i < 16; ++i) {
+ char zero[2] = { 0, 0 };
+ QByteArray pattern(i, '0');
+ add(pattern, zero);
+ }
+
+ // "1" to "1111111111111111"
+ for (int i = 1; i < 16; ++i) {
+ char one[2] = { '\xff', '\xff' };
+ QByteArray pattern(i, '1');
+ add(pattern, one);
+ }
+
+ // trailing 0 and 1
+ char zero = 1;
+ char one = 0;
+ QByteArray pzero = "1";
+ QByteArray pone = "0";
+ for (int i = 2; i < 8; ++i) {
+ zero <<= 1;
+ pzero.prepend('0');
+ add(pzero, &zero);
+
+ one = (one << 1) | 1;
+ pone.prepend('1');
+ add(pone, &one);
+ }
+}
+
+void tst_QBitArray::fromBits()
+{
+ QFETCH(QByteArray, data);
+ QFETCH(int, size);
+ QFETCH(QBitArray, expected);
+
+ QBitArray fromBits = QBitArray::fromBits(data, size);
+ QCOMPARE(fromBits, expected);
+
+ QCOMPARE(QBitArray::fromBits(fromBits.bits(), fromBits.size()), expected);
+}
+
QTEST_APPLESS_MAIN(tst_QBitArray)
#include "tst_qbitarray.moc"
diff --git a/tests/auto/corelib/tools/qlinkedlist/qlinkedlist.pro b/tests/auto/corelib/tools/qlinkedlist/qlinkedlist.pro
index 378c574eb0..c53d553d6d 100644
--- a/tests/auto/corelib/tools/qlinkedlist/qlinkedlist.pro
+++ b/tests/auto/corelib/tools/qlinkedlist/qlinkedlist.pro
@@ -1,5 +1,7 @@
CONFIG += testcase
TARGET = tst_qlinkedlist
QT = core testlib
+qtConfig(c++14): CONFIG += c++14
+qtConfig(c++1z): CONFIG += c++1z
SOURCES = tst_qlinkedlist.cpp
DEFINES -= QT_NO_LINKED_LIST
diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp
index deb3b68c5c..df42b5dea9 100644
--- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp
+++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp
@@ -187,6 +187,7 @@ private slots:
void countInt() const;
void countMovable() const;
void countComplex() const;
+ void cpp17ctad() const;
void emptyInt() const;
void emptyMovable() const;
void emptyComplex() const;
@@ -594,6 +595,33 @@ void tst_QLinkedList::countComplex() const
QCOMPARE(liveCount, Complex::getLiveCount());
}
+void tst_QLinkedList::cpp17ctad() const
+{
+#ifdef __cpp_deduction_guides
+#define QVERIFY_IS_LIST_OF(obj, Type) \
+ QVERIFY2((std::is_same<decltype(obj), QLinkedList<Type>>::value), \
+ QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>()))
+#define CHECK(Type, One, Two, Three) \
+ do { \
+ const Type v[] = {One, Two, Three}; \
+ QLinkedList v1 = {One, Two, Three}; \
+ QVERIFY_IS_LIST_OF(v1, Type); \
+ QLinkedList v2(v1.begin(), v1.end()); \
+ QVERIFY_IS_LIST_OF(v2, Type); \
+ QLinkedList v3(std::begin(v), std::end(v)); \
+ QVERIFY_IS_LIST_OF(v3, Type); \
+ } while (false) \
+ /*end*/
+ CHECK(int, 1, 2, 3);
+ CHECK(double, 1.0, 2.0, 3.0);
+ CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three"));
+#undef QVERIFY_IS_LIST_OF
+#undef CHECK
+#else
+ QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler.");
+#endif
+}
+
template<typename T>
void tst_QLinkedList::empty() const
{
diff --git a/tests/auto/corelib/tools/qlist/qlist.pro b/tests/auto/corelib/tools/qlist/qlist.pro
index 47f0140abb..118c607880 100644
--- a/tests/auto/corelib/tools/qlist/qlist.pro
+++ b/tests/auto/corelib/tools/qlist/qlist.pro
@@ -1,4 +1,6 @@
CONFIG += testcase
TARGET = tst_qlist
QT = core testlib
+qtConfig(c++14): CONFIG += c++14
+qtConfig(c++1z): CONFIG += c++1z
SOURCES = $$PWD/tst_qlist.cpp
diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
index 5a485e88d2..cc9a3a16d1 100644
--- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp
+++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
@@ -310,6 +310,7 @@ private slots:
void lastComplex() const;
void constFirst() const;
void constLast() const;
+ void cpp17ctad() const;
void beginOptimal() const;
void beginMovable() const;
void beginComplex() const;
@@ -864,6 +865,33 @@ void tst_QList::constLast() const
QVERIFY(listCopy.isSharedWith(list));
}
+void tst_QList::cpp17ctad() const
+{
+#ifdef __cpp_deduction_guides
+#define QVERIFY_IS_LIST_OF(obj, Type) \
+ QVERIFY2((std::is_same<decltype(obj), QList<Type>>::value), \
+ QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>()))
+#define CHECK(Type, One, Two, Three) \
+ do { \
+ const Type v[] = {One, Two, Three}; \
+ QList v1 = {One, Two, Three}; \
+ QVERIFY_IS_LIST_OF(v1, Type); \
+ QList v2(v1.begin(), v1.end()); \
+ QVERIFY_IS_LIST_OF(v2, Type); \
+ QList v3(std::begin(v), std::end(v)); \
+ QVERIFY_IS_LIST_OF(v3, Type); \
+ } while (false) \
+ /*end*/
+ CHECK(int, 1, 2, 3);
+ CHECK(double, 1.0, 2.0, 3.0);
+ CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three"));
+#undef QVERIFY_IS_LIST_OF
+#undef CHECK
+#else
+ QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler.");
+#endif
+}
+
template<typename T>
void tst_QList::last() const
{
diff --git a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
index 8e184f3ef3..f25492d2db 100644
--- a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
+++ b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
@@ -42,6 +42,8 @@ private slots:
void getSet_data();
void getSet();
+ void transposed();
+
void rx();
void ry();
@@ -126,6 +128,11 @@ void tst_QPoint::getSet()
QCOMPARE(point.y(), i);
}
+void tst_QPoint::transposed()
+{
+ QCOMPARE(QPoint(1, 2).transposed(), QPoint(2, 1));
+}
+
void tst_QPoint::rx()
{
const QPoint originalPoint(-1, 0);
diff --git a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
index d4ccdf7ba6..e78a8e3082 100644
--- a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
+++ b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
@@ -46,6 +46,8 @@ private slots:
void getSet_data();
void getSet();
+ void transposed();
+
void rx();
void ry();
@@ -154,6 +156,11 @@ void tst_QPointF::getSet()
QCOMPARE(point.y(), r);
}
+void tst_QPointF::transposed()
+{
+ QCOMPARE(QPointF(1, 2).transposed(), QPointF(2, 1));
+}
+
void tst_QPointF::rx()
{
const QPointF originalPoint(-1, 0);
diff --git a/tests/auto/corelib/tools/qset/qset.pro b/tests/auto/corelib/tools/qset/qset.pro
index d0c6337147..3ae4bc4805 100644
--- a/tests/auto/corelib/tools/qset/qset.pro
+++ b/tests/auto/corelib/tools/qset/qset.pro
@@ -1,6 +1,8 @@
CONFIG += testcase
TARGET = tst_qset
QT = core testlib
+qtConfig(c++14): CONFIG += c++14
+qtConfig(c++1z): CONFIG += c++1z
SOURCES = tst_qset.cpp
DEFINES -= QT_NO_JAVA_STYLE_ITERATORS
diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp
index 31b4c0449e..8a545712a2 100644
--- a/tests/auto/corelib/tools/qset/tst_qset.cpp
+++ b/tests/auto/corelib/tools/qset/tst_qset.cpp
@@ -54,6 +54,7 @@ private slots:
void detach();
void isDetached();
void clear();
+ void cpp17ctad();
void remove();
void contains();
void containsSet();
@@ -325,6 +326,33 @@ void tst_QSet::clear()
QVERIFY(set2.size() == 0);
}
+void tst_QSet::cpp17ctad()
+{
+#ifdef __cpp_deduction_guides
+#define QVERIFY_IS_SET_OF(obj, Type) \
+ QVERIFY2((std::is_same<decltype(obj), QSet<Type>>::value), \
+ QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>()))
+#define CHECK(Type, One, Two, Three) \
+ do { \
+ const Type v[] = {One, Two, Three}; \
+ QSet v1 = {One, Two, Three}; \
+ QVERIFY_IS_SET_OF(v1, Type); \
+ QSet v2(v1.begin(), v1.end()); \
+ QVERIFY_IS_SET_OF(v2, Type); \
+ QSet v3(std::begin(v), std::end(v)); \
+ QVERIFY_IS_SET_OF(v3, Type); \
+ } while (false) \
+ /*end*/
+ CHECK(int, 1, 2, 3);
+ CHECK(double, 1.0, 2.0, 3.0);
+ CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three"));
+#undef QVERIFY_IS_SET_OF
+#undef CHECK
+#else
+ QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler.");
+#endif
+}
+
void tst_QSet::remove()
{
QSet<QString> set1;
diff --git a/tests/auto/corelib/tools/qsize/tst_qsize.cpp b/tests/auto/corelib/tools/qsize/tst_qsize.cpp
index 385ff18ce5..6824bad9c8 100644
--- a/tests/auto/corelib/tools/qsize/tst_qsize.cpp
+++ b/tests/auto/corelib/tools/qsize/tst_qsize.cpp
@@ -29,6 +29,7 @@
#include <QtTest/QtTest>
#include <qsize.h>
+Q_DECLARE_METATYPE(QMargins)
class tst_QSize : public QObject
{
@@ -43,6 +44,9 @@ private slots:
void boundedTo_data();
void boundedTo();
+ void grownOrShrunkBy_data();
+ void grownOrShrunkBy();
+
void transpose_data();
void transpose();
};
@@ -186,6 +190,46 @@ void tst_QSize::boundedTo()
QCOMPARE( input1.boundedTo(input2), expected);
}
+void tst_QSize::grownOrShrunkBy_data()
+{
+ QTest::addColumn<QSize>("input");
+ QTest::addColumn<QMargins>("margins");
+ QTest::addColumn<QSize>("grown");
+ QTest::addColumn<QSize>("shrunk");
+
+ auto row = [](QSize i, QMargins m, QSize g, QSize s) {
+ QTest::addRow("{%d,%d}/{%d,%d,%d,%d}", i.width(), i.height(),
+ m.left(), m.top(), m.right(), m.bottom())
+ << i << m << g << s;
+ };
+
+ const QSize zero = {0, 0};
+ const QSize some = {100, 200};
+ const QMargins zeroMargins = {};
+ const QMargins negative = {-1, -2, -3, -4};
+ const QMargins positive = { 1, 2, 3, 4};
+
+ row(zero, zeroMargins, zero, zero);
+ row(zero, negative, {-4, -6}, { 4, 6});
+ row(zero, positive, { 4, 6}, {-4, -6});
+ row(some, zeroMargins, some, some);
+ row(some, negative, { 96, 194}, {104, 206});
+ row(some, positive, {104, 206}, { 96, 194});
+}
+
+void tst_QSize::grownOrShrunkBy()
+{
+ QFETCH(const QSize, input);
+ QFETCH(const QMargins, margins);
+ QFETCH(const QSize, grown);
+ QFETCH(const QSize, shrunk);
+
+ QCOMPARE(input.grownBy(margins), grown);
+ QCOMPARE(input.shrunkBy(margins), shrunk);
+ QCOMPARE(grown.shrunkBy(margins), input);
+ QCOMPARE(shrunk.grownBy(margins), input);
+}
+
void tst_QSize::transpose_data()
{
QTest::addColumn<QSize>("input1");
diff --git a/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp b/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp
index 42801d63a9..bbffa74a62 100644
--- a/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp
+++ b/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp
@@ -29,6 +29,7 @@
#include <QtTest/QtTest>
#include <qsize.h>
+Q_DECLARE_METATYPE(QMarginsF)
class tst_QSizeF : public QObject
{
@@ -45,6 +46,9 @@ private slots:
void boundedTo_data();
void boundedTo();
+ void grownOrShrunkBy_data();
+ void grownOrShrunkBy();
+
void transpose_data();
void transpose();
};
@@ -152,6 +156,46 @@ void tst_QSizeF::boundedTo() {
QCOMPARE( input1.boundedTo(input2), expected);
}
+void tst_QSizeF::grownOrShrunkBy_data()
+{
+ QTest::addColumn<QSizeF>("input");
+ QTest::addColumn<QMarginsF>("margins");
+ QTest::addColumn<QSizeF>("grown");
+ QTest::addColumn<QSizeF>("shrunk");
+
+ auto row = [](QSizeF i, QMarginsF m, QSizeF g, QSizeF s) {
+ QTest::addRow("{%g,%g}/{%g,%g,%g,%g}", i.width(), i.height(),
+ m.left(), m.top(), m.right(), m.bottom())
+ << i << m << g << s;
+ };
+
+ const QSizeF zero = {0, 0};
+ const QSizeF some = {100, 200};
+ const QMarginsF zeroMargins = {};
+ const QMarginsF negative = {-1, -2, -3, -4};
+ const QMarginsF positive = { 1, 2, 3, 4};
+
+ row(zero, zeroMargins, zero, zero);
+ row(zero, negative, {-4, -6}, { 4, 6});
+ row(zero, positive, { 4, 6}, {-4, -6});
+ row(some, zeroMargins, some, some);
+ row(some, negative, { 96, 194}, {104, 206});
+ row(some, positive, {104, 206}, { 96, 194});
+}
+
+void tst_QSizeF::grownOrShrunkBy()
+{
+ QFETCH(const QSizeF, input);
+ QFETCH(const QMarginsF, margins);
+ QFETCH(const QSizeF, grown);
+ QFETCH(const QSizeF, shrunk);
+
+ QCOMPARE(input.grownBy(margins), grown);
+ QCOMPARE(input.shrunkBy(margins), shrunk);
+ QCOMPARE(grown.shrunkBy(margins), input);
+ QCOMPARE(shrunk.grownBy(margins), input);
+}
+
void tst_QSizeF::transpose_data() {
QTest::addColumn<QSizeF>("input1");
QTest::addColumn<QSizeF>("expected");
diff --git a/tests/auto/corelib/tools/qtimeline/BLACKLIST b/tests/auto/corelib/tools/qtimeline/BLACKLIST
index b60cab31fa..9794b0059f 100644
--- a/tests/auto/corelib/tools/qtimeline/BLACKLIST
+++ b/tests/auto/corelib/tools/qtimeline/BLACKLIST
@@ -1,8 +1,6 @@
[interpolation]
-osx-10.12
windows-10 msvc-2015
-osx-10.13
-windows-7sp1
+osx
[frameRate]
osx-10.12
osx-10.13
diff --git a/tests/auto/corelib/tools/qvarlengtharray/qvarlengtharray.pro b/tests/auto/corelib/tools/qvarlengtharray/qvarlengtharray.pro
index 108fb33db5..14b2bc213b 100644
--- a/tests/auto/corelib/tools/qvarlengtharray/qvarlengtharray.pro
+++ b/tests/auto/corelib/tools/qvarlengtharray/qvarlengtharray.pro
@@ -1,4 +1,6 @@
CONFIG += testcase
TARGET = tst_qvarlengtharray
QT = core testlib
+qtConfig(c++14): CONFIG += c++14
+qtConfig(c++1z): CONFIG += c++1z
SOURCES = tst_qvarlengtharray.cpp
diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
index 3d90644aa3..a1d0100f96 100644
--- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
+++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
@@ -44,6 +44,7 @@ private slots:
void realloc();
void reverseIterators();
void count();
+ void cpp17ctad();
void first();
void last();
void squeeze();
@@ -717,6 +718,34 @@ void tst_QVarLengthArray::count()
}
}
+void tst_QVarLengthArray::cpp17ctad()
+{
+#ifdef __cpp_deduction_guides
+#define QVERIFY_IS_VLA_OF(obj, Type) \
+ QVERIFY2((std::is_same<decltype(obj), QVarLengthArray<Type>>::value), \
+ QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>()))
+#define CHECK(Type, One, Two, Three) \
+ do { \
+ const Type v[] = {One, Two, Three}; \
+ QVarLengthArray v1 = {One, Two, Three}; \
+ QVERIFY_IS_VLA_OF(v1, Type); \
+ QVarLengthArray v2(v1.begin(), v1.end()); \
+ QVERIFY_IS_VLA_OF(v2, Type); \
+ QVarLengthArray v3(std::begin(v), std::end(v)); \
+ QVERIFY_IS_VLA_OF(v3, Type); \
+ } while (false) \
+ /*end*/
+ CHECK(int, 1, 2, 3);
+ CHECK(double, 1.0, 2.0, 3.0);
+ CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three"));
+#undef QVERIFY_IS_VLA_OF
+#undef CHECK
+#else
+ QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler.");
+#endif
+
+}
+
void tst_QVarLengthArray::first()
{
// append some items, make sure it stays sane
diff --git a/tests/auto/corelib/tools/qvector/qvector.pro b/tests/auto/corelib/tools/qvector/qvector.pro
index b9a4ae747b..689d9b87a2 100644
--- a/tests/auto/corelib/tools/qvector/qvector.pro
+++ b/tests/auto/corelib/tools/qvector/qvector.pro
@@ -1,5 +1,7 @@
CONFIG += testcase
qtConfig(c++11): CONFIG += c++11
+qtConfig(c++14): CONFIG += c++14
+qtConfig(c++1z): CONFIG += c++1z
TARGET = tst_qvector
QT = core testlib
SOURCES = $$PWD/tst_qvector.cpp
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index 05b5579d64..08d5a8cd50 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -230,6 +230,7 @@ private slots:
void countInt() const;
void countMovable() const;
void countCustom() const;
+ void cpp17ctad() const;
void data() const;
void emptyInt() const;
void emptyMovable() const;
@@ -914,6 +915,33 @@ void tst_QVector::countCustom() const
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
+void tst_QVector::cpp17ctad() const
+{
+#ifdef __cpp_deduction_guides
+#define QVERIFY_IS_VECTOR_OF(obj, Type) \
+ QVERIFY2((std::is_same<decltype(obj), QVector<Type>>::value), \
+ QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>()))
+#define CHECK(Type, One, Two, Three) \
+ do { \
+ const Type v[] = {One, Two, Three}; \
+ QVector v1 = {One, Two, Three}; \
+ QVERIFY_IS_VECTOR_OF(v1, Type); \
+ QVector v2(v1.begin(), v1.end()); \
+ QVERIFY_IS_VECTOR_OF(v2, Type); \
+ QVector v3(std::begin(v), std::end(v)); \
+ QVERIFY_IS_VECTOR_OF(v3, Type); \
+ } while (false) \
+ /*end*/
+ CHECK(int, 1, 2, 3);
+ CHECK(double, 1.0, 2.0, 3.0);
+ CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three"));
+#undef QVERIFY_IS_VECTOR_OF
+#undef CHECK
+#else
+ QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler.");
+#endif
+}
+
void tst_QVector::data() const
{
QVector<int> myvec;