summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-03-23 14:37:41 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2011-03-23 14:39:27 (GMT)
commitcea4ae150bef0f24b0e8385d47b06a9f6b8197c3 (patch)
treedbafc4c5248bd2f7f97b91e78614e6e791fd546c /tests
parentb10199ab328848e954c3701f745043ff697a2c27 (diff)
downloadQt-cea4ae150bef0f24b0e8385d47b06a9f6b8197c3.zip
Qt-cea4ae150bef0f24b0e8385d47b06a9f6b8197c3.tar.gz
Qt-cea4ae150bef0f24b0e8385d47b06a9f6b8197c3.tar.bz2
Fix tst_QVariant::qvariant_cast_QObject
qvariant_cast_QObject_data was creating the QVariant wrong, The QVariant(int, void*) constructor take a pointer to the value of the type ObjectStar (hence a pointer to a pointer) Task-number: QTBUG-18257
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index 62babdb..2e57264 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -2660,7 +2660,10 @@ void tst_QVariant::qvariant_cast_QObject_data() {
QTest::addColumn<QVariant>("data");
QTest::addColumn<bool>("success");
- QTest::newRow("from QObject") << QVariant(QMetaType::QObjectStar, new QObject(this)) << true;
+ QObject *obj = new QObject(this);
+ obj->setObjectName(QString::fromLatin1("Hello"));
+ QTest::newRow("from QObject") << QVariant(QMetaType::QObjectStar, &obj) << true;
+ QTest::newRow("from QObject2") << QVariant::fromValue(obj) << true;
QTest::newRow("from String") << QVariant(QLatin1String("1, 2, 3")) << false;
QTest::newRow("from int") << QVariant((int) 123) << false;
}
@@ -2672,6 +2675,9 @@ void tst_QVariant::qvariant_cast_QObject() {
QObject *o = qvariant_cast<QObject *>(data);
QCOMPARE(o != 0, success);
+ if (success) {
+ QCOMPARE(o->objectName(), QString::fromLatin1("Hello"));
+ }
}
Q_DECLARE_METATYPE(qint8);