QUuid: add missing relational operators
QUuid has ==, !=, <, and >. Add <= and =>, too. Change-Id: I11a0b8028be766e2d48dc7664d935df4d327b3d3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
09c1bd2eb0
commit
1b109967c5
@ -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()
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user