summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp7
-rw-r--r--tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro1
-rw-r--r--tests/auto/corelib/global/qlogging/test/test.pro2
-rw-r--r--tests/auto/corelib/io/qfile/test/test.pro2
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.pro1
-rw-r--r--tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro2
-rw-r--r--tests/auto/corelib/io/qprocess/test/test.pro2
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp73
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp2
-rw-r--r--tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp25
-rw-r--r--tests/auto/corelib/json/json.pro1
-rw-r--r--tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro1
-rw-r--r--tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro1
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp2
-rw-r--r--tests/auto/corelib/kernel/qsharedmemory/test/test.pro1
-rw-r--r--tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro1
-rw-r--r--tests/auto/corelib/plugin/qfactoryloader/test/test.pro2
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst/tst.pro1
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro11
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst/tst.pro1
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/test/test.pro2
-rw-r--r--tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp50
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp4
-rw-r--r--tests/auto/corelib/tools/qlocale/test/test.pro1
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp24
-rw-r--r--tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp68
26 files changed, 253 insertions, 35 deletions
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index bb6ec1c8e7..083526fdc4 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -102,6 +102,13 @@ void tst_QGlobal::for_each()
QCOMPARE(i, counter++);
}
QCOMPARE(counter, list.count());
+
+ // check whether we can use a lambda
+ counter = 0;
+ foreach (int i, [&](){ return list; }()) {
+ QCOMPARE(i, counter++);
+ }
+ QCOMPARE(counter, list.count());
}
void tst_QGlobal::qassert()
diff --git a/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro b/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro
index 056d940da7..21bb040b8d 100644
--- a/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro
+++ b/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro
@@ -5,7 +5,6 @@ QT -= gui
TARGET = tst_qglobalstatic
CONFIG += console
-CONFIG -= app_bundle
CONFIG += exceptions
SOURCES += tst_qglobalstatic.cpp
diff --git a/tests/auto/corelib/global/qlogging/test/test.pro b/tests/auto/corelib/global/qlogging/test/test.pro
index 93eee7307a..7c46ae9d16 100644
--- a/tests/auto/corelib/global/qlogging/test/test.pro
+++ b/tests/auto/corelib/global/qlogging/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
qtConfig(c++11): CONFIG += c++11
qtConfig(c++14): CONFIG += c++14
TARGET = ../tst_qlogging
diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro
index c0c4b9d5d2..5f1963cf5f 100644
--- a/tests/auto/corelib/io/qfile/test/test.pro
+++ b/tests/auto/corelib/io/qfile/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT = core-private core testlib
qtHaveModule(network): QT += network
else: DEFINES += QT_NO_NETWORK
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
index 7b83d5dbe8..7a304fe779 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-CONFIG -= app_bundle
TARGET = tst_qlockfile
SOURCES += tst_qlockfile.cpp
diff --git a/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro b/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro
index e46e7e1100..8e46320e0c 100644
--- a/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro
+++ b/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro
@@ -1,4 +1,4 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT = core testlib
SOURCES = tst_qprocessnoapplication.cpp
diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro
index 96d105a4b4..7d6a7973dc 100644
--- a/tests/auto/corelib/io/qprocess/test/test.pro
+++ b/tests/auto/corelib/io/qprocess/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT = core-private testlib network
SOURCES = ../tst_qprocess.cpp
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index dadf4b612e..fcff13b416 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -183,6 +183,7 @@ private slots:
void embeddedZeroByte_data();
void embeddedZeroByte();
+ void testXdg();
private:
void cleanupTestFiles();
@@ -3557,5 +3558,77 @@ void tst_QSettings::consistentRegistryStorage()
}
#endif
+#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(QT_NO_STANDARDPATHS)
+QT_BEGIN_NAMESPACE
+extern void clearDefaultPaths();
+QT_END_NAMESPACE
+#endif
+void tst_QSettings::testXdg()
+{
+#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(QT_NO_STANDARDPATHS)
+ // Note: The XDG_CONFIG_DIRS test must be done before overriding the system path
+ // by QSettings::setPath/setSystemIniPath (used in cleanupTestFiles()).
+ clearDefaultPaths();
+
+ // Initialize the env. variable & populate testing files.
+ const QStringList config_dirs = { settingsPath("xdg_1st"), settingsPath("xdg_2nd"), settingsPath("xdg_3rd") };
+ qputenv("XDG_CONFIG_DIRS", config_dirs.join(':').toUtf8());
+ QList<QSettings *> xdg_orgs, xdg_apps;
+ for (const auto & dir : config_dirs) {
+ xdg_orgs << new QSettings{dir + "/software.org.conf", QSettings::NativeFormat};
+ xdg_apps << new QSettings{dir + "/software.org/KillerAPP.conf", QSettings::NativeFormat};
+ }
+ Q_ASSERT(config_dirs.size() == 3 && xdg_orgs.size() == 3 && xdg_apps.size() == 3);
+ for (int i = 0; i < 3; ++i) {
+ xdg_orgs[i]->setValue("all", QString{"all_org%1"}.arg(i));
+ xdg_apps[i]->setValue("all", QString{"all_app%1"}.arg(i));
+ xdg_orgs[i]->setValue("all_only_org", QString{"all_only_org%1"}.arg(i));
+ xdg_apps[i]->setValue("all_only_app", QString{"all_only_app%1"}.arg(i));
+
+ if (i > 0) {
+ xdg_orgs[i]->setValue("from2nd", QString{"from2nd_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from2nd", QString{"from2nd_app%1"}.arg(i));
+ xdg_orgs[i]->setValue("from2nd_only_org", QString{"from2nd_only_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from2nd_only_app", QString{"from2nd_only_app%1"}.arg(i));
+ }
+
+ if (i > 1) {
+ xdg_orgs[i]->setValue("from3rd", QString{"from3rd_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from3rd", QString{"from3rd_app%1"}.arg(i));
+ xdg_orgs[i]->setValue("from3rd_only_org", QString{"from3rd_only_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from3rd_only_app", QString{"from3rd_only_app%1"}.arg(i));
+ }
+ }
+ qDeleteAll(xdg_apps);
+ qDeleteAll(xdg_orgs);
+
+ // Do the test.
+ QSettings app{QSettings::SystemScope, "software.org", "KillerAPP"}, org{QSettings::SystemScope, "software.org"};
+
+ QVERIFY(app.value("all").toString() == "all_app0");
+ QVERIFY(org.value("all").toString() == "all_org0");
+ QVERIFY(app.value("all_only_org").toString() == "all_only_org0");
+ QVERIFY(org.value("all_only_org").toString() == "all_only_org0");
+ QVERIFY(app.value("all_only_app").toString() == "all_only_app0");
+ QVERIFY(org.value("all_only_app").toString() == QString{});
+
+ QVERIFY(app.value("from2nd").toString() == "from2nd_app1");
+ QVERIFY(org.value("from2nd").toString() == "from2nd_org1");
+ QVERIFY(app.value("from2nd_only_org").toString() == "from2nd_only_org1");
+ QVERIFY(org.value("from2nd_only_org").toString() == "from2nd_only_org1");
+ QVERIFY(app.value("from2nd_only_app").toString() == "from2nd_only_app1");
+ QVERIFY(org.value("from2nd_only_app").toString() == QString{});
+
+ QVERIFY(app.value("from3rd").toString() == "from3rd_app2");
+ QVERIFY(org.value("from3rd").toString() == "from3rd_org2");
+ QVERIFY(app.value("from3rd_only_org").toString() == "from3rd_only_org2");
+ QVERIFY(org.value("from3rd_only_org").toString() == "from3rd_only_org2");
+ QVERIFY(app.value("from3rd_only_app").toString() == "from3rd_only_app2");
+ QVERIFY(org.value("from3rd_only_app").toString() == QString{});
+#else
+ QSKIP("This test is performed in QT_BUILD_INTERNAL on Q_XDG_PLATFORM with use of standard paths only.");
+#endif
+}
+
QTEST_MAIN(tst_QSettings)
#include "tst_qsettings.moc"
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index a7a761a2da..0a00e00d83 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -385,7 +385,7 @@ void tst_qstandardpaths::testFindExecutable_data()
QTest::newRow("win-cmd-nosuffix")
<< QString() << QString::fromLatin1("cmd") << cmdPath;
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8) {
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8) {
// The logo executable on Windows 8 is perfectly suited for testing that the
// suffix mechanism is not thrown off by dots in the name.
// Note: Requires disabling WOW64 redirection, see initTestCase()
diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
index 487c13be94..758bbead84 100644
--- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
+++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
@@ -57,6 +57,8 @@ private slots:
void fileTemplate_data();
void getSetCheck();
void fileName();
+ void filePath_data();
+ void filePath();
void autoRemove();
void nonWritableCurrentDir();
void openOnRootDrives();
@@ -204,6 +206,29 @@ void tst_QTemporaryDir::fileName()
QCOMPARE(absoluteFilePath, absoluteTempPath);
}
+void tst_QTemporaryDir::filePath_data()
+{
+ QTest::addColumn<QString>("templatePath");
+ QTest::addColumn<QString>("fileName");
+
+ QTest::newRow("0") << QString() << "/tmpfile";
+ QTest::newRow("1") << QString() << "tmpfile";
+ QTest::newRow("2") << "XXXXX" << "tmpfile";
+ QTest::newRow("3") << "YYYYY" << "subdir/file";
+}
+
+void tst_QTemporaryDir::filePath()
+{
+ QFETCH(QString, templatePath);
+ QFETCH(QString, fileName);
+
+ QTemporaryDir dir(templatePath);
+ const QString filePath = dir.filePath(fileName);
+ const QString expectedFilePath = QDir::isAbsolutePath(fileName) ?
+ QString() : dir.path() + QLatin1Char('/') + fileName;
+ QCOMPARE(filePath, expectedFilePath);
+}
+
void tst_QTemporaryDir::autoRemove()
{
// Test auto remove
diff --git a/tests/auto/corelib/json/json.pro b/tests/auto/corelib/json/json.pro
index 16c2ae2fb7..8fa17c5c38 100644
--- a/tests/auto/corelib/json/json.pro
+++ b/tests/auto/corelib/json/json.pro
@@ -1,6 +1,5 @@
TARGET = tst_json
QT = core-private testlib
-CONFIG -= app_bundle
CONFIG += testcase
!android:TESTDATA += bom.json test.json test.bjson test3.json test2.json
diff --git a/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro b/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro
index a42cd60236..9dfa29b0fc 100644
--- a/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro
+++ b/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro
@@ -2,4 +2,3 @@ CONFIG += testcase
TARGET = tst_qmetamethod
QT = core testlib
SOURCES = tst_qmetamethod.cpp
-mac:CONFIG -= app_bundle
diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro b/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro
index f3153b3fd4..4da90c1096 100644
--- a/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro
+++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro
@@ -2,4 +2,3 @@ CONFIG += testcase
TARGET = tst_qmetaobjectbuilder
QT = core-private testlib
SOURCES = tst_qmetaobjectbuilder.cpp
-mac:CONFIG -= app_bundle
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 91810cdcd8..5eea858107 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -3401,14 +3401,12 @@ void tst_QObject::dumpObjectInfo()
QObject a, b;
QObject::connect(&a, SIGNAL(destroyed(QObject*)), &b, SLOT(deleteLater()));
a.disconnect(&b);
-#ifdef QT_DEBUG
QTest::ignoreMessage(QtDebugMsg, "OBJECT QObject::unnamed");
QTest::ignoreMessage(QtDebugMsg, " SIGNALS OUT");
QTest::ignoreMessage(QtDebugMsg, " signal: destroyed(QObject*)");
QTest::ignoreMessage(QtDebugMsg, " <Disconnected receiver>");
QTest::ignoreMessage(QtDebugMsg, " SIGNALS IN");
QTest::ignoreMessage(QtDebugMsg, " <None>");
-#endif
a.dumpObjectInfo(); // should not crash
}
diff --git a/tests/auto/corelib/kernel/qsharedmemory/test/test.pro b/tests/auto/corelib/kernel/qsharedmemory/test/test.pro
index fabd2cf7a3..61124c27ee 100644
--- a/tests/auto/corelib/kernel/qsharedmemory/test/test.pro
+++ b/tests/auto/corelib/kernel/qsharedmemory/test/test.pro
@@ -2,7 +2,6 @@ CONFIG += testcase
QT = core-private testlib
-mac:CONFIG -= app_bundle
linux:LIBS += -lrt
SOURCES += tst_qsharedmemory.cpp
diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro b/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro
index a0f63741d3..f60207eb01 100644
--- a/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro
+++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro
@@ -2,7 +2,6 @@ CONFIG += testcase
QT = core testlib
win32: CONFIG += console
-mac:CONFIG -= app_bundle
SOURCES += tst_qsystemsemaphore.cpp
TARGET = tst_qsystemsemaphore
diff --git a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro
index 3345651730..9338f4ecc9 100644
--- a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro
+++ b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro
@@ -17,8 +17,6 @@ win32 {
}
}
-mac: CONFIG -= app_bundle
-
!qtConfig(library) {
LIBS += -L ../bin/ -lplugin1 -lplugin2
}
diff --git a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
index d59cd738bf..6e71ec8ff9 100644
--- a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
+++ b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-CONFIG -= app_bundle
TARGET = ../tst_qlibrary
QT = core testlib
SOURCES = ../tst_qlibrary.cpp
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
index e3d5bff5ff..7f7caa7f76 100644
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
@@ -6,11 +6,16 @@ OTHER_FILES += \
# Needs explicit load()ing due to aux template. Relies on QT being non-empty.
load(qt)
+i386_d.target = good.i386.dylib
+i386_d.depends = EXPORT_VALID_ARCHS=i386
i386.target = good.i386.dylib
-i386.commands = $(CXX) $(CXXFLAGS) -shared -arch i386 -o $@ -I$(INCPATH) $<
+i386.commands = $(CXX) $(CXXFLAGS) -shared -o $@ -I$(INCPATH) $<
i386.depends += $$PWD/../fakeplugin.cpp
+
+x86_64_d.target = good.x86_64.dylib
+x86_64_d.depends = EXPORT_VALID_ARCHS=x86_64
x86_64.target = good.x86_64.dylib
-x86_64.commands = $(CXX) $(CXXFLAGS) -shared -arch x86_64 -o $@ -I$(INCPATH) $<
+x86_64.commands = $(CXX) $(CXXFLAGS) -shared -o $@ -I$(INCPATH) $<
x86_64.depends += $$PWD/../fakeplugin.cpp
# Current Mac OS X toolchains have no compiler for PPC anymore
@@ -49,7 +54,7 @@ bad.depends += $$PWD/generate-bad.pl
MYTARGETS = $$fat_all.depends fat_all fat_no_x86_64 fat_no_i386 \
fat_stub_i386 fat_stub_x86_64 bad
all.depends += $$MYTARGETS
-QMAKE_EXTRA_TARGETS += $$MYTARGETS all
+QMAKE_EXTRA_TARGETS += i386_d x86_64_d $$MYTARGETS all
QMAKE_CLEAN += $$i386.target $$x86_64.target $$ppc64.target $$fat_all.target \
$$fat_no_i386.target $$fat_no_x86_64.target \
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
index 5f9fa6664b..c20e56ba4c 100644
--- a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
@@ -4,7 +4,6 @@ QT = core testlib
qtConfig(private_tests): QT += core-private
SOURCES = ../tst_qpluginloader.cpp ../fakeplugin.cpp
HEADERS = ../theplugin/plugininterface.h
-CONFIG -= app_bundle
win32 {
CONFIG(debug, debug|release) {
diff --git a/tests/auto/corelib/thread/qthreadstorage/test/test.pro b/tests/auto/corelib/thread/qthreadstorage/test/test.pro
index b9d661a9af..1a1fede186 100644
--- a/tests/auto/corelib/thread/qthreadstorage/test/test.pro
+++ b/tests/auto/corelib/thread/qthreadstorage/test/test.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = ../tst_qthreadstorage
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
CONFIG += console
QT = core testlib
SOURCES = ../tst_qthreadstorage.cpp
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
index 3be8379d29..ba2adddca0 100644
--- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
+++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
@@ -65,6 +65,8 @@ private slots:
void simpleVectorReserve();
void allocate_data();
void allocate();
+ void reallocate_data() { allocate_data(); }
+ void reallocate();
void alignment_data();
void alignment();
void typedData();
@@ -742,6 +744,54 @@ void tst_QArrayData::allocate()
}
}
+void tst_QArrayData::reallocate()
+{
+ QFETCH(size_t, objectSize);
+ QFETCH(size_t, alignment);
+ QFETCH(QArrayData::AllocationOptions, allocateOptions);
+ QFETCH(bool, isCapacityReserved);
+ QFETCH(const QArrayData *, commonEmpty);
+
+ // Maximum alignment that can be requested is that of QArrayData,
+ // otherwise, we can't use reallocate().
+ Q_ASSERT(alignment <= Q_ALIGNOF(QArrayData));
+
+ // Minimum alignment that can be requested is that of QArrayData.
+ // Typically, this alignment is sizeof(void *) and ensured by malloc.
+ size_t minAlignment = qMax(alignment, Q_ALIGNOF(QArrayData));
+
+ int capacity = 10;
+ Deallocator keeper(objectSize, minAlignment);
+ QArrayData *data = QArrayData::allocate(objectSize, minAlignment, capacity,
+ QArrayData::AllocationOptions(allocateOptions) & ~QArrayData::Grow);
+ keeper.headers.append(data);
+
+ memset(data->data(), 'A', objectSize * capacity);
+ data->size = capacity;
+
+ // now try to reallocate
+ int newCapacity = 40;
+ data = QArrayData::reallocateUnaligned(data, objectSize, newCapacity,
+ QArrayData::AllocationOptions(allocateOptions));
+ QVERIFY(data);
+ keeper.headers.clear();
+ keeper.headers.append(data);
+
+ QCOMPARE(data->size, capacity);
+ if (allocateOptions & QArrayData::Grow)
+ QVERIFY(data->alloc > uint(newCapacity));
+ else
+ QCOMPARE(data->alloc, uint(newCapacity));
+ QCOMPARE(data->capacityReserved, uint(isCapacityReserved));
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
+ QFETCH(bool, isSharable);
+ QCOMPARE(data->ref.isSharable(), isSharable);
+#endif
+
+ for (int i = 0; i < capacity; ++i)
+ QCOMPARE(static_cast<char *>(data->data())[i], 'A');
+}
+
class Unaligned
{
char dummy[8];
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index 4604e664b0..d4ae1b2a91 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -3145,17 +3145,17 @@ void tst_QDateTime::timeZones() const
// Test local to MSecs
// - Test first occurrence 02:00:00 = 1 hour before tran
hourBeforeStd = QDateTime(QDate(2013, 10, 27), QTime(2, 0, 0), cet);
+ QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QCOMPARE(hourBeforeStd.toMSecsSinceEpoch(), dstToStdMSecs - 3600000);
// - Test first occurrence 02:59:59.999 = 1 msec before tran
msecBeforeStd = QDateTime(QDate(2013, 10, 27), QTime(2, 59, 59, 999), cet);
+ QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QCOMPARE(msecBeforeStd.toMSecsSinceEpoch(), dstToStdMSecs - 1);
// - Test second occurrence 02:00:00 = at tran
atStd = QDateTime(QDate(2013, 10, 27), QTime(2, 0, 0), cet);
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QCOMPARE(atStd.toMSecsSinceEpoch(), dstToStdMSecs);
// - Test second occurrence 03:00:00 = 59 mins after tran
afterStd = QDateTime(QDate(2013, 10, 27), QTime(2, 59, 59, 999), cet);
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QCOMPARE(afterStd.toMSecsSinceEpoch(), dstToStdMSecs + 3600000 - 1);
// - Test 03:00:00 = 1 hour after tran
hourAfterStd = QDateTime(QDate(2013, 10, 27), QTime(3, 0, 0), cet);
diff --git a/tests/auto/corelib/tools/qlocale/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro
index 595ee258e7..c87e29e764 100644
--- a/tests/auto/corelib/tools/qlocale/test/test.pro
+++ b/tests/auto/corelib/tools/qlocale/test/test.pro
@@ -1,5 +1,4 @@
CONFIG += console testcase
-CONFIG -= app_bundle
QT = core testlib core-private
embedded: QT += gui
SOURCES = ../tst_qlocale.cpp
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index 8d9a789507..7681f4755c 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -1754,6 +1754,30 @@ void tst_QLocale::numberOptions()
QVERIFY(ok);
locale.toDouble(QString("1.24e+01"), &ok);
QVERIFY(!ok);
+
+ QCOMPARE(locale.toString(12.4, 'g', 5), QString("12.4"));
+ locale.setNumberOptions(QLocale::IncludeTrailingZeroesAfterDot);
+ QCOMPARE(locale.numberOptions(), QLocale::IncludeTrailingZeroesAfterDot);
+ QCOMPARE(locale.toString(12.4, 'g', 5), QString("12.400"));
+
+ locale.toDouble(QString("1.24e+01"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("1.2400e+01"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("12.4"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("12.400"), &ok);
+ QVERIFY(ok);
+ locale.setNumberOptions(QLocale::RejectTrailingZeroesAfterDot);
+ QCOMPARE(locale.numberOptions(), QLocale::RejectTrailingZeroesAfterDot);
+ locale.toDouble(QString("1.24e+01"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("1.2400e+01"), &ok);
+ QVERIFY(!ok);
+ locale.toDouble(QString("12.4"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("12.400"), &ok);
+ QVERIFY(!ok);
}
void tst_QLocale::negativeNumbers()
diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
index c631b395f8..38aaff0edc 100644
--- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
@@ -45,6 +45,8 @@ private slots:
void dataStreamTest();
void isTimeZoneIdAvailable();
void availableTimeZoneIds();
+ void transitionEachZone_data();
+ void transitionEachZone();
void stressTest();
void windowsId();
void isValidId_data();
@@ -57,20 +59,20 @@ private slots:
void winTest();
private:
- void printTimeZone(const QTimeZone tz);
+ void printTimeZone(const QTimeZone &tz);
#ifdef QT_BUILD_INTERNAL
void testCetPrivate(const QTimeZonePrivate &tzp);
#endif // QT_BUILD_INTERNAL
- bool debug;
+ const bool debug;
};
tst_QTimeZone::tst_QTimeZone()
-{
// Set to true to print debug output, test Display Names and run long stress tests
- debug = false;
+ : debug(false)
+{
}
-void tst_QTimeZone::printTimeZone(const QTimeZone tz)
+void tst_QTimeZone::printTimeZone(const QTimeZone &tz)
{
QDateTime now = QDateTime::currentDateTime();
QDateTime jan = QDateTime(QDate(2012, 1, 1), QTime(0, 0, 0), Qt::UTC);
@@ -367,6 +369,56 @@ void tst_QTimeZone::isTimeZoneIdAvailable()
QCOMPARE(QTimeZonePrivate::isValidId("12345678901234/123456789012345"), false);
}
+void tst_QTimeZone::transitionEachZone_data()
+{
+ QTest::addColumn<QByteArray>("zone");
+ QTest::addColumn<qint64>("secs");
+ QTest::addColumn<int>("start");
+ QTest::addColumn<int>("stop");
+
+ struct {
+ qint64 baseSecs;
+ int start, stop;
+ int year;
+ } table[] = {
+ { 25666200, 3, 12, 1970 }, // 1970-10-25 01:30 UTC; North America
+ { 1288488600, -4, 8, 2010 } // 2010-10-31 01:30 UTC; Europe, Russia
+ };
+
+ QString name;
+ for (int k = sizeof(table) / sizeof(table[0]); k-- > 0; ) {
+ foreach (QByteArray zone, QTimeZone::availableTimeZoneIds()) {
+ name.sprintf("%s@%d", zone.constData(), table[k].year);
+ QTest::newRow(name.toUtf8().constData())
+ << zone
+ << table[k].baseSecs
+ << table[k].start
+ << table[k].stop;
+ }
+ }
+}
+
+void tst_QTimeZone::transitionEachZone()
+{
+ // Regression test: round-trip fromMsecs/toMSecs should be idempotent; but
+ // various zones failed during fall-back transitions.
+ QFETCH(QByteArray, zone);
+ QFETCH(qint64, secs);
+ QFETCH(int, start);
+ QFETCH(int, stop);
+ QTimeZone named(zone);
+
+ for (int i = start; i < stop; i++) {
+ qint64 here = secs + i * 3600;
+ QDateTime when = QDateTime::fromMSecsSinceEpoch(here * 1000, named);
+ qint64 stamp = when.toMSecsSinceEpoch();
+ if (here * 1000 != stamp) // (The +1 is due to using *1*:30 as baseSecs.)
+ qDebug() << "Failing for" << zone << "at half past" << (i + 1) << "UTC";
+ QCOMPARE(stamp % 1000, 0);
+ QCOMPARE(here - stamp / 1000, 0);
+ }
+}
+
void tst_QTimeZone::availableTimeZoneIds()
{
if (debug) {
@@ -704,9 +756,9 @@ void tst_QTimeZone::tzTest()
// Test display names by type, either ICU or abbreviation only
QLocale enUS("en_US");
-#ifdef QT_USE_ICU
// Only test names in debug mode, names used can vary by ICU version installed
if (debug) {
+#ifdef QT_USE_ICU
QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::LongName, enUS),
QString("Central European Standard Time"));
QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::ShortName, enUS),
@@ -726,9 +778,7 @@ void tst_QTimeZone::tzTest()
QString("GMT+01:00"));
QCOMPARE(tzp.displayName(QTimeZone::GenericTime, QTimeZone::OffsetName, enUS),
QString("UTC+01:00"));
- }
#else
- if (debug) {
QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::LongName, enUS),
QString("CET"));
QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::ShortName, enUS),
@@ -747,10 +797,8 @@ void tst_QTimeZone::tzTest()
QString("CET"));
QCOMPARE(tzp.displayName(QTimeZone::GenericTime, QTimeZone::OffsetName, enUS),
QString("CET"));
- }
#endif // QT_USE_ICU
- if (debug) {
// Test Abbreviations
QCOMPARE(tzp.abbreviation(std), QString("CET"));
QCOMPARE(tzp.abbreviation(dst), QString("CEST"));