diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-08-22 18:05:45 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-07-27 23:48:29 +0200 |
commit | cc584c59de644195ae0c4f7f99ad428e189df07d (patch) | |
tree | c9762af5a8ecfc44d1c57da1741192c2de35ec79 /tests/auto/corelib/tools/qmap/tst_qmap.cpp | |
parent | 7d7f09d5561a6dec2cb20eb5b0956f11c942e2d8 (diff) |
QMap: add operator+ and - for iterators
We missed the chance of deprecating them in 5.15, so
they'll just add to the pain of porting to 6.0. We
should not keep them around forever, though; QMap isn't
random access and so its iterators should only have
bidirectional APIs.
Pick-to: 6.2
Fixes: QTBUG-95334
Change-Id: I3577f7d25e8ab793722d2f220fd27bc85c622b0d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/corelib/tools/qmap/tst_qmap.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qmap/tst_qmap.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index 3e9a51cf2c..e5bddb5d8d 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -1129,6 +1129,29 @@ void tst_QMap::iterators() QVERIFY(stlIt.value() == testString.arg(i)); QCOMPARE(i, 100); + // Same but exercising deprecated APIs +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + stlIt = map.begin(); + QCOMPARE(stlIt.value(), QLatin1String("Teststring 1")); + + stlIt += 5; + QCOMPARE(stlIt.value(), QLatin1String("Teststring 6")); + + stlIt++; + QCOMPARE(stlIt.value(), QLatin1String("Teststring 7")); + + stlIt = stlIt - 3; + QCOMPARE(stlIt.value(), QLatin1String("Teststring 4")); + + stlIt--; + QCOMPARE(stlIt.value(), QLatin1String("Teststring 3")); + + for(stlIt = map.begin(), i = 1; stlIt != map.end(); ++stlIt, ++i) + QVERIFY(stlIt.value() == testString.arg(i)); + QCOMPARE(i, 100); +QT_WARNING_POP + //STL-Style const-iterators QMap<int, QString>::const_iterator cstlIt = map.constBegin(); @@ -1150,6 +1173,29 @@ void tst_QMap::iterators() QVERIFY(cstlIt.value() == testString.arg(i)); QCOMPARE(i, 100); + // Same but exercising deprecated APIs +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + cstlIt = map.constBegin(); + QCOMPARE(cstlIt.value(), QLatin1String("Teststring 1")); + + cstlIt += 5; + QCOMPARE(cstlIt.value(), QLatin1String("Teststring 6")); + + cstlIt++; + QCOMPARE(cstlIt.value(), QLatin1String("Teststring 7")); + + cstlIt = cstlIt - 3; + QCOMPARE(cstlIt.value(), QLatin1String("Teststring 4")); + + cstlIt--; + QCOMPARE(cstlIt.value(), QLatin1String("Teststring 3")); + + for(cstlIt = map.constBegin(), i = 1; cstlIt != map.constEnd(); ++cstlIt, ++i) + QVERIFY(cstlIt.value() == testString.arg(i)); + QCOMPARE(i, 100); +QT_WARNING_POP + //Java-Style iterators QMapIterator<int, QString> javaIt(map); |