tst_QHashFunctions: extend the consistency() test with mixed-signedness int types

Looking good, because all signed integral qHash overloads are implemented
by casting to the unsigned type before hashing.

Pick-to: 6.5
Change-Id: I8372eb6d4a57b40c2371db58d1b5aeabe9a3951a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7d1f29df795e3e1635204b656b368582ed6942ea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 68deb79e2d9a26ebfd97b2b2887b31e65bf12991)
This commit is contained in:
Marc Mutz 2023-08-15 13:22:04 +02:00 committed by Qt Cherry-pick Bot
parent 6763644c3f
commit 155f97a0a2

View File

@ -104,6 +104,25 @@ void tst_QHashFunctions::consistent()
QCOMPARE(h32, h64); QCOMPARE(h32, h64);
} }
// mixed signed/unsigned
{
const auto hu8 = qHash(quint8(42), seed);
const auto hs8 = qHash(qint8(42), seed);
QCOMPARE(hu8, hs8);
const auto hu16 = qHash(quint16(4242), seed);
const auto hs16 = qHash(qint16(4242), seed);
QCOMPARE(hu16, hs16);
const auto hu32 = qHash(quint32(4242'4242), seed);
const auto hs32 = qHash(qint32(4242'4242), seed);
QCOMPARE(hu32, hs32);
const auto hu64 = qHash(quint64(4242'424242), seed);
const auto hs64 = qHash(qint64(4242'424242), seed);
QCOMPARE(hu64, hs64);
}
// floats // floats
{ {
const/*expr broken: QTBUG-116079*/ qfloat16 f16 = qfloat16(-42.f); const/*expr broken: QTBUG-116079*/ qfloat16 f16 = qfloat16(-42.f);