From 72c3ae0a832bee8065b2c037a9b11210d9f90da7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2024 10:34:13 +0200 Subject: [PATCH] tst_QHashFunctions: check bool/integral consistency It doesn't work. Pick-to: 6.7 6.5 Task-number: QTBUG-126674 Change-Id: Iefdfdf9071d02f5bc8ea98567a2341f95d6ed460 Reviewed-by: Thiago Macieira (cherry picked from commit 878077de2823c40235237e657c2468e0a6cc2262) Reviewed-by: Qt Cherry-pick Bot --- .../tools/qhashfunctions/tst_qhashfunctions.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp index 4358aa0d1dc..beb3eb36c49 100644 --- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp +++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp @@ -33,6 +33,7 @@ public slots: void init(); private Q_SLOTS: + void boolIntegerConsistency(); void unsignedIntegerConsistency_data(); void unsignedIntegerConsistency(); void signedIntegerConsistency_data(); @@ -94,6 +95,19 @@ void tst_QHashFunctions::init() seed = size_t(seedValue); } +void tst_QHashFunctions::boolIntegerConsistency() +{ + if (seed) QEXPECT_FAIL("", "QTBUG-126674", Continue); + QCOMPARE(qHash(0, seed), qHash(false, seed)); + if (seed) QEXPECT_FAIL("", "QTBUG-126674", Continue); + QCOMPARE(qHash(1, seed), qHash(true, seed)); +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) + // check consistency with pre-6.9 incidental implementation: + QCOMPARE(qHash(true, seed), qHash(int(true)) ^ seed); + QCOMPARE(qHash(false, seed), qHash(int(false)) ^ seed); +#endif +} + template static void addPositiveCommonRows() { QTest::addRow("zero") << T(0);