diff options
Diffstat (limited to 'tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp')
-rw-r--r-- | tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index 2671c253cb..f5f5146eb5 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -64,14 +64,10 @@ #include <qhostinfo.h> #include "private/qhostinfo_p.h" -#if !defined(QT_NO_GETADDRINFO) -# include <sys/types.h> -# if defined(Q_OS_UNIX) +#include <sys/types.h> +#if defined(Q_OS_UNIX) # include <sys/socket.h> -# endif -# if !defined(Q_OS_WIN) # include <netdb.h> -# endif #endif #include "../../../network-settings.h" @@ -86,6 +82,8 @@ class tst_QHostInfo : public QObject private slots: void init(); void initTestCase(); + void swapFunction(); + void moveOperator(); void getSetCheck(); void staticInformation(); void lookupIPv4_data(); @@ -129,6 +127,29 @@ private: #endif }; +void tst_QHostInfo::swapFunction() +{ + QHostInfo obj1, obj2; + obj1.setError(QHostInfo::HostInfoError(0)); + obj2.setError(QHostInfo::HostInfoError(1)); + obj1.swap(obj2); + QCOMPARE(QHostInfo::HostInfoError(0), obj2.error()); + QCOMPARE(QHostInfo::HostInfoError(1), obj1.error()); +} + +void tst_QHostInfo::moveOperator() +{ + QHostInfo obj1, obj2, obj3(1); + obj1.setError(QHostInfo::HostInfoError(0)); + obj2.setError(QHostInfo::HostInfoError(1)); + obj1 = std::move(obj2); + obj2 = obj3; + QCOMPARE(QHostInfo::HostInfoError(1), obj1.error()); + QCOMPARE(obj3.lookupId(), obj2.lookupId()); +} + + + // Testing get/set functions void tst_QHostInfo::getSetCheck() { @@ -166,7 +187,7 @@ void tst_QHostInfo::initTestCase() networkSession.reset(new QNetworkSession(networkConfiguration)); if (!networkSession->isOpen()) { networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); + networkSession->waitForOpened(30000); } #endif @@ -179,15 +200,13 @@ void tst_QHostInfo::initTestCase() ipv6Available = true; } -// HP-UX 11i does not support IPv6 reverse lookups. -#if !defined(QT_NO_GETADDRINFO) && !(defined(Q_OS_HPUX) && defined(__ia64)) // check if the system getaddrinfo can do IPv6 lookups struct addrinfo hint, *result = 0; memset(&hint, 0, sizeof hint); hint.ai_family = AF_UNSPEC; -# ifdef AI_ADDRCONFIG +#ifdef AI_ADDRCONFIG hint.ai_flags = AI_ADDRCONFIG; -# endif +#endif int res = getaddrinfo("::1", "80", &hint, &result); if (res == 0) { @@ -199,7 +218,6 @@ void tst_QHostInfo::initTestCase() ipv6LookupsAvailable = true; } } -#endif // run each testcase with and without test enabled QTest::addColumn<bool>("cache"); |