Use built-in C++ foreach iteration in tests

Change-Id: I1e4bf9249ce26c034c676d78cfa16231226da05b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
David Skoland 2020-11-03 11:27:43 +01:00
parent dfec79f5d8
commit 28f7c95e3b
2 changed files with 7 additions and 7 deletions

View File

@ -899,13 +899,13 @@ void tst_QFuture::multipleResults()
QList<int> fasit = QList<int>() << 1 << 2 << 3 << 4;
{
QList<int> results;
foreach(int result, f)
for (int result : qAsConst(f))
results.append(result);
QCOMPARE(results, fasit);
}
{
QList<int> results;
foreach(int result, copy)
for (int result : qAsConst(copy))
results.append(result);
QCOMPARE(results, fasit);
}

View File

@ -518,7 +518,7 @@ void tst_QNetworkCookieJar::rfc6265_data()
QVERIFY(!document.isNull());
QVERIFY(document.isArray());
foreach (const QJsonValue& testCase, document.array()) {
for (const QJsonValue testCase : document.array()) {
QJsonObject testObject = testCase.toObject();
//"test" - the test case name
@ -527,15 +527,15 @@ void tst_QNetworkCookieJar::rfc6265_data()
continue;
//"received" - the cookies received from the server
QJsonArray received = testObject.value("received").toArray();
const QJsonArray received = testObject.value("received").toArray();
QStringList receivedList;
foreach (const QJsonValue& receivedCookie, received)
for (const QJsonValue receivedCookie : received)
receivedList.append(receivedCookie.toString());
//"sent" - the cookies sent back to the server
QJsonArray sent = testObject.value("sent").toArray();
const QJsonArray sent = testObject.value("sent").toArray();
QList<QNetworkCookie> sentList;
foreach (const QJsonValue& sentCookie, sent) {
for (const QJsonValue sentCookie : sent) {
QJsonObject sentCookieObject = sentCookie.toObject();
QNetworkCookie cookie;
cookie.setName(sentCookieObject.value("name").toString().toUtf8());