From ca38ac77313cd4ad1436fae28ec43dc219ea341d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 15 Sep 2023 12:20:51 +0200 Subject: 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 --- tests/auto/corelib/plugin/quuid/tst_quuid.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index b637596536..5872993b2b 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -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) } }; -- cgit v1.2.3