summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-04-04 08:59:11 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2016-04-04 08:59:18 +0200
commit216f57ef8682f74b72ae4e39cf1fd23abddf6a51 (patch)
tree9d1dc12e0944ec0252dac843fbadaf1dc4693888 /tests/auto/corelib
parent36bc2477753d19a14c587b97d4ec4f263e9e16c0 (diff)
parent8ce657d0279566ef327af1b88339534041ddc012 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/global/qlogging/tst_qlogging.cpp11
-rw-r--r--tests/auto/corelib/io/qstandardpaths/BLACKLIST2
-rw-r--r--tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp16
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp27
4 files changed, 54 insertions, 2 deletions
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
index f608a36214..ce227a6c8b 100644
--- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
+++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
@@ -774,6 +774,17 @@ void tst_qmessagehandler::qMessagePattern_data()
<< true << (QList<QByteArray>()
<< ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8() + "/qDebug"));
+ QTest::newRow("time-time") << "/%{time yyyy - MM - d}/%{time dd-MM-yy}/%{message}"
+ << true << (QList<QByteArray>()
+ << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8()
+ + '/' + QDateTime::currentDateTime().toString("dd-MM-yy").toUtf8()
+ + "/qDebug"));
+
+ QTest::newRow("skipped-time-shown-time")
+ << "/%{if-warning}%{time yyyy - MM - d}%{endif}%{if-debug}%{time dd-MM-yy}%{endif}/%{message}"
+ << true << (QList<QByteArray>()
+ << ('/' + QDateTime::currentDateTime().toString("dd-MM-yy").toUtf8() + "/qDebug"));
+
// %{time} should have a padding of 6 so if it takes less than 10 seconds to show
// the first message, there should be 5 spaces
QTest::newRow("time-process") << "<%{time process}>%{message}" << true << (QList<QByteArray>()
diff --git a/tests/auto/corelib/io/qstandardpaths/BLACKLIST b/tests/auto/corelib/io/qstandardpaths/BLACKLIST
deleted file mode 100644
index 8496a620b3..0000000000
--- a/tests/auto/corelib/io/qstandardpaths/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[testRuntimeDirectory]
-rhel-7.1
diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
index 838120bb68..914f9e2b9b 100644
--- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
+++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
@@ -54,6 +54,7 @@ private slots:
void qvariantCast();
void constPointer();
+ void constQPointer();
};
void tst_QPointer::constructors()
@@ -397,6 +398,21 @@ void tst_QPointer::constPointer()
delete fp.data();
}
+void tst_QPointer::constQPointer()
+{
+ // Check that const QPointers work. It's a bit weird to mark a pointer
+ // const if its value can change, but the shallow-const principle in C/C++
+ // allows this, and people use it, so document it with a test.
+ //
+ // It's unlikely that this test will fail in and out of itself, but it
+ // presents the use-case to static and dynamic checkers that can raise
+ // a warning (hopefully) should this become an issue.
+ QObject *o = new QObject(this);
+ const QPointer<QObject> p = o;
+ delete o;
+ QVERIFY(!p);
+}
+
QTEST_MAIN(tst_QPointer)
#include "tst_qpointer.moc"
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 32c2154da6..7f6e26eecb 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -276,6 +276,8 @@ private slots:
void compareSanity_data();
void compareSanity();
+ void accessSequentialContainerKey();
+
private:
void dataStream_data(QDataStream::Version version);
void loadQVariantFromDataStream(QDataStream::Version version);
@@ -4763,5 +4765,30 @@ void tst_QVariant::compareSanity()
}
}
+void tst_QVariant::accessSequentialContainerKey()
+{
+ QString nameResult;
+
+ {
+ QMap<QString, QObject*> mapping;
+ QString name = QString::fromLatin1("Seven");
+ mapping.insert(name, Q_NULLPTR);
+
+ QVariant variant = QVariant::fromValue(mapping);
+
+ QAssociativeIterable iterable = variant.value<QAssociativeIterable>();
+ QAssociativeIterable::const_iterator iit = iterable.begin();
+ const QAssociativeIterable::const_iterator end = iterable.end();
+ for ( ; iit != end; ++iit) {
+ nameResult += iit.key().toString();
+ }
+ } // Destroy mapping
+ // Regression test for QTBUG-52246 - no memory corruption/double deletion
+ // of the string key.
+
+ QCOMPARE(nameResult, QStringLiteral("Seven"));
+}
+
+
QTEST_MAIN(tst_QVariant)
#include "tst_qvariant.moc"