diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-08-20 18:45:43 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-08-20 18:45:43 (GMT) |
commit | d63d0c10c0eeef0d2f93f3d0b197e09399087b00 (patch) | |
tree | 746a1856103d6367f9821a81b7eee25aeb10a7ed /tests/auto/qvariant/tst_qvariant.cpp | |
parent | 435c87186ff54ebfd481e41e07b9a136fbc87a20 (diff) | |
parent | e90a5e819478b656963de0492a1b234c8863a12b (diff) | |
download | Qt-d63d0c10c0eeef0d2f93f3d0b197e09399087b00.zip Qt-d63d0c10c0eeef0d2f93f3d0b197e09399087b00.tar.gz Qt-d63d0c10c0eeef0d2f93f3d0b197e09399087b00.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into qtscript-jsc-backend
Conflicts:
src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri
Diffstat (limited to 'tests/auto/qvariant/tst_qvariant.cpp')
-rw-r--r-- | tests/auto/qvariant/tst_qvariant.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 9ad4482..709cba9 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -267,6 +267,8 @@ private slots: void convertByteArrayToBool_data() const; void toIntFromQString() const; void task256984_setValue(); + + void numericalConvert(); }; Q_DECLARE_METATYPE(QDate) @@ -3060,11 +3062,45 @@ void tst_QVariant::task256984_setValue() QVERIFY( !v2.isDetached() ); qVariantSetValue(v2, 3); //set an integer value - + QVERIFY( v1.isDetached() ); QVERIFY( v2.isDetached() ); } +void tst_QVariant::numericalConvert() +{ + QVariant vfloat(float(5.3)); + QVariant vdouble(double(5.3)); + QVariant vreal(qreal(5.3)); + QVariant vint(int(5)); + QVariant vuint(uint(5)); + QVariant vshort(short(5)); + QVariant vlonglong(quint64(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; + + for(int i = 0; i < vect.size(); i++) { + double num = 5.3; + if (i >= 3 && i <= 7) + 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) { + QCOMPARE(v->toInt() , int(num)); + QCOMPARE(v->toUInt() , uint(num)); + QCOMPARE(v->toULongLong() , quint64(num)); + } + QCOMPARE(v->toString() , QString::number(num)); + } +} + + + QTEST_MAIN(tst_QVariant) #include "tst_qvariant.moc" |