Add test for qHash(QString) / qHash(QStringRef)

Two equal strings / stringrefs must return the same hash.

Change-Id: I2af9a11ab721ca25f4039048a7e5f260e6ff0148
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Giuseppe D'Angelo 2012-04-04 20:44:33 +01:00 committed by Qt by Nokia
parent 4bdb7a0780
commit 10747da77d

View File

@ -51,6 +51,7 @@
#include <qlocale.h>
#include <locale.h>
#include <qhash.h>
Q_DECLARE_METATYPE(qlonglong)
@ -4929,6 +4930,13 @@ void tst_QString::compare()
QCOMPARE(sign(QStringRef::compare(r1, r2, Qt::CaseSensitive)), csr);
QCOMPARE(sign(QStringRef::compare(r1, r2, Qt::CaseInsensitive)), cir);
if (csr == 0) {
QVERIFY(qHash(s1) == qHash(s2));
QVERIFY(qHash(s1) == qHash(r2));
QVERIFY(qHash(r1) == qHash(s2));
QVERIFY(qHash(r1) == qHash(r2));
}
if (!cir) {
QCOMPARE(s1.toCaseFolded(), s2.toCaseFolded());
}