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 <thiago.macieira@intel.com>
(cherry picked from commit 878077de2823c40235237e657c2468e0a6cc2262)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-06-26 10:34:13 +02:00 committed by Qt Cherry-pick Bot
parent 8dd5bfa591
commit 72c3ae0a83

View File

@ -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 <typename T> static void addPositiveCommonRows()
{
QTest::addRow("zero") << T(0);