summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-20 20:45:43 +0200
committerKent Hansen <khansen@trolltech.com>2009-08-20 20:45:43 +0200
commitd63d0c10c0eeef0d2f93f3d0b197e09399087b00 (patch)
tree746a1856103d6367f9821a81b7eee25aeb10a7ed /tests/auto
parent435c87186ff54ebfd481e41e07b9a136fbc87a20 (diff)
parente90a5e819478b656963de0492a1b234c8863a12b (diff)
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')
-rw-r--r--tests/auto/qhostinfo/tst_qhostinfo.cpp2
-rw-r--r--tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp121
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp9
-rw-r--r--tests/auto/qsharedpointer/tst_qsharedpointer.cpp16
-rw-r--r--tests/auto/qstringbuilder/qstringbuilder.pro5
-rw-r--r--tests/auto/qstringbuilder/scenario1.pro9
-rw-r--r--tests/auto/qstringbuilder/scenario2.pro8
-rw-r--r--tests/auto/qstringbuilder/scenario3.pro8
-rw-r--r--tests/auto/qstringbuilder/scenario4.pro8
-rw-r--r--tests/auto/qstringbuilder1/qstringbuilder1.pro9
-rw-r--r--tests/auto/qstringbuilder1/stringbuilder.cpp (renamed from tests/auto/qstringbuilder/tst_qstringbuilder.cpp)2
-rw-r--r--tests/auto/qstringbuilder1/stringbuilder.h (renamed from tests/auto/qstringbuilder/tst_qstringbuilder.h)0
-rw-r--r--tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp (renamed from tests/auto/qstringbuilder/scenario3.cpp)2
-rw-r--r--tests/auto/qstringbuilder2/qstringbuilder2.pro8
-rw-r--r--tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp (renamed from tests/auto/qstringbuilder/scenario1.cpp)2
-rw-r--r--tests/auto/qstringbuilder3/qstringbuilder3.pro8
-rw-r--r--tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp (renamed from tests/auto/qstringbuilder/scenario2.cpp)2
-rw-r--r--tests/auto/qstringbuilder4/qstringbuilder4.pro8
-rw-r--r--tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp (renamed from tests/auto/qstringbuilder/scenario4.cpp)2
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp7
-rw-r--r--tests/auto/qtextdocument/tst_qtextdocument.cpp19
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp38
22 files changed, 230 insertions, 63 deletions
diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp
index 4b60acac16..abe49df863 100644
--- a/tests/auto/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp
@@ -303,7 +303,7 @@ void tst_QHostInfo::reverseLookup_data()
// ### Use internal DNS instead. Discussed with Andreas.
//QTest::newRow("classical.hexago.com") << QString("2001:5c0:0:2::24") << QStringList(QString("classical.hexago.com")) << 0;
QTest::newRow("www.cisco.com") << QString("198.133.219.25") << QStringList(QString("origin-www.cisco.com")) << 0;
- QTest::newRow("bogusexample.doenstexist.org") << QString("1::2::3::4") << QStringList() << 1;
+ QTest::newRow("bogus-name") << QString("1::2::3::4") << QStringList() << 1;
}
void tst_QHostInfo::reverseLookup()
diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
index 4f24721ec4..c4c33d5731 100644
--- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
+++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
@@ -99,6 +99,9 @@ private Q_SLOTS:
void get401_data();
void get401();
+ void getMultiple_data();
+ void getMultiple();
+ void getMultipleWithPipeliningAndMultiplePriorities();
};
@@ -763,5 +766,123 @@ void tst_QHttpNetworkConnection::nossl()
}
#endif
+
+void tst_QHttpNetworkConnection::getMultiple_data()
+{
+ QTest::addColumn<quint16>("connectionCount");
+ QTest::addColumn<bool>("pipeliningAllowed");
+ // send 100 requests. apache will usually force-close after 100 requests in a single tcp connection
+ QTest::addColumn<int>("requestCount");
+
+ QTest::newRow("6 connections, no pipelining, 100 requests") << quint16(6) << false << 100;
+ QTest::newRow("1 connection, no pipelining, 100 requests") << quint16(1) << false << 100;
+ QTest::newRow("6 connections, pipelining allowed, 100 requests") << quint16(2) << true << 100;
+ QTest::newRow("1 connection, pipelining allowed, 100 requests") << quint16(1) << true << 100;
+}
+
+void tst_QHttpNetworkConnection::getMultiple()
+{
+ QFETCH(quint16, connectionCount);
+ QFETCH(bool, pipeliningAllowed);
+ QFETCH(int, requestCount);
+
+ QHttpNetworkConnection connection(connectionCount, QtNetworkSettings::serverName());
+
+ QList<QHttpNetworkRequest*> requests;
+ QList<QHttpNetworkReply*> replies;
+
+ for (int i = 0; i < requestCount; i++) {
+ // depending on what you use the results will vary.
+ // for the "real" results, use a URL that has "internet latency" for you. Then (6 connections, pipelining) will win.
+ // for LAN latency, you will possibly get that (1 connection, no pipelining) is the fastest
+ QHttpNetworkRequest *request = new QHttpNetworkRequest("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt");
+ // located in Berlin:
+ //QHttpNetworkRequest *request = new QHttpNetworkRequest(QUrl("http://klinsmann.nokia.trolltech.de/~berlin/qtcreatorad.gif"));
+ if (pipeliningAllowed)
+ request->setPipeliningAllowed(true);
+ requests.append(request);
+ QHttpNetworkReply *reply = connection.sendRequest(*request);
+ replies.append(reply);
+ }
+
+ QTime stopWatch;
+ stopWatch.start();
+ int finishedCount = 0;
+ do {
+ QCoreApplication::instance()->processEvents();
+ if (stopWatch.elapsed() >= 60000)
+ break;
+
+ finishedCount = 0;
+ for (int i = 0; i < replies.length(); i++)
+ if (replies.at(i)->isFinished())
+ finishedCount++;
+
+ } while (finishedCount != replies.length());
+
+ // redundant
+ for (int i = 0; i < replies.length(); i++)
+ QVERIFY(replies.at(i)->isFinished());
+
+ qDebug() << "===" << stopWatch.elapsed() << "msec ===";
+
+ qDeleteAll(requests);
+ qDeleteAll(replies);
+}
+
+void tst_QHttpNetworkConnection::getMultipleWithPipeliningAndMultiplePriorities()
+{
+ quint16 requestCount = 100;
+
+ // use 2 connections.
+ QHttpNetworkConnection connection(2, QtNetworkSettings::serverName());
+
+ QList<QHttpNetworkRequest*> requests;
+ QList<QHttpNetworkReply*> replies;
+
+ for (int i = 0; i < requestCount; i++) {
+
+ QHttpNetworkRequest *request = new QHttpNetworkRequest("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt");
+
+ if (i % 2 || i % 3)
+ request->setPipeliningAllowed(true);
+
+ if (i % 3)
+ request->setPriority(QHttpNetworkRequest::HighPriority);
+ else if (i % 5)
+ request->setPriority(QHttpNetworkRequest::NormalPriority);
+ else if (i % 7)
+ request->setPriority(QHttpNetworkRequest::LowPriority);
+
+ requests.append(request);
+ QHttpNetworkReply *reply = connection.sendRequest(*request);
+ replies.append(reply);
+ }
+
+ QTime stopWatch;
+ stopWatch.start();
+ int finishedCount = 0;
+ do {
+ QCoreApplication::instance()->processEvents();
+ if (stopWatch.elapsed() >= 60000)
+ break;
+
+ finishedCount = 0;
+ for (int i = 0; i < replies.length(); i++)
+ if (replies.at(i)->isFinished())
+ finishedCount++;
+
+ } while (finishedCount != replies.length());
+
+ // redundant
+ for (int i = 0; i < replies.length(); i++)
+ QVERIFY(replies.at(i)->isFinished());
+
+ qDebug() << "===" << stopWatch.elapsed() << "msec ===";
+
+ qDeleteAll(requests);
+ qDeleteAll(replies);
+}
+
QTEST_MAIN(tst_QHttpNetworkConnection)
#include "tst_qhttpnetworkconnection.moc"
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index d339803853..7a9d016c6d 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -2254,8 +2254,11 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer_data()
QTest::addColumn<bool>("doDisconnect");
QTest::newRow("no-newline") << QByteArray("Hello World") << false;
- QTest::newRow("just-newline") << QByteArray("\r\n") << false;
- QTest::newRow("just-2newline") << QByteArray("\r\n\r\n") << false;
+
+ // these are OK now, we just eat the lonely newlines
+ //QTest::newRow("just-newline") << QByteArray("\r\n") << false;
+ //QTest::newRow("just-2newline") << QByteArray("\r\n\r\n") << false;
+
QTest::newRow("with-newlines") << QByteArray("Long first line\r\nLong second line") << false;
QTest::newRow("with-newlines2") << QByteArray("\r\nSecond line") << false;
QTest::newRow("with-newlines3") << QByteArray("ICY\r\nSecond line") << false;
@@ -2931,7 +2934,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocket()
QSignalSpy authenticationRequiredSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)));
QSignalSpy proxyAuthenticationRequiredSpy(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
- QTestEventLoop::instance().enterLoop(1);
+ QTestEventLoop::instance().enterLoop(3);
disconnect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index c9b232517d..b2afb9f75a 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -799,6 +799,7 @@ void tst_QSharedPointer::differentPointers()
QVERIFY(baseptr.data() == aData);
QVERIFY(aData == baseptr.data());
+ QVERIFY(bool(operator==<Data,DiffPtrDerivedData>(baseptr, aData)));
QVERIFY(baseptr == aData);
QVERIFY(aData == baseptr);
}
@@ -1654,21 +1655,6 @@ void tst_QSharedPointer::invalidConstructs_data()
<< "QObject *ptr = new QObject;\n"
"QWeakPointer<QObject> weak = ptr;\n" // this makes the object unmanaged
"QSharedPointer<QObject> shared(ptr);\n";
-
-#ifndef QT_NO_DEBUG
- // this tests a Q_ASSERT, so it is only valid in debug mode
- // the DerivedFromQObject destructor below creates a QWeakPointer from parent().
- // parent() is not 0 in the current Qt implementation, but has started destruction,
- // so the code should detect that issue
- QTest::newRow("shared-pointer-from-qobject-in-destruction")
- << &QTest::QExternalTest::tryRunFail
- << "class DerivedFromQObject: public QObject { public:\n"
- " DerivedFromQObject(QObject *parent): QObject(parent) {}\n"
- " ~DerivedFromQObject() { QWeakPointer<QObject> weak = parent(); }\n"
- "};\n"
- "QObject obj;\n"
- "new DerivedFromQObject(&obj);";
-#endif
}
void tst_QSharedPointer::invalidConstructs()
diff --git a/tests/auto/qstringbuilder/qstringbuilder.pro b/tests/auto/qstringbuilder/qstringbuilder.pro
deleted file mode 100644
index c5a26d386c..0000000000
--- a/tests/auto/qstringbuilder/qstringbuilder.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-
-TEMPLATE = subdirs
-SUBDIRS = scenario1.pro scenario2.pro scenario3.pro scenario4.pro
-
-
diff --git a/tests/auto/qstringbuilder/scenario1.pro b/tests/auto/qstringbuilder/scenario1.pro
deleted file mode 100644
index d72451c2ec..0000000000
--- a/tests/auto/qstringbuilder/scenario1.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-
-QT = core
-
-SOURCES += scenario1.cpp
-HEADERS += tst_qstringbuilder.h
-
-DEFINES += SCENARIO=1
-
diff --git a/tests/auto/qstringbuilder/scenario2.pro b/tests/auto/qstringbuilder/scenario2.pro
deleted file mode 100644
index 78e0c68de3..0000000000
--- a/tests/auto/qstringbuilder/scenario2.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-
-QT = core
-
-SOURCES += scenario2.cpp
-HEADERS += tst_qstringbuilder.h
-
-DEFINES += SCENARIO=2
diff --git a/tests/auto/qstringbuilder/scenario3.pro b/tests/auto/qstringbuilder/scenario3.pro
deleted file mode 100644
index 7b9e5af180..0000000000
--- a/tests/auto/qstringbuilder/scenario3.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-
-QT = core
-
-SOURCES += scenario3.cpp
-HEADERS += tst_qstringbuilder.h
-
-DEFINES += SCENARIO=3
diff --git a/tests/auto/qstringbuilder/scenario4.pro b/tests/auto/qstringbuilder/scenario4.pro
deleted file mode 100644
index 1b62b25e37..0000000000
--- a/tests/auto/qstringbuilder/scenario4.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-
-QT = core
-
-SOURCES += scenario4.cpp
-HEADERS += tst_qstringbuilder.h
-
-DEFINES += SCENARIO=4
diff --git a/tests/auto/qstringbuilder1/qstringbuilder1.pro b/tests/auto/qstringbuilder1/qstringbuilder1.pro
new file mode 100644
index 0000000000..1ca9d456a8
--- /dev/null
+++ b/tests/auto/qstringbuilder1/qstringbuilder1.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+
+QT = core
+
+SOURCES += tst_qstringbuilder1.cpp
+HEADERS += ../qstringbuilder1/stringbuilder.h
+
+DEFINES += SCENARIO=1
+
diff --git a/tests/auto/qstringbuilder/tst_qstringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp
index ffe77392d9..c26099ae33 100644
--- a/tests/auto/qstringbuilder/tst_qstringbuilder.cpp
+++ b/tests/auto/qstringbuilder1/stringbuilder.cpp
@@ -86,7 +86,7 @@
#endif
#include <QtTest/QtTest>
-#include "tst_qstringbuilder.h"
+#include "stringbuilder.h"
//TESTED_CLASS=QStringBuilder
//TESTED_FILES=qstringbuilder.cpp
diff --git a/tests/auto/qstringbuilder/tst_qstringbuilder.h b/tests/auto/qstringbuilder1/stringbuilder.h
index b7e7f5a71b..b7e7f5a71b 100644
--- a/tests/auto/qstringbuilder/tst_qstringbuilder.h
+++ b/tests/auto/qstringbuilder1/stringbuilder.h
diff --git a/tests/auto/qstringbuilder/scenario3.cpp b/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp
index 915964993a..f6fa7c07ee 100644
--- a/tests/auto/qstringbuilder/scenario3.cpp
+++ b/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp
@@ -39,4 +39,4 @@
**
****************************************************************************/
-#include "tst_qstringbuilder.cpp"
+#include "../qstringbuilder1/stringbuilder.cpp"
diff --git a/tests/auto/qstringbuilder2/qstringbuilder2.pro b/tests/auto/qstringbuilder2/qstringbuilder2.pro
new file mode 100644
index 0000000000..c0b3ebc797
--- /dev/null
+++ b/tests/auto/qstringbuilder2/qstringbuilder2.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+
+QT = core
+
+SOURCES += tst_qstringbuilder2.cpp
+HEADERS += ../qstringbuilder1/stringbuilder.h
+
+DEFINES += SCENARIO=2
diff --git a/tests/auto/qstringbuilder/scenario1.cpp b/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp
index 915964993a..f6fa7c07ee 100644
--- a/tests/auto/qstringbuilder/scenario1.cpp
+++ b/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp
@@ -39,4 +39,4 @@
**
****************************************************************************/
-#include "tst_qstringbuilder.cpp"
+#include "../qstringbuilder1/stringbuilder.cpp"
diff --git a/tests/auto/qstringbuilder3/qstringbuilder3.pro b/tests/auto/qstringbuilder3/qstringbuilder3.pro
new file mode 100644
index 0000000000..93d1a39e7e
--- /dev/null
+++ b/tests/auto/qstringbuilder3/qstringbuilder3.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+
+QT = core
+
+SOURCES += tst_qstringbuilder3.cpp
+HEADERS += ../qstringbuilder1/stringbuilder.h
+
+DEFINES += SCENARIO=3
diff --git a/tests/auto/qstringbuilder/scenario2.cpp b/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp
index 915964993a..f6fa7c07ee 100644
--- a/tests/auto/qstringbuilder/scenario2.cpp
+++ b/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp
@@ -39,4 +39,4 @@
**
****************************************************************************/
-#include "tst_qstringbuilder.cpp"
+#include "../qstringbuilder1/stringbuilder.cpp"
diff --git a/tests/auto/qstringbuilder4/qstringbuilder4.pro b/tests/auto/qstringbuilder4/qstringbuilder4.pro
new file mode 100644
index 0000000000..eeec447885
--- /dev/null
+++ b/tests/auto/qstringbuilder4/qstringbuilder4.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+
+QT = core
+
+SOURCES += tst_qstringbuilder4.cpp
+HEADERS += ../qstringbuilder1/stringbuilder.h
+
+DEFINES += SCENARIO=4
diff --git a/tests/auto/qstringbuilder/scenario4.cpp b/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp
index 25f793261d..480db66506 100644
--- a/tests/auto/qstringbuilder/scenario4.cpp
+++ b/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp
@@ -39,4 +39,4 @@
**
****************************************************************************/
-#include "tst_qstringbuilder.cpp"
+#include "../qstringbuilder1/stringbuilder.cpp"
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index ebb62e127e..6d0dc2193b 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -45,6 +45,8 @@
#else
#include <sys/types.h>
#include <sys/socket.h>
+#include <fcntl.h>
+#include <unistd.h>
#define SOCKET int
#define INVALID_SOCKET -1
#endif
@@ -415,6 +417,11 @@ void tst_QTcpSocket::setSocketDescriptor()
}
#else
SOCKET sock = ::socket(AF_INET, SOCK_STREAM, 0);
+
+ // artificially increase the value of sock
+ SOCKET sock2 = ::fcntl(sock, F_DUPFD, sock + 50);
+ ::close(sock);
+ sock = sock2;
#endif
QVERIFY(sock != INVALID_SOCKET);
diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp
index 4643df03a2..cffa4375ca 100644
--- a/tests/auto/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp
@@ -2490,6 +2490,25 @@ void tst_QTextDocument::testUndoBlocks()
QCOMPARE(doc->toPlainText(), QString("Hello WorldOne\nTwo\nThree"));
doc->undo();
QCOMPARE(doc->toPlainText(), QString("Hello World"));
+ cursor.insertText("One\nTwo\nThree");
+ cursor.insertText("Trailing text");
+ doc->undo();
+ QCOMPARE(doc->toPlainText(), QString("Hello WorldOne\nTwo\nThree"));
+ doc->undo();
+ QCOMPARE(doc->toPlainText(), QString("Hello World"));
+ doc->undo();
+ QCOMPARE(doc->toPlainText(), QString(""));
+
+ cursor.insertText("quod");
+ cursor.beginEditBlock();
+ cursor.insertText(" erat");
+ cursor.endEditBlock();
+ cursor.insertText(" demonstrandum");
+ QCOMPARE(doc->toPlainText(), QString("quod erat demonstrandum"));
+ doc->undo();
+ QCOMPARE(doc->toPlainText(), QString("quod erat"));
+ doc->undo();
+ QCOMPARE(doc->toPlainText(), QString("quod"));
doc->undo();
QCOMPARE(doc->toPlainText(), QString(""));
}
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index 9ad4482b8c..709cba9c75 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"