diff options
author | Rym Bouabid <rym.bouabid@qt.io> | 2024-02-20 16:54:53 +0100 |
---|---|---|
committer | Rym Bouabid <rym.bouabid@qt.io> | 2024-03-06 11:09:21 +0100 |
commit | 8103d29e94f90131ee0ad69fc312c1e62e74a6a9 (patch) | |
tree | eaa067a796a42da3ebd72e411cabec8d935e052d /tests/auto/corelib/io | |
parent | 907e9a8b293a0a4372ea474ad76e7507e7c7ebd9 (diff) |
QUrl: Use new comparison helper macros
The class had operator==(), operator!=() and operator <() defined as
public member functions, so use QT_CORE_REMOVED_SINCE and
removed_api.cpp to get rid of these methods and replace them with hidden
friends.
Use QT_TEST_ALL_EQUALITY_OPS macro in unit-tests.
Use new \compares command in the documentation to describe the
comparison operators provided by QUrl.
Task-number: QTBUG-120303
Change-Id: Ic4fa2335292cc4b75ad2373832c0b89d768f529c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r-- | tests/auto/corelib/io/qurl/tst_qurl.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index ec901f8b63..81cd94e4ed 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -6,6 +6,7 @@ #include <QtCore/QDebug> #include <QTest> +#include <QtTest/private/qcomparisontesthelper_p.h> #include <QDirIterator> #include <qcoreapplication.h> @@ -31,6 +32,7 @@ private slots: void hashInPath(); void unc(); void assignment(); + void orderingCompiles(); void comparison(); void comparison2_data(); void comparison2(); @@ -289,6 +291,11 @@ void tst_QUrl::assignment() QCOMPARE(url, copy); } +void tst_QUrl::orderingCompiles() +{ + QTestPrivate::testAllComparisonOperatorsCompile<QUrl>(); +} + void tst_QUrl::comparison() { QUrl url1("http://qt-project.org/"); @@ -437,18 +444,19 @@ void tst_QUrl::comparison2() QFETCH(QUrl, url2); QFETCH(int, ordering); + const Qt::weak_ordering expectedOrdering = [&ordering] { + if (ordering > 0) + return Qt::weak_ordering::greater; + else if (ordering < 0) + return Qt::weak_ordering::less; + return Qt::weak_ordering::equivalent; + }(); + QCOMPARE(url1.toString() == url2.toString(), ordering == 0); - QCOMPARE(url1 == url2, ordering == 0); - QCOMPARE(url1 != url2, ordering != 0); + QT_TEST_ALL_COMPARISON_OPS(url1, url2, expectedOrdering); if (ordering == 0) QCOMPARE(qHash(url1), qHash(url2)); - QCOMPARE(url1 < url2, ordering < 0); - QCOMPARE(!(url1 < url2), ordering >= 0); - - QCOMPARE(url2 < url1, ordering > 0); - QCOMPARE(!(url2 < url1), ordering <= 0); - // redundant checks (the above should catch these) QCOMPARE(url1 < url2 || url2 < url1, ordering != 0); QVERIFY(!(url1 < url2 && url2 < url1)); |