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 <sona.kurazyan@qt.io>
This commit is contained in:
Marc Mutz 2022-02-01 09:03:21 +01:00
parent bd891d87af
commit 93be44c9c1
1 changed files with 16 additions and 0 deletions

View File

@ -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<int> i = list;
@ -1103,6 +1104,7 @@ void tst_QLinkedList::iterators() const
}
QVERIFY(sum == 21);
}
#endif
{
int sum = 0;
QLinkedList<int>::const_iterator i = list.begin();
@ -1111,10 +1113,16 @@ void tst_QLinkedList::iterators() const
QVERIFY(sum == 21);
}
{
#ifndef QT_NO_JAVA_STYLE_ITERATORS
QMutableLinkedListIterator<int> 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<int> 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<int> 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<int> i = list;
@ -1205,6 +1220,7 @@ void tst_QLinkedList::iterators() const
while (i.findNext(42))
i.remove();
}
#endif
}
QT_END_NAMESPACE