diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-08-15 13:22:04 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2024-01-09 08:27:42 +0100 |
commit | 7d1f29df795e3e1635204b656b368582ed6942ea (patch) | |
tree | 5b35fd431de645eb50b440fbff4cd49d4457c5e4 /tests/auto/corelib | |
parent | 75ac9adeda41194e1733c69b3176fc2a368a369e (diff) |
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 <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
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); |