diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-08-20 14:58:58 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-08-20 14:58:58 (GMT) |
commit | 851a858fcd28c35dff2ffbeffdb40f7ee69f45b4 (patch) | |
tree | f76f604982f127af7ef66d904038cdfa705ff3af /tests/auto/qvariant/tst_qvariant.cpp | |
parent | efea248b4b725ca429793874eb168ad4b43c7994 (diff) | |
parent | c0b24b7ce12387aff6e74b05b4060c61a58d87e0 (diff) | |
download | Qt-851a858fcd28c35dff2ffbeffdb40f7ee69f45b4.zip Qt-851a858fcd28c35dff2ffbeffdb40f7ee69f45b4.tar.gz Qt-851a858fcd28c35dff2ffbeffdb40f7ee69f45b4.tar.bz2 |
Merge commit 'qt/master'
Conflicts:
examples/painting/svgviewer/files/bubbles.svg
src/corelib/kernel/qobject.cpp
src/network/kernel/qhostinfo.cpp
tests/auto/qhostinfo/tst_qhostinfo.cpp
Diffstat (limited to 'tests/auto/qvariant/tst_qvariant.cpp')
-rw-r--r-- | tests/auto/qvariant/tst_qvariant.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 6059364..729e29b 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -268,6 +268,8 @@ private slots: void toIntFromQString() const; void toIntFromDouble() const; void task256984_setValue(); + + void numericalConvert(); }; Q_DECLARE_METATYPE(QDate) @@ -3091,6 +3093,40 @@ void tst_QVariant::task256984_setValue() 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" |