From: Giuseppe D'Angelo Date: Wed, 4 Apr 2012 19:44:33 +0000 (+0100) Subject: Add test for qHash(QString) / qHash(QStringRef) X-Git-Tag: 071012110112~1235^2^2~96 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=10747da77d8df4894eaa7ee256b5bfb68faac635;p=profile%2Fivi%2Fqtbase.git Add test for qHash(QString) / qHash(QStringRef) Two equal strings / stringrefs must return the same hash. Change-Id: I2af9a11ab721ca25f4039048a7e5f260e6ff0148 Reviewed-by: Thiago Macieira --- diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 9739448..dda4c52 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -51,6 +51,7 @@ #include #include +#include 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()); }