From 93be44c9c1c1e97de0d77de209d5c6e2c795d101 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 1 Feb 2022 09:03:21 +0100 Subject: [PATCH] tst_QLinkedList: compile with QT_NO_JAVA_STYLE_ITERATORS Temporarily disable tests of Java-style iteration, as qtbase/1d28fd7a9c4720289f3d41db2ed8e6fcb07d5a30 unconditionally re-enabled QT_NO_JAVA_STYLE_ITERATORS, with no API to disable it, breaking integration. This commit disables the Java-style iterator code whereas the next one reverts this and uses the API introduced in qtbase/1d28fd7a9c4720289f3d41db2ed8e6fcb07d5a30 to re-disable QT_NO_JAVA_STYLE_ITERATORS. Fixes: QTBUG-100359 Pick-to: 6.3 6.2 Change-Id: I41ea0d50d1d94ff57891241cf11645d7450432d0 Reviewed-by: Sona Kurazyan --- .../core5/tools/qlinkedlist/tst_qlinkedlist.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/auto/core5/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/core5/tools/qlinkedlist/tst_qlinkedlist.cpp index 6ba0571..5baf00d 100644 --- a/tests/auto/core5/tools/qlinkedlist/tst_qlinkedlist.cpp +++ b/tests/auto/core5/tools/qlinkedlist/tst_qlinkedlist.cpp @@ -1095,6 +1095,7 @@ void tst_QLinkedList::iterators() const list << 4 << 5 << 6; QVERIFY(!list.isEmpty()); QVERIFY(list.size() == 6); +#ifndef QT_NO_JAVA_STYLE_ITERATORS { int sum = 0; QLinkedListIterator i = list; @@ -1103,6 +1104,7 @@ void tst_QLinkedList::iterators() const } QVERIFY(sum == 21); } +#endif { int sum = 0; QLinkedList::const_iterator i = list.begin(); @@ -1111,10 +1113,16 @@ void tst_QLinkedList::iterators() const QVERIFY(sum == 21); } { +#ifndef QT_NO_JAVA_STYLE_ITERATORS QMutableLinkedListIterator i = list; while (i.hasNext()) i.setValue(2 * i.next()); +#else + for (auto &e : list) + e *= 2; +#endif } +#ifndef QT_NO_JAVA_STYLE_ITERATORS { int sum = 0; QLinkedListIterator i = list; @@ -1123,12 +1131,19 @@ void tst_QLinkedList::iterators() const sum += i.previous(); QVERIFY(sum == 2 * 21); } +#endif { +#ifndef QT_NO_JAVA_STYLE_ITERATORS QMutableLinkedListIterator i = list; i.toBack(); while (i.hasPrevious()) i.setValue(2 * i.previous()); +#else + for (auto &e : list) + e *= 2; +#endif } +#ifndef QT_NO_JAVA_STYLE_ITERATORS { int sum = 0; QLinkedListIterator i = list; @@ -1205,6 +1220,7 @@ void tst_QLinkedList::iterators() const while (i.findNext(42)) i.remove(); } +#endif } QT_END_NAMESPACE