diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index f23ec5d75c..72f662dc1e 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -846,6 +846,34 @@ bool QUuid::operator>(const QUuid &other) const Q_DECL_NOTHROW return other < *this; } +/*! + \fn bool operator<=(const QUuid &lhs, const QUuid &rhs) + \relates QUuid + \since 5.5 + + Returns \c true if \a lhs has the same \l{Variant field} + {variant field} as \a rhs and is lexicographically + \e{not after} \a rhs. If \a rhs has a + different variant field, the return value is determined by + comparing the two \l{QUuid::Variant} {variants}. + + \sa variant() +*/ + +/*! + \fn bool operator>=(const QUuid &lhs, const QUuid &rhs) + \relates QUuid + \since 5.5 + + Returns \c true if \a lhs has the same \l{Variant field} + {variant field} as \a rhs and is lexicographically + \e{not before} \a rhs. If \a rhs has a + different variant field, the return value is determined by + comparing the two \l{QUuid::Variant} {variants}. + + \sa variant() +*/ + /*! \fn QUuid QUuid::createUuid() diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index 38f3bdfb8b..f004cba77e 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -214,6 +214,11 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QUuid &); Q_CORE_EXPORT uint qHash(const QUuid &uuid, uint seed = 0) Q_DECL_NOTHROW; +inline bool operator<=(const QUuid &lhs, const QUuid &rhs) Q_DECL_NOTHROW +{ return !(rhs < lhs); } +inline bool operator>=(const QUuid &lhs, const QUuid &rhs) Q_DECL_NOTHROW +{ return !(lhs < rhs); } + QT_END_NAMESPACE #endif // QUUID_H diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index 8f37b265f6..f31aed6976 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -260,19 +260,33 @@ void tst_QUuid::generate() void tst_QUuid::less() { - QVERIFY( !(uuidA < uuidB) ); + QVERIFY( uuidB < uuidA); + QVERIFY( uuidB <= uuidA); + QVERIFY(!(uuidA < uuidB) ); + QVERIFY(!(uuidA <= uuidB)); QUuid null_uuid; QVERIFY(null_uuid < uuidA); // Null uuid is always less than a valid one + QVERIFY(null_uuid <= uuidA); + + QVERIFY(null_uuid <= null_uuid); + QVERIFY(uuidA <= uuidA); } void tst_QUuid::more() { - QVERIFY( uuidA > uuidB ); + QVERIFY( uuidA > uuidB); + QVERIFY( uuidA >= uuidB); + QVERIFY(!(uuidB > uuidA)); + QVERIFY(!(uuidB >= uuidA)); QUuid null_uuid; - QVERIFY( !(null_uuid > uuidA) ); // Null uuid is always less than a valid one + QVERIFY(!(null_uuid > uuidA)); // Null uuid is always less than a valid one + QVERIFY(!(null_uuid >= uuidA)); + + QVERIFY(null_uuid >= null_uuid); + QVERIFY(uuidA >= uuidA); }