From 66ff3f7fa4cd157d9b79e2fb7fe8cce98c913e08 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 27 Apr 2013 01:02:06 +0200 Subject: Add qt_hash(QStringRef) overload This enables fixing a performance regression compared to Qt 4. Also, add some qt_hash tests. Change-Id: Id830e17dec99fb67e5930c80029ac2233b2f427e Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/tools/qhash/tst_qhash.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 1cbf181286..71428310b8 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -75,6 +75,9 @@ private slots: void const_shared_null(); void twoArguments_qHash(); void initializerList(); + + void qthash_data(); + void qthash(); }; struct Foo { @@ -1330,5 +1333,24 @@ void tst_QHash::initializerList() #endif } +void tst_QHash::qthash_data() +{ + QTest::addColumn("key"); + QTest::addColumn("hash"); + + QTest::newRow("null") << QString() << 0u; + QTest::newRow("empty") << QStringLiteral("") << 0u; + QTest::newRow("abcdef") << QStringLiteral("abcdef") << 108567222u; + QTest::newRow("tqbfjotld") << QStringLiteral("The quick brown fox jumps over the lazy dog") << 140865879u; + QTest::newRow("42") << QStringLiteral("42") << 882u; +} + +void tst_QHash::qthash() +{ + QFETCH(QString, key); + const uint result = qt_hash(key); + QTEST(result, "hash"); +} + QTEST_APPLESS_MAIN(tst_QHash) #include "tst_qhash.moc" -- cgit v1.2.3