summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/global/qflags/tst_qflags.cpp2
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp15
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+android/test2 (renamed from tests/auto/corelib/io/qfileselector/platforms/+generic_unix/test)0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+blackberry/test20
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+ios/test20
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+linux/test20
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+mac/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+mac/test20
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+unix/+android/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+unix/+blackberry/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+unix/+ios/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+unix/+linux/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+unix/+mac/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+unix/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+wince/test20
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+windows/+wince/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+windows/test20
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/test20
-rw-r--r--tests/auto/corelib/io/qfileselector/qfileselector.qrc22
-rw-r--r--tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp30
-rw-r--r--tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp1
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp10
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp8
-rw-r--r--tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp38
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp97
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp113
-rw-r--r--tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp1
-rw-r--r--tests/auto/corelib/plugin/quuid/tst_quuid.cpp12
-rw-r--r--tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp12
-rw-r--r--tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp2
-rw-r--r--tests/auto/corelib/tools/qcollator/qcollator.pro7
-rw-r--r--tests/auto/corelib/tools/qcollator/tst_qcollator.cpp92
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp11
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp49
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp8
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp9
-rw-r--r--tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp94
-rw-r--r--tests/auto/corelib/tools/tools.pro1
38 files changed, 569 insertions, 65 deletions
diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp
index e50a6b63fe..73a69a1309 100644
--- a/tests/auto/corelib/global/qflags/tst_qflags.cpp
+++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp
@@ -99,7 +99,7 @@ void tst_QFlags::testFlagMultiBits() const
}
}
-template <int N, typename T> bool verifyConstExpr(T n) { return n == N; }
+template <unsigned int N, typename T> bool verifyConstExpr(T n) { return n == N; }
void tst_QFlags::constExpr()
{
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index 4a50a45ea6..0d08e912f8 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -59,6 +59,7 @@ private slots:
void qCoreAppStartupFunctionRestart();
void isEnum();
void qAlignOf();
+ void integerForSize();
};
void tst_QGlobal::qIsNull()
@@ -566,5 +567,19 @@ void tst_QGlobal::qAlignOf()
#undef TEST_AlignOf_RValueRef
#undef TEST_AlignOf_impl
+void tst_QGlobal::integerForSize()
+{
+ // compile-only test:
+ Q_STATIC_ASSERT(sizeof(QIntegerForSize<1>::Signed) == 1);
+ Q_STATIC_ASSERT(sizeof(QIntegerForSize<2>::Signed) == 2);
+ Q_STATIC_ASSERT(sizeof(QIntegerForSize<4>::Signed) == 4);
+ Q_STATIC_ASSERT(sizeof(QIntegerForSize<8>::Signed) == 8);
+
+ Q_STATIC_ASSERT(sizeof(QIntegerForSize<1>::Unsigned) == 1);
+ Q_STATIC_ASSERT(sizeof(QIntegerForSize<2>::Unsigned) == 2);
+ Q_STATIC_ASSERT(sizeof(QIntegerForSize<4>::Unsigned) == 4);
+ Q_STATIC_ASSERT(sizeof(QIntegerForSize<8>::Unsigned) == 8);
+}
+
QTEST_APPLESS_MAIN(tst_QGlobal)
#include "tst_qglobal.moc"
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+generic_unix/test b/tests/auto/corelib/io/qfileselector/platforms/+android/test2
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/corelib/io/qfileselector/platforms/+generic_unix/test
+++ b/tests/auto/corelib/io/qfileselector/platforms/+android/test2
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+blackberry/test2 b/tests/auto/corelib/io/qfileselector/platforms/+blackberry/test2
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+blackberry/test2
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+ios/test2 b/tests/auto/corelib/io/qfileselector/platforms/+ios/test2
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+ios/test2
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+linux/test2 b/tests/auto/corelib/io/qfileselector/platforms/+linux/test2
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+linux/test2
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+mac/test b/tests/auto/corelib/io/qfileselector/platforms/+mac/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+mac/test
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+mac/test2 b/tests/auto/corelib/io/qfileselector/platforms/+mac/test2
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+mac/test2
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+android/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+android/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/+android/test
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+blackberry/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+blackberry/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/+blackberry/test
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+ios/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+ios/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/+ios/test
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+linux/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+linux/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/+linux/test
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+mac/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+mac/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/+mac/test
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/test
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+wince/test2 b/tests/auto/corelib/io/qfileselector/platforms/+wince/test2
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+wince/test2
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+windows/+wince/test b/tests/auto/corelib/io/qfileselector/platforms/+windows/+wince/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+windows/+wince/test
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+windows/test2 b/tests/auto/corelib/io/qfileselector/platforms/+windows/test2
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+windows/test2
diff --git a/tests/auto/corelib/io/qfileselector/platforms/test2 b/tests/auto/corelib/io/qfileselector/platforms/test2
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/test2
diff --git a/tests/auto/corelib/io/qfileselector/qfileselector.qrc b/tests/auto/corelib/io/qfileselector/qfileselector.qrc
index c644e41107..abfead2a55 100644
--- a/tests/auto/corelib/io/qfileselector/qfileselector.qrc
+++ b/tests/auto/corelib/io/qfileselector/qfileselector.qrc
@@ -11,13 +11,27 @@
<file>extras/+custom3/+custom5/test</file>
<file>extras/+custom5/+custom3/test</file>
<file>platforms/test</file>
+ <file>platforms/+unix/+android/test</file>
+ <file>platforms/+unix/+blackberry/test</file>
+ <file>platforms/+unix/+ios/test</file>
+ <file>platforms/+unix/+mac/test</file>
+ <file>platforms/+windows/+wince/test</file>
+ <file>platforms/+windows/test</file>
+ <file>platforms/+windows/test2</file>
+ <file>platforms/+unix/+linux/test</file>
+ <file>platforms/+unix/test</file>
+ <file>platforms/test2</file>
+ <file>platforms/+android/test2</file>
+ <file>platforms/+blackberry/test2</file>
+ <file>platforms/+ios/test2</file>
+ <file>platforms/+mac/test2</file>
+ <file>platforms/+linux/test2</file>
+ <file>platforms/+wince/test2</file>
<file>platforms/+android/test</file>
<file>platforms/+blackberry/test</file>
<file>platforms/+ios/test</file>
- <file>platforms/+osx/test</file>
- <file>platforms/+wince/test</file>
- <file>platforms/+windows/test</file>
+ <file>platforms/+mac/test</file>
<file>platforms/+linux/test</file>
- <file>platforms/+generic_unix/test</file>
+ <file>platforms/+wince/test</file>
</qresource>
</RCC>
diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
index 2baebd0296..d6461c3aba 100644
--- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
+++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
@@ -91,9 +91,33 @@ void tst_QFileSelector::basicTest_data()
QTest::addColumn<QString>("expectedPath");
QString test("/test");// '/' is here so dir string can also be selector string
- QTest::newRow("platform") << QString(":/platforms/test") << QStringList()
- << QString(":/platforms/") + QLatin1Char(selectorIndicator)
- + QFileSelectorPrivate::platformSelectors().first() + test;
+ QString test2("/test2");
+ QString expectedPlatform1File(":/platforms");
+ QString expectedPlatform2File(""); //Only the last selector
+#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) && !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_IOS) && !defined(Q_OS_LINUX) && !defined(Q_OS_MAC)
+ /* We are only aware of specific unixes, and do not have test files for any of the others.
+ However those unixes can get a selector added from the result of a uname call, so this will
+ lead to a case where we don't have that file so we can't expect the concatenation of platform
+ selectors to work. It should just find the +unix/test file.*/
+ expectedPlatform1File = QString(":/platforms/") + QLatin1Char(selectorIndicator)
+ + QString("unix/test");
+ expectedPlatform2File = QString(":/platforms/test2");
+#else
+ foreach (const QString &selector, QFileSelectorPrivate::platformSelectors()) {
+ expectedPlatform1File = expectedPlatform1File + QLatin1Char('/') + QLatin1Char(selectorIndicator)
+ + selector;
+ expectedPlatform2File = selector;
+ }
+ expectedPlatform1File += test;
+ expectedPlatform2File = QLatin1String(":/platforms/") + QLatin1Char(selectorIndicator)
+ + expectedPlatform2File + test2;
+#endif
+
+ QTest::newRow("platform1") << QString(":/platforms/test") << QStringList()
+ << expectedPlatform1File;
+
+ QTest::newRow("platform2") << QString(":/platforms/test2") << QStringList()
+ << expectedPlatform2File;
QString resourceTestPath(":/extras/test");
QString custom1("custom1");
diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
index a49793c3d4..50268f20a4 100644
--- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
+++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
@@ -69,7 +69,6 @@ QByteArray qMyMessageFormatString(QtMsgType type, const QMessageLogContext &cont
case QtWarningMsg: message.append(".warning"); break;
case QtCriticalMsg:message.append(".critical"); break;
case QtFatalMsg: message.append(".fatal"); break;
- case QtTraceMsg: message.append(".trace"); break;
}
message.append(": ");
message.append(qPrintable(str));
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index c3a1ad206d..d19f4379c7 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -56,7 +56,7 @@
#define Q_XDG_PLATFORM
#endif
-const int MaxStandardLocation = QStandardPaths::GenericCacheLocation;
+static const int MaxStandardLocation = QStandardPaths::GenericConfigLocation;
class tst_qstandardpaths : public QObject
{
@@ -127,7 +127,8 @@ static const char * const enumNames[MaxStandardLocation + 1 - int(QStandardPaths
"RuntimeLocation",
"ConfigLocation",
"DownloadLocation",
- "GenericCacheLocation"
+ "GenericCacheLocation",
+ "GenericConfigLocation"
};
void tst_qstandardpaths::dump()
@@ -151,9 +152,11 @@ void tst_qstandardpaths::testDefaultLocations()
const QString expectedConfHome = QDir::homePath() + QString::fromLatin1("/.config");
QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation), expectedConfHome);
+ QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation), expectedConfHome);
const QStringList confDirs = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation);
QCOMPARE(confDirs.count(), 2);
QVERIFY(confDirs.contains(expectedConfHome));
+ QCOMPARE(QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation), confDirs);
const QStringList genericDataDirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
QCOMPARE(genericDataDirs.count(), 3);
@@ -178,6 +181,7 @@ void tst_qstandardpaths::testCustomLocations()
// test writableLocation()
QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation), m_localConfigDir);
+ QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation), m_localConfigDir);
// test locate()
const QString thisFileName = QString::fromLatin1("aFile");
@@ -212,6 +216,7 @@ void tst_qstandardpaths::enableTestMode()
// ConfigLocation
const QString configDir = qttestDir + QLatin1String("/config");
QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation), configDir);
+ QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation), configDir);
const QStringList confDirs = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation);
QCOMPARE(confDirs, QStringList() << configDir << m_globalConfigDir);
@@ -235,6 +240,7 @@ void tst_qstandardpaths::enableTestMode()
testLocations.insert(QStandardPaths::DataLocation, QStandardPaths::writableLocation(QStandardPaths::DataLocation));
testLocations.insert(QStandardPaths::GenericDataLocation, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
testLocations.insert(QStandardPaths::ConfigLocation, QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
+ testLocations.insert(QStandardPaths::GenericConfigLocation, QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
testLocations.insert(QStandardPaths::CacheLocation, QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
testLocations.insert(QStandardPaths::GenericCacheLocation, QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
// On Windows, what should "Program Files" become, in test mode?
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 2128d68485..12b9159bf2 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -378,6 +378,14 @@ void tst_QUrl::comparison()
QVERIFY(!passUrl1.matches(passUrl2, QUrl::None));
QVERIFY(passUrl1.matches(passUrl2, QUrl::RemovePassword));
+ // RemovePassword, null vs empty
+ QUrl emptyPassUrl1("http://user:@host/");
+ QUrl emptyPassUrl2("http://user@host/");
+ QVERIFY(!(emptyPassUrl1 == emptyPassUrl2));
+ QVERIFY(emptyPassUrl1 != emptyPassUrl2);
+ QVERIFY(!emptyPassUrl1.matches(emptyPassUrl2, QUrl::None));
+ QVERIFY(emptyPassUrl1.matches(emptyPassUrl2, QUrl::RemovePassword));
+
// RemoveQuery, RemoveFragment
QUrl queryFragUrl1("http://host/file?query#fragment");
QUrl queryFragUrl2("http://host/file?q2#f2");
diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
index 870e65f0cc..3afc2bc574 100644
--- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
@@ -155,6 +155,7 @@ private slots:
void invokeCustomTypes();
void invokeMetaConstructor();
void invokeTypedefTypes();
+ void invokeException();
void qtMetaObjectInheritance();
void normalizedSignature_data();
void normalizedSignature();
@@ -301,6 +302,19 @@ void tst_QMetaObject::connectSlotsByName()
struct MyUnregisteredType { };
+static int countedStructObjectsCount = 0;
+struct CountedStruct
+{
+ CountedStruct() { ++countedStructObjectsCount; }
+ CountedStruct(const CountedStruct &) { ++countedStructObjectsCount; }
+ CountedStruct &operator=(const CountedStruct &) { return *this; }
+ ~CountedStruct() { --countedStructObjectsCount; }
+};
+
+#ifndef QT_NO_EXCEPTIONS
+class ObjectException : public std::exception { };
+#endif
+
class QtTestObject: public QObject
{
friend class tst_QMetaObject;
@@ -340,6 +354,13 @@ public slots:
void slotWithUnregisteredParameterType(MyUnregisteredType);
+ CountedStruct throwingSlot(const CountedStruct &, CountedStruct s2) {
+#ifndef QT_NO_EXCEPTIONS
+ throw ObjectException();
+#endif
+ return s2;
+ }
+
signals:
void sig0();
QString sig1(QString s1);
@@ -847,6 +868,23 @@ void tst_QMetaObject::invokeTypedefTypes()
QCOMPARE(spy.at(0).at(0), QVariant(arg));
}
+void tst_QMetaObject::invokeException()
+{
+#ifndef QT_NO_EXCEPTIONS
+ QtTestObject obj;
+ QCOMPARE(countedStructObjectsCount, 0);
+ try {
+ CountedStruct s;
+ QVERIFY(QMetaObject::invokeMethod(&obj, "throwingSlot", Q_RETURN_ARG(CountedStruct, s),
+ Q_ARG(CountedStruct, s), Q_ARG(CountedStruct, s)));
+ QFAIL("Did not throw");
+ } catch(ObjectException &) {}
+ QCOMPARE(countedStructObjectsCount, 0);
+#else
+ QSKIP("Needs exceptions");
+#endif
+}
+
void tst_QMetaObject::normalizedSignature_data()
{
QTest::addColumn<QString>("signature");
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index f429500077..e4804e6079 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -152,6 +152,7 @@ private slots:
void contextDoesNotLeakFunctor();
void connectBase();
void qmlConnect();
+ void exceptions();
};
struct QObjectCreatedOnShutdown
@@ -6185,6 +6186,102 @@ void tst_QObject::qmlConnect()
#endif
}
+#ifndef QT_NO_EXCEPTIONS
+class ObjectException : public std::exception { };
+
+struct ThrowFunctor
+{
+ CountedStruct operator()(const CountedStruct &, CountedStruct s2) const
+ {
+ throw ObjectException();
+ return s2;
+ }
+ CountedStruct s;
+};
+#endif
+
+class ExceptionThrower : public QObject
+{
+ Q_OBJECT
+public slots:
+ CountedStruct throwException(const CountedStruct &, CountedStruct s2)
+ {
+#ifndef QT_NO_EXCEPTIONS
+ throw ObjectException();
+#endif
+ return s2;
+ }
+signals:
+ CountedStruct mySignal(const CountedStruct &s1, CountedStruct s2);
+};
+
+void tst_QObject::exceptions()
+{
+#ifndef QT_NO_EXCEPTIONS
+ ReceiverObject receiver;
+
+ // String based syntax
+ {
+ QCOMPARE(countedStructObjectsCount, 0);
+ ExceptionThrower thrower;
+ receiver.reset();
+
+ connect(&thrower, SIGNAL(mySignal(CountedStruct,CountedStruct)), &receiver, SLOT(slot1()));
+ connect(&thrower, SIGNAL(mySignal(CountedStruct,CountedStruct)), &thrower, SLOT(throwException(CountedStruct,CountedStruct)));
+ connect(&thrower, SIGNAL(mySignal(CountedStruct,CountedStruct)), &receiver, SLOT(slot2()));
+ try {
+ CountedStruct s;
+ emit thrower.mySignal(s, s);
+ QFAIL("Exception not thrown?");
+ } catch (ObjectException&) {}
+ QCOMPARE(receiver.count_slot1, 1);
+ QCOMPARE(receiver.count_slot2, 0);
+ QCOMPARE(countedStructObjectsCount, 0);
+ }
+ // Pointer to member function
+ {
+ QCOMPARE(countedStructObjectsCount, 0);
+ ExceptionThrower thrower;
+ receiver.reset();
+
+ connect(&thrower, &ExceptionThrower::mySignal, &receiver, &ReceiverObject::slot1);
+ connect(&thrower, &ExceptionThrower::mySignal, &thrower, &ExceptionThrower::throwException);
+ connect(&thrower, &ExceptionThrower::mySignal, &receiver, &ReceiverObject::slot2);
+ try {
+ CountedStruct s;
+ emit thrower.mySignal(s, s);
+ QFAIL("Exception not thrown?");
+ } catch (ObjectException&) {}
+ QCOMPARE(receiver.count_slot1, 1);
+ QCOMPARE(receiver.count_slot2, 0);
+ QCOMPARE(countedStructObjectsCount, 0);
+ }
+ // Functor
+ {
+ QCOMPARE(countedStructObjectsCount, 0);
+ ExceptionThrower thrower;
+ receiver.reset();
+
+ connect(&thrower, &ExceptionThrower::mySignal, &receiver, &ReceiverObject::slot1);
+ connect(&thrower, &ExceptionThrower::mySignal, ThrowFunctor());
+ connect(&thrower, &ExceptionThrower::mySignal, &receiver, &ReceiverObject::slot2);
+ try {
+ CountedStruct s;
+ emit thrower.mySignal(s, s);
+ QFAIL("Exception not thrown?");
+ } catch (ObjectException&) {}
+ QCOMPARE(receiver.count_slot1, 1);
+ QCOMPARE(receiver.count_slot2, 0);
+ QCOMPARE(countedStructObjectsCount, 1); // the Functor
+ }
+ QCOMPARE(countedStructObjectsCount, 0);
+
+
+#else
+ QSKIP("Needs exceptions");
+#endif
+}
+
// Test for QtPrivate::HasQ_OBJECT_Macro
Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 422bd63163..aef79e0c2f 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -247,6 +247,8 @@ private slots:
void iterateContainerElements();
void pairElements();
+
+ void enums();
private:
void dataStream_data(QDataStream::Version version);
void loadQVariantFromDataStream(QDataStream::Version version);
@@ -888,6 +890,17 @@ void tst_QVariant::toLongLong_data()
bytearray[3] = '0';
QTest::newRow( "QByteArray" ) << QVariant( bytearray ) << (qlonglong) 3200 << true;
QTest::newRow("QJsonValue") << QVariant(QJsonValue(321)) << (qlonglong)321 << true;
+
+ qint64 value64 = (Q_INT64_C(12) << 35) + 8;
+ QTest::newRow("qint64") << QVariant::fromValue(value64) << qlonglong(value64) << true;
+ QTest::newRow("-qint64") << QVariant::fromValue(-value64) << qlonglong(-value64) << true;
+ QTest::newRow("long") << QVariant::fromValue(long(464646)) << qlonglong(464646) << true;
+ QTest::newRow("LONG_MAX") << QVariant::fromValue( LONG_MAX ) << qlonglong(LONG_MAX) << true;
+ QTest::newRow("LONG_MIN") << QVariant::fromValue( LONG_MIN ) << qlonglong(LONG_MIN) << true;
+
+ QTest::newRow( "short" ) << QVariant(short(12)) << qlonglong(12) << true;
+ QTest::newRow( "-short" ) << QVariant(short(-24)) << qlonglong(-24) << true;
+ QTest::newRow( "ushort" ) << QVariant(ushort(15)) << qlonglong(15) << true;
}
void tst_QVariant::toLongLong()
@@ -933,6 +946,15 @@ void tst_QVariant::toULongLong_data()
bytearray[3] = '1';
QTest::newRow( "QByteArray" ) << QVariant( bytearray ) << (qulonglong) 3201 << true;
QTest::newRow("QJsonValue") << QVariant(QJsonValue(321)) << (qulonglong)321 << true;
+
+ quint64 value64 = (Q_INT64_C(12) << 35) + 8;
+ QTest::newRow("qint64") << QVariant::fromValue(value64) << qulonglong(value64) << true;
+ QTest::newRow("long") << QVariant::fromValue(long(464646)) << qulonglong(464646) << true;
+ QTest::newRow("LONG_MAX") << QVariant::fromValue( LONG_MAX ) << qulonglong(LONG_MAX) << true;
+ QTest::newRow("ULONG_MAX") << QVariant::fromValue( ULONG_MAX ) << qulonglong(ULONG_MAX) << true;
+ QTest::newRow( "short" ) << QVariant(short(12)) << qulonglong(12) << true;
+ QTest::newRow( "-short" ) << QVariant(short(-24)) << qulonglong(-24) << true;
+ QTest::newRow( "ushort" ) << QVariant(ushort(15)) << qulonglong(15) << true;
}
void tst_QVariant::toULongLong()
@@ -2895,24 +2917,27 @@ void tst_QVariant::numericalConvert()
QVariant vuint(uint(5));
QVariant vshort(short(5));
QVariant vlonglong(quint64(5));
+ QVariant vlong = QVariant::fromValue(long(5));
QVariant vstringint(QString::fromLatin1("5"));
QVariant vstring(QString::fromLatin1("5.3"));
QVector<QVariant *> vect;
- vect << &vfloat << &vdouble << &vreal << &vint << &vuint << &vshort<< &vlonglong << &vstringint << &vstring;
+ vect << &vfloat << &vdouble << &vreal << &vint << &vuint << &vshort<< &vlonglong << &vlong << &vstringint << &vstring;
for(int i = 0; i < vect.size(); i++) {
double num = 5.3;
- if (i >= 3 && i <= 7)
+ if (i >= 3 && i <= 8)
num = 5;
QVariant *v = vect.at(i);
QCOMPARE(v->toFloat() , float(num));
QCOMPARE(float(v->toReal()) , float(num));
QCOMPARE(float(v->toDouble()) , float(num));
- if(i != 8) {
+ if (i != 9) {
QCOMPARE(v->toInt() , int(num));
QCOMPARE(v->toUInt() , uint(num));
QCOMPARE(v->toULongLong() , quint64(num));
+ QCOMPARE(v->value<ulong>() , ulong(num));
+ QCOMPARE(v->value<ushort>() , ushort(num));
}
QCOMPARE(v->toString() , QString::number(num));
}
@@ -3930,5 +3955,87 @@ void tst_QVariant::pairElements()
TEST_PAIR_ELEMENT_ACCESS(std::pair, int, QVariant, 44, 15)
}
+enum EnumTest_Enum0 { EnumTest_Enum0_value = 42, ensureSignedEnum0 = -1 };
+Q_DECLARE_METATYPE(EnumTest_Enum0)
+enum EnumTest_Enum1 { EnumTest_Enum1_value = 42, EnumTest_Enum1_bigValue = (Q_INT64_C(1) << 33) + 50 };
+Q_DECLARE_METATYPE(EnumTest_Enum1)
+
+#if defined(Q_COMPILER_CLASS_ENUM)
+enum EnumTest_Enum3 : qint64 { EnumTest_Enum3_value = -47, EnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5 };
+Q_DECLARE_METATYPE(EnumTest_Enum3)
+enum EnumTest_Enum4 : quint64 { EnumTest_Enum4_value = 47, EnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 };
+Q_DECLARE_METATYPE(EnumTest_Enum4)
+enum EnumTest_Enum5 : uint { EnumTest_Enum5_value = 47 };
+Q_DECLARE_METATYPE(EnumTest_Enum5)
+enum EnumTest_Enum6 : uchar { EnumTest_Enum6_value = 47 };
+Q_DECLARE_METATYPE(EnumTest_Enum6)
+enum class EnumTest_Enum7 { EnumTest_Enum7_value = 47, ensureSignedEnum7 = -1 };
+Q_DECLARE_METATYPE(EnumTest_Enum7)
+enum EnumTest_Enum8 : short { EnumTest_Enum8_value = 47 };
+Q_DECLARE_METATYPE(EnumTest_Enum8)
+#endif
+
+template<typename Enum> void testVariant(Enum value, bool *ok)
+{
+ *ok = false;
+ QVariant var = QVariant::fromValue(value);
+
+ QCOMPARE(var.userType(), qMetaTypeId<Enum>());
+
+ QVERIFY(var.canConvert<Enum>());
+ QVERIFY(var.canConvert<int>());
+ QVERIFY(var.canConvert<unsigned int>());
+ QVERIFY(var.canConvert<short>());
+ QVERIFY(var.canConvert<unsigned short>());
+ QVERIFY(var.canConvert<qint64>());
+ QVERIFY(var.canConvert<quint64>());
+
+
+ QCOMPARE(var.value<Enum>(), value);
+ QCOMPARE(var.value<int>(), static_cast<int>(value));
+ QCOMPARE(var.value<uint>(), static_cast<uint>(value));
+ QCOMPARE(var.value<short>(), static_cast<short>(value));
+ QCOMPARE(var.value<unsigned short>(), static_cast<unsigned short>(value));
+ QCOMPARE(var.value<qint64>(), static_cast<qint64>(value));
+ QCOMPARE(var.value<quint64>(), static_cast<quint64>(value));
+
+ QVariant var2 = var;
+ QVERIFY(var2.convert(QMetaType::Int));
+ QCOMPARE(var2.value<int>(), static_cast<int>(value));
+
+ *ok = true;
+}
+
+void tst_QVariant::enums()
+{
+ bool ok = false;
+ testVariant(EnumTest_Enum0_value, &ok);
+ QVERIFY(ok);
+ testVariant(EnumTest_Enum1_value, &ok);
+ QVERIFY(ok);
+ testVariant(EnumTest_Enum1_bigValue, &ok);
+ QVERIFY(ok);
+#if defined(Q_COMPILER_CLASS_ENUM)
+ testVariant(EnumTest_Enum3::EnumTest_Enum3_value, &ok);
+ QVERIFY(ok);
+ testVariant(EnumTest_Enum3::EnumTest_Enum3_bigValue, &ok);
+ QVERIFY(ok);
+ testVariant(EnumTest_Enum4::EnumTest_Enum4_value, &ok);
+ QVERIFY(ok);
+ testVariant(EnumTest_Enum4::EnumTest_Enum4_bigValue, &ok);
+ QVERIFY(ok);
+ testVariant(EnumTest_Enum5::EnumTest_Enum5_value, &ok);
+ QVERIFY(ok);
+ testVariant(EnumTest_Enum6::EnumTest_Enum6_value, &ok);
+ QVERIFY(ok);
+ testVariant(EnumTest_Enum7::EnumTest_Enum7_value, &ok);
+ QVERIFY(ok);
+ testVariant(EnumTest_Enum8::EnumTest_Enum8_value, &ok);
+ QVERIFY(ok);
+ testVariant(EnumTest_Enum3::EnumTest_Enum3_value, &ok);
+ QVERIFY(ok);
+#endif
+}
+
QTEST_MAIN(tst_QVariant)
#include "tst_qvariant.moc"
diff --git a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp
index 8a0ff162c6..952cb031b8 100644
--- a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp
+++ b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp
@@ -42,6 +42,7 @@
#include <QtTest/QtTest>
#include <qwineventnotifier.h>
#include <qtimer.h>
+#include <qt_windows.h>
class tst_QWinEventNotifier : public QObject
{
diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
index 197d56359f..227351485d 100644
--- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
+++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
@@ -64,6 +64,7 @@ private slots:
void isNull();
void equal();
void notEqual();
+ void cpp11();
// Only in Qt > 3.2.x
void generate();
@@ -245,6 +246,17 @@ void tst_QUuid::notEqual()
QVERIFY( uuidA != uuidB );
}
+void tst_QUuid::cpp11() {
+#ifdef Q_COMPILER_UNIFORM_INIT
+ // "{fc69b59e-cc34-4436-a43c-ee95d128b8c5}" cf, initTestCase
+ Q_DECL_CONSTEXPR QUuid u1{0xfc69b59e, 0xcc34, 0x4436, 0xa4, 0x3c, 0xee, 0x95, 0xd1, 0x28, 0xb8, 0xc5};
+ Q_DECL_CONSTEXPR QUuid u2 = {0xfc69b59e, 0xcc34, 0x4436, 0xa4, 0x3c, 0xee, 0x95, 0xd1, 0x28, 0xb8, 0xc5};
+ Q_UNUSED(u1);
+ Q_UNUSED(u2);
+#else
+ QSKIP("This compiler is not in C++11 mode or it doesn't support uniform initialization");
+#endif
+}
void tst_QUuid::generate()
{
diff --git a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
index 0d51f69559..ac8d433f96 100644
--- a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
+++ b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
@@ -49,11 +49,13 @@
#ifdef Q_OS_UNIX
#include <unistd.h>
#endif
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
-#include <windows.h>
-#define sleep(X) Sleep(X)
-#elif defined(Q_OS_WINRT)
-#define sleep(X) WaitForSingleObjectEx(GetCurrentThread(), X, FALSE);
+#if defined(Q_OS_WIN)
+# include <qt_windows.h>
+# ifndef Q_OS_WINRT
+# define sleep(X) Sleep(X)
+# else
+# define sleep(X) WaitForSingleObjectEx(GetCurrentThread(), X, FALSE);
+# endif
#endif
//on solaris, threads that loop on the release bool variable
diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
index 144bc62b1b..64eb91b7b6 100644
--- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
+++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
@@ -1027,7 +1027,7 @@ void tst_QAlgorithms::binaryFindOnLargeContainer() const
}
// alternative implementation of qPopulationCount for comparison:
-static const uint bitsSetInNibble[] = {
+static Q_DECL_CONSTEXPR const uint bitsSetInNibble[] = {
0, 1, 1, 2, 1, 2, 2, 3,
1, 2, 2, 3, 2, 3, 3, 4,
};
diff --git a/tests/auto/corelib/tools/qcollator/qcollator.pro b/tests/auto/corelib/tools/qcollator/qcollator.pro
new file mode 100644
index 0000000000..3c5987ffa0
--- /dev/null
+++ b/tests/auto/corelib/tools/qcollator/qcollator.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase parallel_test
+TARGET = tst_qcollator
+QT = core testlib
+SOURCES = tst_qcollator.cpp
+DEFINES += QT_NO_CAST_TO_ASCII
+contains(QT_CONFIG,icu):DEFINES += QT_USE_ICU
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
new file mode 100644
index 0000000000..3df8422a34
--- /dev/null
+++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <qlocale.h>
+#include <qcollator.h>
+
+#include <cstring>
+
+class tst_QCollator : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void moveSemantics();
+};
+
+#ifdef Q_COMPILER_RVALUE_REFS
+static bool dpointer_is_null(QCollator &c)
+{
+ char mem[sizeof c];
+ using namespace std;
+ memcpy(mem, &c, sizeof c);
+ for (size_t i = 0; i < sizeof c; ++i)
+ if (mem[i])
+ return false;
+ return true;
+}
+#endif
+
+void tst_QCollator::moveSemantics()
+{
+#ifdef Q_COMPILER_RVALUE_REFS
+ const QLocale de_AT(QLocale::German, QLocale::Austria);
+
+ QCollator c1(de_AT);
+ QCOMPARE(c1.locale(), de_AT);
+
+ QCollator c2(std::move(c1));
+ QCOMPARE(c2.locale(), de_AT);
+ QVERIFY(dpointer_is_null(c1));
+
+ c1 = std::move(c2);
+ QCOMPARE(c1.locale(), de_AT);
+ QVERIFY(dpointer_is_null(c2));
+#else
+ QSKIP("The compiler is not in C++11 mode or does not support move semantics.");
+#endif
+}
+
+QTEST_APPLESS_MAIN(tst_QCollator)
+
+#include "tst_qcollator.moc"
diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp
index 07f8ddfc8e..2b30b0486b 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp
@@ -69,9 +69,18 @@ int main(int argc, char *argv[])
// An option with a longer description, to test wrapping
QCommandLineOption noImplicitIncludesOption(QStringList() << QStringLiteral("n") << QStringLiteral("no-implicit-includes"));
- noImplicitIncludesOption.setDescription(QStringLiteral("Disable automatic generation of implicit #include-directives."));
+ noImplicitIncludesOption.setDescription(QStringLiteral("Disable magic generation of implicit #include-directives."));
parser.addOption(noImplicitIncludesOption);
+ QCommandLineOption newlineOption(QStringList() << QStringLiteral("newline"));
+ newlineOption.setDescription(QString::fromLatin1("This is an option with a rather long\n"
+ "description using explicit newline characters "
+ "(but testing automatic wrapping too). In addition, "
+ "here, we test breaking after a comma. Testing -option. "
+ "Long URL: http://qt-project.org/wiki/How_to_create_a_library_with_Qt_and_use_it_in_an_application "
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ parser.addOption(newlineOption);
+
// This program supports different options depending on the "command" (first argument).
// Call parse() to find out the positional arguments.
parser.parse(QCoreApplication::arguments());
diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
index 1ee6cacd97..d5b3323506 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
@@ -459,27 +459,40 @@ void tst_QCommandLineParser::testVersionOption()
#endif // !QT_NO_PROCESS
}
+static const char expectedOptionsHelp[] =
+ "Options:\n"
+ " -h, --help Displays this help.\n"
+ " -v, --version Displays version information.\n"
+ " --load <url> Load file from URL.\n"
+ " -o, --output <file> Set output file.\n"
+ " -D <key=value> Define macro.\n"
+ " -n, --no-implicit-includes Disable magic generation of implicit\n"
+ " #include-directives.\n"
+ " --newline This is an option with a rather long\n"
+ " description using explicit newline characters (but\n"
+ " testing automatic wrapping too). In addition,\n"
+ " here, we test breaking after a comma. Testing\n"
+ " -option. Long URL:\n"
+ " http://qt-project.org/wiki/How_to_create_a_library\n"
+ " _with_Qt_and_use_it_in_an_application\n"
+ " abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx\n"
+ " yzabcdefghijklmnopqrstuvwxyz\n";
+
void tst_QCommandLineParser::testHelpOption_data()
{
QTest::addColumn<QCommandLineParser::SingleDashWordOptionMode>("parsingMode");
QTest::addColumn<QString>("expectedHelpOutput");
- QString expectedOutput =
+ QString expectedOutput = QString::fromLatin1(
"Usage: testhelper/qcommandlineparser_test_helper [options] parsingMode command\n"
"Test helper\n"
- "\n"
- "Options:\n"
- " -h, --help Displays this help.\n"
- " -v, --version Displays version information.\n"
- " --load <url> Load file from URL.\n"
- " -o, --output <file> Set output file.\n"
- " -D <key=value> Define macro.\n"
- " -n, --no-implicit-includes Disable automatic generation of implicit #include\n"
- " -directives.\n"
+ "\n")
+ + QString::fromLatin1(expectedOptionsHelp) +
+ QString::fromLatin1(
"\n"
"Arguments:\n"
" parsingMode The parsing mode to test.\n"
- " command The command to execute.\n";
+ " command The command to execute.\n");
#ifdef Q_OS_WIN
expectedOutput.replace(" -h, --help Displays this help.\n",
" -?, -h, --help Displays this help.\n");
@@ -510,6 +523,7 @@ void tst_QCommandLineParser::testHelpOption()
#ifdef Q_OS_WIN
output.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
#endif
+ QCOMPARE(output.split('\n'), expectedHelpOutput.split('\n')); // easier to debug than the next line, on failure
QCOMPARE(output, expectedHelpOutput);
process.start("testhelper/qcommandlineparser_test_helper", QStringList() << "0" << "resize" << "--help");
@@ -519,18 +533,11 @@ void tst_QCommandLineParser::testHelpOption()
#ifdef Q_OS_WIN
output.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
#endif
- QByteArray expectedResizeHelp =
+ QByteArray expectedResizeHelp = QByteArrayLiteral(
"Usage: testhelper/qcommandlineparser_test_helper [options] resize [resize_options]\n"
"Test helper\n"
- "\n"
- "Options:\n"
- " -h, --help Displays this help.\n"
- " -v, --version Displays version information.\n"
- " --load <url> Load file from URL.\n"
- " -o, --output <file> Set output file.\n"
- " -D <key=value> Define macro.\n"
- " -n, --no-implicit-includes Disable automatic generation of implicit #include\n"
- " -directives.\n"
+ "\n")
+ + expectedOptionsHelp +
" --size <size> New size.\n"
"\n"
"Arguments:\n"
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index 8c0f32bb74..7d51696fe3 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -48,7 +48,7 @@
#include <private/qdatetime_p.h>
#ifdef Q_OS_WIN
-# include <windows.h>
+# include <qt_windows.h>
# if defined(Q_OS_WINRT)
# define tzset()
# endif
@@ -2906,6 +2906,12 @@ void tst_QDateTime::timeZones() const
// - Test 03:00:00 = 1 hour after tran
hourAfterStd = QDateTime(QDate(2013, 10, 27), QTime(3, 0, 0), cet);
QCOMPARE(hourAfterStd.toMSecsSinceEpoch(), dstToStdMSecs + 3600000);
+
+ // Test Time Zone that has transitions but no future transitions afer a given date
+ QTimeZone sgt("Asia/Singapore");
+ QDateTime future(QDate(2015, 1, 1), QTime(0, 0, 0), sgt);
+ QVERIFY(future.isValid());
+ QCOMPARE(future.offsetFromUtc(), 28800);
}
void tst_QDateTime::invalid() const
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index f11e632b2e..1bac5f39e7 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -1733,6 +1733,11 @@ void tst_QLocale::dayName()
QLocale ir("ga_IE");
QCOMPARE(ir.dayName(1, QLocale::ShortFormat), QLatin1String("Luan"));
QCOMPARE(ir.dayName(7, QLocale::ShortFormat), QLatin1String("Domh"));
+
+ QLocale gr("el_GR");
+ QCOMPARE(gr.dayName(2, QLocale::ShortFormat), QString::fromUtf8("\316\244\317\201\316\257"));
+ QCOMPARE(gr.dayName(4, QLocale::ShortFormat), QString::fromUtf8("\316\240\316\255\316\274"));
+ QCOMPARE(gr.dayName(6, QLocale::ShortFormat), QString::fromUtf8("\316\243\316\254\316\262"));
}
void tst_QLocale::standaloneDayName_data()
@@ -1903,6 +1908,10 @@ void tst_QLocale::timeFormat()
const QLocale cat("ca_ES");
QCOMPARE(cat.timeFormat(QLocale::ShortFormat), QLatin1String("H.mm"));
QCOMPARE(cat.timeFormat(QLocale::LongFormat), QLatin1String("H.mm.ss t"));
+
+ const QLocale bra("pt_BR");
+ QCOMPARE(bra.timeFormat(QLocale::ShortFormat), QLatin1String("HH:mm"));
+ QCOMPARE(bra.timeFormat(QLocale::LongFormat), QLatin1String("HH:mm:ss t"));
}
void tst_QLocale::dateTimeFormat()
diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
index 28245b5e6a..0a63ffeeaf 100644
--- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
@@ -57,6 +57,7 @@ private slots:
void nullTest();
void dataStreamTest();
void availableTimeZoneIds();
+ void stressTest();
void windowsId();
// Backend tests
void utcTest();
@@ -75,7 +76,7 @@ private:
tst_QTimeZone::tst_QTimeZone()
{
- // Set to true to print debug output
+ // Set to true to print debug output, test Display Names and run long stress tests
debug = false;
}
@@ -367,11 +368,59 @@ void tst_QTimeZone::availableTimeZoneIds()
}
}
+void tst_QTimeZone::stressTest()
+{
+ QList<QByteArray> idList = QTimeZone::availableTimeZoneIds();
+ foreach (const QByteArray &id, idList) {
+ QTimeZone testZone = QTimeZone(id);
+ QCOMPARE(testZone.isValid(), true);
+ QCOMPARE(testZone.id(), id);
+ QDateTime testDate = QDateTime(QDate(2015, 1, 1), QTime(0, 0, 0), Qt::UTC);
+ testZone.country();
+ testZone.comment();
+ testZone.displayName(testDate);
+ testZone.displayName(QTimeZone::DaylightTime);
+ testZone.displayName(QTimeZone::StandardTime);
+ testZone.abbreviation(testDate);
+ testZone.offsetFromUtc(testDate);
+ testZone.standardTimeOffset(testDate);
+ testZone.daylightTimeOffset(testDate);
+ testZone.hasDaylightTime();
+ testZone.isDaylightTime(testDate);
+ testZone.offsetData(testDate);
+ testZone.hasTransitions();
+ testZone.nextTransition(testDate);
+ testZone.previousTransition(testDate);
+ // Dates known to be outside possible tz file pre-calculated rules range
+ QDateTime lowDate1 = QDateTime(QDate(1800, 1, 1), QTime(0, 0, 0), Qt::UTC);
+ QDateTime lowDate2 = QDateTime(QDate(1800, 6, 1), QTime(0, 0, 0), Qt::UTC);
+ QDateTime highDate1 = QDateTime(QDate(2200, 1, 1), QTime(0, 0, 0), Qt::UTC);
+ QDateTime highDate2 = QDateTime(QDate(2200, 6, 1), QTime(0, 0, 0), Qt::UTC);
+ testZone.nextTransition(lowDate1);
+ testZone.nextTransition(lowDate2);
+ testZone.previousTransition(lowDate2);
+ testZone.previousTransition(lowDate2);
+ testZone.nextTransition(highDate1);
+ testZone.nextTransition(highDate2);
+ testZone.previousTransition(highDate1);
+ testZone.previousTransition(highDate2);
+ if (debug) {
+ // This could take a long time, depending on platform and database
+ qDebug() << "Stress test calculating transistions for" << testZone.id();
+ testZone.transitions(lowDate1, highDate1);
+ }
+ testDate.setTimeZone(testZone);
+ testDate.isValid();
+ testDate.offsetFromUtc();
+ testDate.timeZoneAbbreviation();
+ }
+}
+
void tst_QTimeZone::windowsId()
{
/*
Current Windows zones for "Central Standard Time":
- Region Olsen Id(s)
+ Region IANA Id(s)
Default "America/Chicago"
Canada "America/Winnipeg America/Rainy_River America/Rankin_Inlet America/Resolute"
Mexico "America/Matamoros"
@@ -380,24 +429,24 @@ void tst_QTimeZone::windowsId()
"America/North_Dakota/New_Salem"
AnyCountry "CST6CDT"
*/
- QCOMPARE(QTimeZone::olsenIdToWindowsId("America/Chicago"),
+ QCOMPARE(QTimeZone::ianaIdToWindowsId("America/Chicago"),
QByteArray("Central Standard Time"));
- QCOMPARE(QTimeZone::olsenIdToWindowsId("America/Resolute"),
+ QCOMPARE(QTimeZone::ianaIdToWindowsId("America/Resolute"),
QByteArray("Central Standard Time"));
// Partials shouldn't match
- QCOMPARE(QTimeZone::olsenIdToWindowsId("America/Chi"), QByteArray());
- QCOMPARE(QTimeZone::olsenIdToWindowsId("InvalidZone"), QByteArray());
- QCOMPARE(QTimeZone::olsenIdToWindowsId(QByteArray()), QByteArray());
+ QCOMPARE(QTimeZone::ianaIdToWindowsId("America/Chi"), QByteArray());
+ QCOMPARE(QTimeZone::ianaIdToWindowsId("InvalidZone"), QByteArray());
+ QCOMPARE(QTimeZone::ianaIdToWindowsId(QByteArray()), QByteArray());
// Check default value
- QCOMPARE(QTimeZone::windowsIdToDefaultOlsenId("Central Standard Time"),
+ QCOMPARE(QTimeZone::windowsIdToDefaultIanaId("Central Standard Time"),
QByteArray("America/Chicago"));
- QCOMPARE(QTimeZone::windowsIdToDefaultOlsenId("Central Standard Time", QLocale::Canada),
+ QCOMPARE(QTimeZone::windowsIdToDefaultIanaId("Central Standard Time", QLocale::Canada),
QByteArray("America/Winnipeg"));
- QCOMPARE(QTimeZone::windowsIdToDefaultOlsenId("Central Standard Time", QLocale::AnyCountry),
+ QCOMPARE(QTimeZone::windowsIdToDefaultIanaId("Central Standard Time", QLocale::AnyCountry),
QByteArray("CST6CDT"));
- QCOMPARE(QTimeZone::windowsIdToDefaultOlsenId(QByteArray()), QByteArray());
+ QCOMPARE(QTimeZone::windowsIdToDefaultIanaId(QByteArray()), QByteArray());
// No country is sorted list of all zones
QList<QByteArray> list;
@@ -406,39 +455,39 @@ void tst_QTimeZone::windowsId()
<< "America/North_Dakota/Center" << "America/North_Dakota/New_Salem"
<< "America/Rainy_River" << "America/Rankin_Inlet" << "America/Resolute"
<< "America/Winnipeg" << "CST6CDT";
- QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time"), list);
+ QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time"), list);
// Check country with no match returns empty list
list.clear();
- QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::NewZealand),
+ QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::NewZealand),
list);
// Check valid country returns list in preference order
list.clear();
list << "America/Winnipeg" << "America/Rainy_River" << "America/Rankin_Inlet"
<< "America/Resolute";
- QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::Canada), list);
+ QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Canada), list);
list.clear();
list << "America/Matamoros";
- QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::Mexico), list);
+ QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Mexico), list);
list.clear();
list << "America/Chicago" << "America/Indiana/Knox" << "America/Indiana/Tell_City"
<< "America/Menominee" << "America/North_Dakota/Beulah" << "America/North_Dakota/Center"
<< "America/North_Dakota/New_Salem";
- QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::UnitedStates),
+ QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::UnitedStates),
list);
list.clear();
list << "CST6CDT";
- QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::AnyCountry),
+ QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::AnyCountry),
list);
// Check no windowsId return empty
list.clear();
- QCOMPARE(QTimeZone::windowsIdToOlsenIds(QByteArray()), list);
- QCOMPARE(QTimeZone::windowsIdToOlsenIds(QByteArray(), QLocale::AnyCountry), list);
+ QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray()), list);
+ QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray(), QLocale::AnyCountry), list);
}
void tst_QTimeZone::utcTest()
@@ -639,10 +688,11 @@ void tst_QTimeZone::tzTest()
QCOMPARE(dat.standardTimeOffset, 3600);
QCOMPARE(dat.daylightTimeOffset, 0);
+ // Test previous to low value is invalid
dat = tzp.previousTransition(-9999999999999);
- QCOMPARE(dat.atMSecsSinceEpoch, (qint64)-2422054408000);
- QCOMPARE(dat.standardTimeOffset, 3600);
- QCOMPARE(dat.daylightTimeOffset, 0);
+ QCOMPARE(dat.atMSecsSinceEpoch, std::numeric_limits<qint64>::min());
+ QCOMPARE(dat.standardTimeOffset, std::numeric_limits<int>::min());
+ QCOMPARE(dat.daylightTimeOffset, std::numeric_limits<int>::min());
dat = tzp.nextTransition(-9999999999999);
QCOMPARE(dat.atMSecsSinceEpoch, (qint64)-2422054408000);
diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro
index e920813db2..286afdfd18 100644
--- a/tests/auto/corelib/tools/tools.pro
+++ b/tests/auto/corelib/tools/tools.pro
@@ -8,6 +8,7 @@ SUBDIRS=\
qbytedatabuffer \
qcache \
qchar \
+ qcollator \
qcommandlineparser \
qcontiguouscache \
qcryptographichash \