diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-04-06 18:33:20 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2017-04-07 08:30:17 +0000 |
commit | 5e93361888e3d2b03e7b6da19517b44e0239fb47 (patch) | |
tree | c9bb62f242f9595d3855ffe08a80d60439774689 /tests | |
parent | e5a2c87dc702d76407510b55a5ad661f7d48353c (diff) |
Add a test for consistency of hash values between QString{,Ref,View}
Change-Id: I64a169fd6c8e2444bfe67e3ecd5375ea7b6a81ee
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp index 1e09da1fe4..a8ea9ccf27 100644 --- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp +++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp @@ -38,6 +38,7 @@ class tst_QHashFunctions : public QObject { Q_OBJECT private Q_SLOTS: + void consistent(); void qhash(); void qhash_of_empty_and_null_qstring(); void qhash_of_empty_and_null_qbytearray(); @@ -50,6 +51,17 @@ private Q_SLOTS: void setGlobalQHashSeed(); }; +void tst_QHashFunctions::consistent() +{ + // QString-like + { + const QString s = QStringLiteral("abcdefghijklmnopqrstuvxyz").repeated(16); + + QCOMPARE(qHash(s), qHash(QStringRef(&s))); + QCOMPARE(qHash(s), qHash(QStringView(s))); + } +} + void tst_QHashFunctions::qhash() { { |