diff options
Diffstat (limited to 'tests/auto/network/kernel/qhostaddress')
-rw-r--r-- | tests/auto/network/kernel/qhostaddress/CMakeLists.txt | 13 | ||||
-rw-r--r-- | tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp | 12 |
2 files changed, 20 insertions, 5 deletions
diff --git a/tests/auto/network/kernel/qhostaddress/CMakeLists.txt b/tests/auto/network/kernel/qhostaddress/CMakeLists.txt index a33ae6d709..e11a600b60 100644 --- a/tests/auto/network/kernel/qhostaddress/CMakeLists.txt +++ b/tests/auto/network/kernel/qhostaddress/CMakeLists.txt @@ -1,13 +1,20 @@ -# Generated from qhostaddress.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qhostaddress Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qhostaddress LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + qt_internal_add_test(tst_qhostaddress SOURCES tst_qhostaddress.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::NetworkPrivate ) @@ -15,6 +22,6 @@ qt_internal_add_test(tst_qhostaddress ##################################################################### qt_internal_extend_target(tst_qhostaddress CONDITION WIN32 - PUBLIC_LIBRARIES + LIBRARIES ws2_32 ) diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp index 4dbf891822..18d1c04a85 100644 --- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp +++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp @@ -1,6 +1,6 @@ // Copyright (C) 2016 The Qt Company Ltd. // Copyright (C) 2016 Intel Corporation. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <qhostaddress.h> #include <private/qhostaddress_p.h> @@ -15,7 +15,7 @@ # include <qt_windows.h> #endif -#if defined(Q_OS_ANDROID) || defined(Q_OS_WASM) +#if defined(Q_OS_ANDROID) || defined(Q_OS_WASM) || defined(Q_OS_VXWORKS) # include <netinet/in.h> #endif @@ -326,6 +326,12 @@ void tst_QHostAddress::isEqual_data() QTest::newRow("anyv6-anyv4-local") << QHostAddress(QHostAddress::AnyIPv6) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::ConvertLocalHost << false; QTest::newRow("any-anyv4-local") << QHostAddress(QHostAddress::Any) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::ConvertLocalHost << false; QTest::newRow("any-anyv6-local") << QHostAddress(QHostAddress::Any) << QHostAddress(QHostAddress::AnyIPv6) << (int)QHostAddress::ConvertLocalHost << false; + QTest::newRow("localhostv6-any-tolerant") << QHostAddress(QHostAddress::LocalHostIPv6) << QHostAddress(QHostAddress::Any) << (int)QHostAddress::TolerantConversion << false; + QTest::newRow("localhostv4-any-tolerant") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::Any) << (int)QHostAddress::TolerantConversion << false; + QTest::newRow("localhostv6-anyv6-tolerant") << QHostAddress(QHostAddress::LocalHostIPv6) << QHostAddress(QHostAddress::AnyIPv6) << (int)QHostAddress::TolerantConversion << false; + QTest::newRow("localhostv4-anyv6-tolerant") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::AnyIPv6) << (int)QHostAddress::TolerantConversion << false; + QTest::newRow("localhostv6-anyv4-tolerant") << QHostAddress(QHostAddress::LocalHostIPv6) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::TolerantConversion << false; + QTest::newRow("localhostv4-anyv4-tolerant") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::TolerantConversion << false; } void tst_QHostAddress::isEqual() @@ -697,6 +703,7 @@ void tst_QHostAddress::classification() bool isUniqueLocalAddress = (result == UniqueLocalAddress); bool isMulticast = (result == MulticastAddress); bool isBroadcast = (result == BroadcastAddress); + bool isPrivateUse = (result == PrivateNetworkAddress || result == UniqueLocalAddress); QCOMPARE(address.isLoopback(), isLoopback); QCOMPARE(address.isGlobal(), isGlobal); @@ -705,6 +712,7 @@ void tst_QHostAddress::classification() QCOMPARE(address.isUniqueLocalUnicast(), isUniqueLocalAddress); QCOMPARE(address.isMulticast(), isMulticast); QCOMPARE(address.isBroadcast(), isBroadcast); + QCOMPARE(address.isPrivateUse(), isPrivateUse); } void tst_QHostAddress::convertv4v6_data() |