From 34237d62f6023061564ae5ee3955bad0e9881fd3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 25 Jul 2014 14:32:37 +0200 Subject: [PATCH] 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 --- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 map{{1, "hello"}, {2, "initializer_list"}}; + QMap 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 stdm = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; + // QCOMPARE(stdm.size(), 2UL); + // QCOMPARE(stdm[1], QString("bar")); + QMultiMap multiMap{{"il", 1}, {"il", 2}, {"il", 3}}; QCOMPARE(multiMap.count(), 3); QList values = multiMap.values("il");