tst_QUuid: use int128 literals and QCOMPARE support
When the test was written, we didn't have support for either int128 literals or proper QCOMPARE failure printing (QTest::toString()), so the code awkwardly constructed literals from 64-bit ones using arithmetic and QCOMPAREed the high and low 64-bit halves separately. Now that we have added support for both, simplify the test code accordingly. Change-Id: Icdee7bb01f6e4bd3de74233b4fb992b0590ddafd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
ab910e09c7
commit
ca38ac7731
@ -266,19 +266,16 @@ void tst_QUuid::id128()
|
||||
void tst_QUuid::uint128()
|
||||
{
|
||||
#ifdef QT_SUPPORTS_INT128
|
||||
constexpr quint128 u = quint128(Q_UINT64_C(0xfc69b59ecc344436)) << 64
|
||||
| Q_UINT64_C(0xa43cee95d128b8c5); // This is LE
|
||||
constexpr quint128 u = Q_UINT128_C(0xfc69b59e'cc344436'a43cee95'd128b8c5); // This is LE
|
||||
constexpr quint128 be = qToBigEndian(u);
|
||||
constexpr QUuid uuid = QUuid::fromUInt128(be);
|
||||
static_assert(uuid.toUInt128() == be, "Round-trip through QUuid failed");
|
||||
|
||||
QCOMPARE(uuid, uuidA);
|
||||
QCOMPARE(quint64(uuid.toUInt128() >> 64), quint64(be >> 64));
|
||||
QCOMPARE(quint64(uuid.toUInt128()), quint64(be));
|
||||
QCOMPARE(uuid.toUInt128(), be);
|
||||
|
||||
quint128 le = qFromBigEndian(be);
|
||||
QCOMPARE(quint64(uuid.toUInt128(QSysInfo::LittleEndian) >> 64), quint64(le >> 64));
|
||||
QCOMPARE(quint64(uuid.toUInt128(QSysInfo::LittleEndian)), quint64(le));
|
||||
QCOMPARE(uuid.toUInt128(QSysInfo::LittleEndian), le);
|
||||
QCOMPARE(QUuid::fromUInt128(le, QSysInfo::LittleEndian), uuidA);
|
||||
|
||||
QUuid::Id128Bytes bytes = { .data128 = { qToBigEndian(u) } };
|
||||
|
Loading…
x
Reference in New Issue
Block a user