summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qhashfunctions
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-07-11 12:11:14 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-07-11 20:02:15 +0000
commit6a7bae9a26aac877bceaf2810328064abc71c768 (patch)
treed425e9200d9e7bde071f3e47d3dcfb5d3769527a /tests/auto/corelib/tools/qhashfunctions
parent7c279d779b32eb61987fc7d4f1143a1eaa1a1bde (diff)
QHashFunctions: test for hash equality of null and empty string types
In Qt, null QStrings compare equal to empty ones, so add an explicit check that the corresponding hash values are identical, too. Ditto for QByteArray. Change-Id: I190fc95a765305928d9b6b0e4955433865b6b247 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/tools/qhashfunctions')
-rw-r--r--tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
index bde9433a24..4d61bc393d 100644
--- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
+++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
@@ -45,6 +45,8 @@ class tst_QHashFunctions : public QObject
Q_OBJECT
private Q_SLOTS:
void qhash();
+ void qhash_of_empty_and_null_qstring();
+ void qhash_of_empty_and_null_qbytearray();
void fp_qhash_of_zero_is_zero();
void qthash_data();
void qthash();
@@ -117,6 +119,20 @@ void tst_QHashFunctions::qhash()
}
}
+void tst_QHashFunctions::qhash_of_empty_and_null_qstring()
+{
+ QString null, empty("");
+ QCOMPARE(null, empty);
+ QCOMPARE(qHash(null), qHash(empty));
+}
+
+void tst_QHashFunctions::qhash_of_empty_and_null_qbytearray()
+{
+ QByteArray null, empty("");
+ QCOMPARE(null, empty);
+ QCOMPARE(qHash(null), qHash(empty));
+}
+
void tst_QHashFunctions::fp_qhash_of_zero_is_zero()
{
QCOMPARE(qHash(-0.0f), 0U);