diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index 8bb7dad008..16f14c4579 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -1129,6 +1129,18 @@ bool QUrlQuery::operator==(const QUrlQuery &other) const return comparesEqual(*this, other); } +#include "quuid.h" + +bool QUuid::operator<(const QUuid &other) const noexcept +{ + return is_lt(compareThreeWay(*this, other)); +} + +bool QUuid::operator>(const QUuid &other) const noexcept +{ + return is_gt(compareThreeWay(*this, other)); +} + #include "qxmlstream.h" // inlined API // #include "qotherheader.h" diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 9c7216c3c5..42f21eea88 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -142,6 +142,11 @@ static QUuid createFromName(const QUuid &ns, const QByteArray &baseData, QCrypto \reentrant + \compares strong + \compareswith strong GUID + \note Comparison with GUID is Windows-only. + \endcompareswith + Using \e{U}niversally \e{U}nique \e{ID}entifiers (UUID) is a standard way to uniquely identify entities in a distributed computing environment. A UUID is a 16-byte (128-bit) number @@ -600,16 +605,16 @@ QUuid QUuid::fromRfc4122(QByteArrayView bytes) noexcept } /*! - \fn bool QUuid::operator==(const QUuid &other) const + \fn bool QUuid::operator==(const QUuid &lhs, const QUuid &rhs) - Returns \c true if this QUuid and the \a other QUuid are identical; + Returns \c true if \a lhs QUuid and the \a rhs QUuid are identical; otherwise returns \c false. */ /*! - \fn bool QUuid::operator!=(const QUuid &other) const + \fn bool QUuid::operator!=(const QUuid &lhs, const QUuid &rhs) - Returns \c true if this QUuid and the \a other QUuid are different; + Returns \c true if \a lhs QUuid and the \a rhs QUuid are different; otherwise returns \c false. */ @@ -898,51 +903,31 @@ QUuid::Version QUuid::version() const noexcept } /*! - \fn bool QUuid::operator<(const QUuid &other) const + \fn bool QUuid::operator<(const QUuid &lhs, const QUuid &rhs) - Returns \c true if this QUuid has the same \l{Variant field} - {variant field} as the \a other QUuid and is lexicographically - \e{before} the \a other QUuid. If the \a other QUuid has a + Returns \c true if \a lhs QUuid has the same \l{Variant field} + {variant field} as the \a rhs QUuid and is lexicographically + \e{before} the \a rhs QUuid. If the \a rhs QUuid has a different variant field, the return value is determined by comparing the two \l{QUuid::Variant} {variants}. \sa variant() */ -bool QUuid::operator<(const QUuid &other) const noexcept -{ - if (variant() != other.variant()) - return variant() < other.variant(); - -#define ISLESS(f1, f2) if (f1!=f2) return (f1(const QUuid &other) const + \fn bool QUuid::operator>(const QUuid &lhs, const QUuid &rhs) - Returns \c true if this QUuid has the same \l{Variant field} - {variant field} as the \a other QUuid and is lexicographically - \e{after} the \a other QUuid. If the \a other QUuid has a + Returns \c true if \a lhs QUuid has the same \l{Variant field} + {variant field} as the \a rhs QUuid and is lexicographically + \e{after} the \a rhs QUuid. If the \a rhs QUuid has a different variant field, the return value is determined by comparing the two \l{QUuid::Variant} {variants}. \sa variant() */ -bool QUuid::operator>(const QUuid &other) const noexcept -{ - return other < *this; -} /*! - \fn bool operator<=(const QUuid &lhs, const QUuid &rhs) - \relates QUuid + \fn bool QUuid::operator<=(const QUuid &lhs, const QUuid &rhs) \since 5.5 Returns \c true if \a lhs has the same \l{Variant field} @@ -955,8 +940,7 @@ bool QUuid::operator>(const QUuid &other) const noexcept */ /*! - \fn bool operator>=(const QUuid &lhs, const QUuid &rhs) - \relates QUuid + \fn bool QUuid::operator>=(const QUuid &lhs, const QUuid &rhs) \since 5.5 Returns \c true if \a lhs has the same \l{Variant field} @@ -1009,17 +993,17 @@ QUuid QUuid::createUuid() #endif // !Q_OS_WIN && !QT_BOOTSTRAPPED /*! - \fn bool QUuid::operator==(const GUID &guid) const + \fn bool QUuid::operator==(const QUuid &lhs, const GUID &rhs) - Returns \c true if this UUID is equal to the Windows GUID \a guid; + Returns \c true if \a lhs UUID is equal to the Windows GUID \a rhs; otherwise returns \c false. */ /*! - \fn bool QUuid::operator!=(const GUID &guid) const + \fn bool QUuid::operator!=(const QUuid &lhs, const GUID &rhs) - Returns \c true if this UUID is not equal to the Windows GUID \a - guid; otherwise returns \c false. + Returns \c true if \a lhs UUID is not equal to the Windows GUID \a rhs; + otherwise returns \c false. */ #ifndef QT_NO_DEBUG_STREAM diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index 7125e8e2cc..504a6971bd 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -4,6 +4,7 @@ #ifndef QUUID_H #define QUUID_H +#include #include #include @@ -122,27 +123,59 @@ QT_WARNING_POP constexpr quint128 toUInt128(QSysInfo::Endian order = QSysInfo::BigEndian) const noexcept; #endif - constexpr bool operator==(const QUuid &orig) const noexcept +private: + friend constexpr bool comparesEqual(const QUuid &lhs, const QUuid &rhs) noexcept { - if (data1 != orig.data1 || data2 != orig.data2 || - data3 != orig.data3) + if (lhs.data1 != rhs.data1 || lhs.data2 != rhs.data2 || lhs.data3 != rhs.data3) return false; - for (uint i = 0; i < 8; i++) - if (data4[i] != orig.data4[i]) + for (uint i = 0; i < 8; i++) { + if (lhs.data4[i] != rhs.data4[i]) return false; + } return true; } + friend Qt::strong_ordering compareThreeWay(const QUuid &lhs, const QUuid &rhs) noexcept + { + if (lhs.variant() != rhs.variant()) + return Qt::compareThreeWay(lhs.variant(), rhs.variant()); + +#define CHECK(f1, f2) if ((f1) != (f2)) return Qt::compareThreeWay(f1, f2) + CHECK(lhs.data1, rhs.data1); + CHECK(lhs.data2, rhs.data2); + CHECK(lhs.data3, rhs.data3); +#undef CHECK + int c = std::memcmp(lhs.data4, rhs.data4, sizeof(lhs.data4)); + return Qt::compareThreeWay(c, 0); + } + +public: +/* To prevent a meta-type creation ambiguity on Windows, we put comparison + macros under NOT QT_CORE_REMOVED_SINCE(6, 8) part. */ +#if QT_CORE_REMOVED_SINCE(6, 8) + constexpr bool operator==(const QUuid &orig) const noexcept + { + return comparesEqual(*this, orig); + } constexpr bool operator!=(const QUuid &orig) const noexcept { - return !(*this == orig); + return !operator==(orig); } bool operator<(const QUuid &other) const noexcept; bool operator>(const QUuid &other) const noexcept; - +#else +private: +#if defined(__cpp_lib_three_way_comparison) && !defined(Q_QDOC) + QT_DECLARE_3WAY_HELPER_STRONG(QUuid, QUuid, /* non-constexpr */, /* no attributes */) +#else + QT_DECLARE_ORDERING_HELPER_STRONG(QUuid, QUuid, /* non-constexpr */, /* no attributes */) +#endif // defined(__cpp_lib_three_way_comparison) && !defined(Q_QDOC) + Q_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE(QUuid) +#endif // QT_CORE_REMOVED_SINCE(6, 8) +public: #if defined(Q_OS_WIN) || defined(Q_QDOC) // On Windows we have a type GUID that is used by the platform API, so we // provide convenience operators to cast from and to this type. @@ -162,17 +195,29 @@ QT_WARNING_POP GUID guid = { data1, data2, data3, { data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7] } }; return guid; } - +private: + friend constexpr bool comparesEqual(const QUuid &lhs, const GUID &rhs) noexcept + { + return comparesEqual(lhs, QUuid(rhs)); + } +public: +/* To prevent a meta-type creation ambiguity on Windows, we put comparison + macros under NOT QT_CORE_REMOVED_SINCE(6, 8) part. */ +#if QT_CORE_REMOVED_SINCE(6, 8) constexpr bool operator==(const GUID &guid) const noexcept { - return *this == QUuid(guid); + return comparesEqual(*this, QUuid(guid)); } constexpr bool operator!=(const GUID &guid) const noexcept { - return !(*this == guid); + return !operator==(guid); } +#else + Q_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE(QUuid, GUID) +#endif // !QT_CORE_REMOVED_SINCE(6, 8) #endif +public: static QUuid createUuid(); #ifndef QT_BOOTSTRAPPED static QUuid createUuidV3(const QUuid &ns, const QByteArray &baseData); @@ -291,11 +336,6 @@ constexpr quint128 QUuid::toUInt128(QSysInfo::Endian order) const noexcept } #endif -inline bool operator<=(const QUuid &lhs, const QUuid &rhs) noexcept -{ return !(rhs < lhs); } -inline bool operator>=(const QUuid &lhs, const QUuid &rhs) noexcept -{ return !(lhs < rhs); } - #if defined(Q_QDOC) // provide fake declarations of qXXXEndian() functions, so that qDoc could // distinguish them from the general template diff --git a/tests/auto/corelib/plugin/quuid/test/CMakeLists.txt b/tests/auto/corelib/plugin/quuid/test/CMakeLists.txt index 1e1e820b14..ec6c1979f7 100644 --- a/tests/auto/corelib/plugin/quuid/test/CMakeLists.txt +++ b/tests/auto/corelib/plugin/quuid/test/CMakeLists.txt @@ -9,6 +9,8 @@ qt_internal_add_test(tst_quuid OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../" SOURCES ../tst_quuid.cpp + LIBRARIES + Qt::TestPrivate ) ## Scopes: diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index c5ce490b61..08a5b826e9 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -3,6 +3,7 @@ #include +#include #if QT_CONFIG(process) #include #endif @@ -17,6 +18,7 @@ class tst_QUuid : public QObject private slots: void initTestCase(); + void compareCompiles(); void fromChar(); void toString(); void fromString_data(); @@ -89,20 +91,28 @@ void tst_QUuid::initTestCase() uuidD = QUuid(0x21f7f8de, 0x8051, 0x5b89, 0x86, 0x80, 0x01, 0x95, 0xef, 0x79, 0x8b, 0x6a); } +void tst_QUuid::compareCompiles() +{ + QTestPrivate::testAllComparisonOperatorsCompile(); +#if defined(Q_OS_WIN) + QTestPrivate::testEqualityOperatorsCompile(); +#endif +} + void tst_QUuid::fromChar() { - QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); - QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); - QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5")); - QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5")); - QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c")); - QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34")); - QCOMPARE(QUuid(), QUuid("fc69b59e-cc34-")); - QCOMPARE(QUuid(), QUuid("fc69b59e-cc34")); - QCOMPARE(QUuid(), QUuid("cc34")); - QCOMPARE(QUuid(), QUuid(nullptr)); + QT_TEST_EQUALITY_OPS(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"), true); + QT_TEST_EQUALITY_OPS(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5}"), true); + QT_TEST_EQUALITY_OPS(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5"), true); + QT_TEST_EQUALITY_OPS(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5"), true); + QT_TEST_EQUALITY_OPS(QUuid(), QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c"), true); + QT_TEST_EQUALITY_OPS(QUuid(), QUuid("{fc69b59e-cc34"), true); + QT_TEST_EQUALITY_OPS(QUuid(), QUuid("fc69b59e-cc34-"), true); + QT_TEST_EQUALITY_OPS(QUuid(), QUuid("fc69b59e-cc34"), true); + QT_TEST_EQUALITY_OPS(QUuid(), QUuid("cc34"), true); + QT_TEST_EQUALITY_OPS(QUuid(), QUuid(nullptr), true); - QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); + QT_TEST_EQUALITY_OPS(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")), true); } void tst_QUuid::toString() @@ -162,21 +172,21 @@ void tst_QUuid::fromString() const auto inputL1 = input.toLatin1(); const auto inputU8 = input.toUtf8(); - QCOMPARE(expected, QUuid(input)); - QCOMPARE(expected, QUuid(inputU8)); - QCOMPARE(expected, QUuid(inputL1)); + QT_TEST_EQUALITY_OPS(expected, QUuid(input), true); + QT_TEST_EQUALITY_OPS(expected, QUuid(inputU8), true); + QT_TEST_EQUALITY_OPS(expected, QUuid(inputL1), true); - QCOMPARE(expected, QUuid::fromString(input)); + QT_TEST_EQUALITY_OPS(expected, QUuid::fromString(input), true); // for QLatin1String, construct one whose data() is not NUL-terminated: const auto longerInputL1 = inputL1 + '5'; // the '5' makes the premature end check incorrectly succeed const auto inputL1S = QLatin1String(longerInputL1.data(), inputL1.size()); - QCOMPARE(expected, QUuid::fromString(inputL1S)); + QT_TEST_EQUALITY_OPS(expected, QUuid::fromString(inputL1S), true); // for QUtf8StringView, too: const auto longerInputU8 = inputU8 + '5'; // the '5' makes the premature end check incorrectly succeed const auto inputU8S = QUtf8StringView(longerInputU8.data(), inputU8.size()); - QCOMPARE(expected, QUuid::fromString(inputU8S)); + QT_TEST_EQUALITY_OPS(expected, QUuid::fromString(inputU8S), true); } void tst_QUuid::toByteArray() @@ -196,27 +206,30 @@ void tst_QUuid::toByteArray() void tst_QUuid::fromByteArray() { - QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); - QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); - QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); - QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); - QCOMPARE(QUuid(), QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c"))); + QT_TEST_EQUALITY_OPS(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")), true); + QT_TEST_EQUALITY_OPS(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5}")), true); + QT_TEST_EQUALITY_OPS(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5")), true); + QT_TEST_EQUALITY_OPS(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5")), true); + QT_TEST_EQUALITY_OPS(QUuid(), QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c")), true); - QCOMPARE(uuidB, QUuid(QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); + QT_TEST_EQUALITY_OPS(uuidB, QUuid(QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")), true); } void tst_QUuid::toRfc4122() { QCOMPARE(uuidA.toRfc4122(), QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5")); - QCOMPARE(uuidB.toRfc4122(), QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b")); } void tst_QUuid::fromRfc4122() { - QCOMPARE(uuidA, QUuid::fromRfc4122(QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5"))); + QT_TEST_EQUALITY_OPS( + uuidA, + QUuid::fromRfc4122(QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5")), true); - QCOMPARE(uuidB, QUuid::fromRfc4122(QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b"))); + QT_TEST_EQUALITY_OPS( + uuidB, QUuid::fromRfc4122(QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b")), + true); } void tst_QUuid::id128() @@ -234,15 +247,15 @@ void tst_QUuid::id128() 0xba, 0x47, 0xec, 0x7e, 0x99, 0x03, 0x9a, 0x7b, } }; - QCOMPARE(QUuid(bytesA), uuidA); - QCOMPARE(QUuid(bytesB), uuidB); + QT_TEST_EQUALITY_OPS(QUuid(bytesA), uuidA, true); + QT_TEST_EQUALITY_OPS(QUuid(bytesB), uuidB, true); QVERIFY(memcmp(uuidA.toBytes().data, bytesA.data, sizeof(QUuid::Id128Bytes)) == 0); QVERIFY(memcmp(uuidB.toBytes().data, bytesB.data, sizeof(QUuid::Id128Bytes)) == 0); QUuid::Id128Bytes leBytesA = {}; for (int i = 0; i < 16; i++) leBytesA.data[15 - i] = bytesA.data[i]; - QCOMPARE(QUuid(leBytesA, QSysInfo::LittleEndian), uuidA); + QT_TEST_EQUALITY_OPS(QUuid(leBytesA, QSysInfo::LittleEndian), uuidA, true); QVERIFY(memcmp(uuidA.toBytes(QSysInfo::LittleEndian).data, leBytesA.data, sizeof(leBytesA)) == 0); // check the new q{To,From}{Big,Little}Endian() overloads @@ -271,16 +284,16 @@ void tst_QUuid::uint128() constexpr QUuid uuid = QUuid::fromUInt128(be); static_assert(uuid.toUInt128() == be, "Round-trip through QUuid failed"); - QCOMPARE(uuid, uuidA); + QT_TEST_EQUALITY_OPS(uuid, uuidA, true); QCOMPARE(uuid.toUInt128(), be); quint128 le = qFromBigEndian(be); QCOMPARE(uuid.toUInt128(QSysInfo::LittleEndian), le); - QCOMPARE(QUuid::fromUInt128(le, QSysInfo::LittleEndian), uuidA); + QT_TEST_EQUALITY_OPS(QUuid::fromUInt128(le, QSysInfo::LittleEndian), uuidA, true); QUuid::Id128Bytes bytes = { .data128 = { qToBigEndian(u) } }; QUuid uuid2(bytes); - QCOMPARE(uuid2, uuid); + QT_TEST_EQUALITY_OPS(uuid2, uuid, true); // verify that toBytes() and toUInt128() provide bytewise similar result constexpr quint128 val = uuid.toUInt128(); @@ -294,11 +307,11 @@ void tst_QUuid::uint128() void tst_QUuid::createUuidV3OrV5() { //"www.widgets.com" is also from RFC4122 - QCOMPARE(uuidC, QUuid::createUuidV3(uuidNS, QByteArray("www.widgets.com"))); - QCOMPARE(uuidC, QUuid::createUuidV3(uuidNS, QString("www.widgets.com"))); + QT_TEST_EQUALITY_OPS(uuidC, QUuid::createUuidV3(uuidNS, QByteArray("www.widgets.com")), true); + QT_TEST_EQUALITY_OPS(uuidC, QUuid::createUuidV3(uuidNS, QString("www.widgets.com")), true); - QCOMPARE(uuidD, QUuid::createUuidV5(uuidNS, QByteArray("www.widgets.com"))); - QCOMPARE(uuidD, QUuid::createUuidV5(uuidNS, QString("www.widgets.com"))); + QT_TEST_EQUALITY_OPS(uuidD, QUuid::createUuidV5(uuidNS, QByteArray("www.widgets.com")), true); + QT_TEST_EQUALITY_OPS(uuidD, QUuid::createUuidV5(uuidNS, QString("www.widgets.com")), true); } void tst_QUuid::check_QDataStream() @@ -314,7 +327,7 @@ void tst_QUuid::check_QDataStream() QDataStream in(&ar,QIODevice::ReadOnly); in.setByteOrder(QDataStream::BigEndian); in >> tmp; - QCOMPARE(uuidA, tmp); + QT_TEST_EQUALITY_OPS(uuidA, tmp, true); } { QDataStream out(&ar,QIODevice::WriteOnly); @@ -325,7 +338,7 @@ void tst_QUuid::check_QDataStream() QDataStream in(&ar,QIODevice::ReadOnly); in.setByteOrder(QDataStream::LittleEndian); in >> tmp; - QCOMPARE(uuidA, tmp); + QT_TEST_EQUALITY_OPS(uuidA, tmp, true); } } @@ -340,14 +353,14 @@ void tst_QUuid::isNull() void tst_QUuid::equal() { - QVERIFY( !(uuidA == uuidB) ); + QT_TEST_EQUALITY_OPS(uuidA, uuidB, false); QUuid copy(uuidA); - QCOMPARE(uuidA, copy); + QT_TEST_EQUALITY_OPS(uuidA, copy, true); QUuid assigned; assigned = uuidA; - QCOMPARE(uuidA, assigned); + QT_TEST_EQUALITY_OPS(uuidA, assigned, true); } @@ -384,10 +397,12 @@ void tst_QUuid::less() QVERIFY( uuidB <= uuidA); QVERIFY(!(uuidA < uuidB) ); QVERIFY(!(uuidA <= uuidB)); + QT_TEST_ALL_COMPARISON_OPS(uuidB, uuidA, Qt::strong_ordering::less); QUuid null_uuid; QVERIFY(null_uuid < uuidA); // Null uuid is always less than a valid one QVERIFY(null_uuid <= uuidA); + QT_TEST_ALL_COMPARISON_OPS(null_uuid, uuidA, Qt::strong_ordering::less); QVERIFY(null_uuid <= null_uuid); QVERIFY(uuidA <= uuidA); @@ -400,6 +415,7 @@ void tst_QUuid::more() QVERIFY( uuidA >= uuidB); QVERIFY(!(uuidB > uuidA)); QVERIFY(!(uuidB >= uuidA)); + QT_TEST_ALL_COMPARISON_OPS(uuidA, uuidB, Qt::strong_ordering::greater); QUuid null_uuid; QVERIFY(!(null_uuid > uuidA)); // Null uuid is always less than a valid one @@ -407,6 +423,7 @@ void tst_QUuid::more() QVERIFY(null_uuid >= null_uuid); QVERIFY(uuidA >= uuidA); + QT_TEST_ALL_COMPARISON_OPS(uuidA, uuidA, Qt::strong_ordering::equal); } @@ -512,7 +529,7 @@ void tst_QUuid::qvariant() QUuid uuid2 = v.value(); QVERIFY(!uuid2.isNull()); - QCOMPARE(uuid, uuid2); + QT_TEST_EQUALITY_OPS(uuid, uuid2, true); } void tst_QUuid::qvariant_conversion() @@ -544,7 +561,7 @@ void tst_QUuid::qvariant_conversion() QVariant sv = QVariant::fromValue(uuid.toByteArray()); QCOMPARE(sv.metaType(), QMetaType(QMetaType::QByteArray)); QVERIFY(sv.canConvert()); - QCOMPARE(sv.value(), uuid); + QT_TEST_EQUALITY_OPS(sv.value(), uuid, true); } }