From af437047a2d849d19f8de01b5ecfb685f813d6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Sun, 28 Oct 2012 15:36:11 +0100 Subject: QMap - improve QMap stl-map ctor We can insert directly on the most left-most Node. We always enforce an insert here (unlike the insert call), but that is not a problem since the keys in a std::map are unique. Change-Id: Ib409b90ffc57a5a43dab4a4b08d34f6fdabd057f Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index 9c53563a5c..e64496352c 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -55,6 +55,7 @@ protected: public slots: void init(); private slots: + void ctor(); void count(); void clear(); void beginEnd(); @@ -146,6 +147,30 @@ void tst_QMap::init() MyClass::count = 0; } +void tst_QMap::ctor() +{ + std::map map; + for (int i = 0; i < 100000; ++i) + map.insert(std::pair(i * 3, i * 7)); + + QMap qmap(map); // ctor. + + // Check that we have the same + std::map::iterator j = map.begin(); + QMap::const_iterator i = qmap.constBegin(); + + while (i != qmap.constEnd()) { + QCOMPARE( (*j).first, i.key()); + QCOMPARE( (*j).second, i.value()); + ++i; + ++j; + } + + QCOMPARE( (int) map.size(), qmap.size()); +} + + + void tst_QMap::count() { { -- cgit v1.2.3