summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-07-25 14:32:37 +0200
committerMarc Mutz <marc.mutz@kdab.com>2014-07-25 14:52:58 +0200
commit34237d62f6023061564ae5ee3955bad0e9881fd3 (patch)
treee92afed85f4bc82f9f3e786cad5cebc0c5149f4d /tests/auto
parent443bc6ab188c5107f8ac0a068dc3bf12b4809355 (diff)
tst_QMap: verify that {}-style initialization drops duplicates
No actual reason for this test, except my curiority. Then again, it's good to have this check, too. Also checks that the last entry in the init_list "wins", which is not how std:: containers work. Change-Id: I4f7d1228f2b90a904b6c3f99e54afcd9970b723e Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/tools/qmap/tst_qmap.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
index 00e669c1d8..c160902268 100644
--- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp
+++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
@@ -1179,11 +1179,16 @@ void tst_QMap::checkMostLeftNode()
void tst_QMap::initializerList()
{
#ifdef Q_COMPILER_INITIALIZER_LISTS
- QMap<int, QString> map{{1, "hello"}, {2, "initializer_list"}};
+ QMap<int, QString> map = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}};
QCOMPARE(map.count(), 2);
QVERIFY(map[1] == "hello");
QVERIFY(map[2] == "initializer_list");
+ // note the difference to std::map:
+ // std::map<int, QString> stdm = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}};
+ // QCOMPARE(stdm.size(), 2UL);
+ // QCOMPARE(stdm[1], QString("bar"));
+
QMultiMap<QString, int> multiMap{{"il", 1}, {"il", 2}, {"il", 3}};
QCOMPARE(multiMap.count(), 3);
QList<int> values = multiMap.values("il");