diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-20 13:46:57 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-20 13:49:28 +0100 |
commit | 76c0be34cd4ff4564693162fa7528463e23ce9d8 (patch) | |
tree | f165b7bc319548fb0082365411a871028f92e89e /tests/auto/corelib/tools/qhash/tst_qhash.cpp | |
parent | 27b4fe96b59e9e63d1e570e802c072e9afdfb2d4 (diff) | |
parent | 36cb3f3f655a9090c82de609010cbfb88651a0f3 (diff) |
Merge branch 'dev' into stable
This starts Qt 5.1 release cycle
Conflicts:
src/gui/text/qfontdatabase.cpp
src/gui/text/qharfbuzz_copy_p.h
src/widgets/kernel/qapplication.cpp
src/widgets/kernel/qcoreapplication.cpp
Change-Id: I72fbf83ab3c2206aeea1b089428b0fc2a89bd62b
Diffstat (limited to 'tests/auto/corelib/tools/qhash/tst_qhash.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qhash/tst_qhash.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 6df84e6363..1cbf181286 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -74,6 +74,7 @@ private slots: void const_shared_null(); void twoArguments_qHash(); + void initializerList(); }; struct Foo { @@ -844,7 +845,7 @@ void tst_QHash::iterators() //STL-Style iterators QHash<int, QString>::iterator stlIt = hash.begin(); - for(stlIt = hash.begin(), i = 1; stlIt != hash.end(), i < 100; ++stlIt, ++i) { + for (stlIt = hash.begin(), i = 1; stlIt != hash.end() && i < 100; ++stlIt, ++i) { testMap.insert(i,stlIt.value()); //QVERIFY(stlIt.value() == hash.value( } @@ -869,7 +870,7 @@ void tst_QHash::iterators() //STL-Style const-iterators QHash<int, QString>::const_iterator cstlIt = hash.constBegin(); - for(cstlIt = hash.constBegin(), i = 1; cstlIt != hash.constEnd(), i < 100; ++cstlIt, ++i) { + for (cstlIt = hash.constBegin(), i = 1; cstlIt != hash.constEnd() && i < 100; ++cstlIt, ++i) { testMap.insert(i,cstlIt.value()); //QVERIFY(stlIt.value() == hash.value( } @@ -1300,5 +1301,34 @@ void tst_QHash::twoArguments_qHash() QCOMPARE(wrongqHashOverload, 0); } +void tst_QHash::initializerList() +{ +#ifdef Q_COMPILER_INITIALIZER_LISTS + QHash<int, QString> hash{{1, "hello"}, {2, "initializer_list"}}; + QCOMPARE(hash.count(), 2); + QVERIFY(hash[1] == "hello"); + QVERIFY(hash[2] == "initializer_list"); + + QMultiHash<QString, int> multiHash{{"il", 1}, {"il", 2}, {"il", 3}}; + QCOMPARE(multiHash.count(), 3); + QList<int> values = multiHash.values("il"); + QCOMPARE(values.count(), 3); + + QHash<int, int> emptyHash{}; + QVERIFY(emptyHash.isEmpty()); + + QHash<int, char> emptyPairs{{}, {}}; + QVERIFY(!emptyPairs.isEmpty()); + + QMultiHash<QString, double> emptyMultiHash{}; + QVERIFY(emptyMultiHash.isEmpty()); + + QMultiHash<int, float> emptyPairs2{{}, {}}; + QVERIFY(!emptyPairs2.isEmpty()); +#else + QSKIP("Compiler doesn't support initializer lists"); +#endif +} + QTEST_APPLESS_MAIN(tst_QHash) #include "tst_qhash.moc" |