From 7d1f29df795e3e1635204b656b368582ed6942ea Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 15 Aug 2023 13:22:04 +0200 Subject: 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.7 6.6 6.5 Change-Id: I8372eb6d4a57b40c2371db58d1b5aeabe9a3951a Reviewed-by: Thiago Macieira --- .../tools/qhashfunctions/tst_qhashfunctions.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/auto/corelib/tools') diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp index 39f9cdae81..6e3f4a793f 100644 --- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp +++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp @@ -104,6 +104,25 @@ void tst_QHashFunctions::consistent() 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 { const/*expr broken: QTBUG-116079*/ qfloat16 f16 = qfloat16(-42.f); -- cgit v1.2.3