summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp48
1 files changed, 28 insertions, 20 deletions
diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
index b3ffe74b67..f7798bbb70 100644
--- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -58,6 +58,7 @@ private slots:
void loopbackIPv4();
void loopbackIPv6();
void localAddress();
+ void interfaceFromXXX_data();
void interfaceFromXXX();
void copyInvalidInterface();
@@ -188,35 +189,42 @@ void tst_QNetworkInterface::localAddress()
QVERIFY(all.contains(local));
}
-void tst_QNetworkInterface::interfaceFromXXX()
+void tst_QNetworkInterface::interfaceFromXXX_data()
{
+ QTest::addColumn<QNetworkInterface>("iface");
+
QList<QNetworkInterface> allInterfaces = QNetworkInterface::allInterfaces();
+ foreach (QNetworkInterface iface, allInterfaces)
+ QTest::newRow(iface.name().toLocal8Bit()) << iface;
+}
+
+void tst_QNetworkInterface::interfaceFromXXX()
+{
+ QFETCH(QNetworkInterface, iface);
- foreach (QNetworkInterface iface, allInterfaces) {
- QVERIFY(QNetworkInterface::interfaceFromName(iface.name()).isValid());
- foreach (QNetworkAddressEntry entry, iface.addressEntries()) {
- QVERIFY(!entry.ip().isNull());
+ QVERIFY(QNetworkInterface::interfaceFromName(iface.name()).isValid());
+ foreach (QNetworkAddressEntry entry, iface.addressEntries()) {
+ QVERIFY(!entry.ip().isNull());
- if (!entry.netmask().isNull()) {
- QCOMPARE(entry.netmask().protocol(), entry.ip().protocol());
+ if (!entry.netmask().isNull()) {
+ QCOMPARE(entry.netmask().protocol(), entry.ip().protocol());
- // if the netmask is known, the broadcast is known
- // but only for IPv4 (there is no such thing as broadcast in IPv6)
- if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol) {
- QVERIFY(!entry.broadcast().isNull());
+ // if the netmask is known, the broadcast is known
+ // but only for IPv4 (there is no such thing as broadcast in IPv6)
+ if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol) {
+ QVERIFY(!entry.broadcast().isNull());
- // verify that the broadcast address is correct
- quint32 ip = entry.ip().toIPv4Address();
- quint32 mask = entry.netmask().toIPv4Address();
- quint32 bcast = entry.broadcast().toIPv4Address();
+ // verify that the broadcast address is correct
+ quint32 ip = entry.ip().toIPv4Address();
+ quint32 mask = entry.netmask().toIPv4Address();
+ quint32 bcast = entry.broadcast().toIPv4Address();
- QCOMPARE(bcast, ip | ~mask);
- }
+ QCOMPARE(bcast, ip | ~mask);
}
-
- if (!entry.broadcast().isNull())
- QCOMPARE(entry.broadcast().protocol(), entry.ip().protocol());
}
+
+ if (!entry.broadcast().isNull())
+ QCOMPARE(entry.broadcast().protocol(), entry.ip().protocol());
}
}