From c0b6e16ffa0edf0ed76cfdfeb71ec3aae99c98dd Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 5 Aug 2016 10:04:11 +0300 Subject: tests/auto/corelib/global: clean up - port Q_FOREACH to C++11 range-for (except in the Q_FOREACH tests :) - port uses of inefficient QLists to QVector - include QTest, not QtTest Fixes some errors pointed out by my tree's static checks. Change-Id: Ibb21a280537af74dda5679ec7c75d59477b6de55 Reviewed-by: David Faure --- tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 16 ++++++++-------- tests/auto/corelib/global/qlogging/tst_qlogging.cpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index bb4d1f4bf2..9b92a4ff15 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -81,7 +81,7 @@ void tst_QGlobal::qIsNull() void tst_QGlobal::for_each() { - QList list; + QVector list; list << 0 << 1 << 2 << 3 << 4 << 5; int counter = 0; @@ -100,7 +100,7 @@ void tst_QGlobal::for_each() // check whether we can pass a constructor as container argument counter = 0; - foreach (int i, QList(list)) { + foreach (int i, QVector(list)) { QCOMPARE(i, counter++); } QCOMPARE(counter, list.count()); @@ -589,7 +589,7 @@ Q_DECLARE_METATYPE(stringpair) void tst_QGlobal::qprintable() { - QFETCH(QList, localestrings); + QFETCH(QVector, localestrings); QFETCH(int, utf8index); QVERIFY(utf8index >= 0 && utf8index < localestrings.count()); @@ -600,21 +600,21 @@ void tst_QGlobal::qprintable() QString string = QString::fromUtf8(utf8string); - foreach (const stringpair &pair, localestrings) { + for (const stringpair &pair : qAsConst(localestrings)) { QTextCodec *codec = QTextCodec::codecForName(pair.first); if (!codec) continue; QTextCodec::setCodecForLocale(codec); // test qPrintable() QVERIFY(qstrcmp(qPrintable(string), pair.second) == 0); - foreach (const stringpair &pair2, localestrings) { + for (const stringpair &pair2 : qAsConst(localestrings)) { if (pair2.second == pair.second) continue; QVERIFY(qstrcmp(qPrintable(string), pair2.second) != 0); } // test qUtf8Printable() QVERIFY(qstrcmp(qUtf8Printable(string), utf8string) == 0); - foreach (const stringpair &pair2, localestrings) { + for (const stringpair &pair2 : qAsConst(localestrings)) { if (qstrcmp(pair2.second, utf8string) == 0) continue; QVERIFY(qstrcmp(qUtf8Printable(string), pair2.second) != 0); @@ -626,7 +626,7 @@ void tst_QGlobal::qprintable() void tst_QGlobal::qprintable_data() { - QTest::addColumn >("localestrings"); + QTest::addColumn >("localestrings"); QTest::addColumn("utf8index"); // index of utf8 string // Unicode: HIRAGANA LETTER A, I, U, E, O (U+3442, U+3444, U+3446, U+3448, U+344a) @@ -634,7 +634,7 @@ void tst_QGlobal::qprintable_data() static const char *const eucjpstring = "\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa"; static const char *const sjisstring = "\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8"; - QList japanesestrings; + QVector japanesestrings; japanesestrings << stringpair("UTF-8", utf8string) << stringpair("EUC-JP", eucjpstring) << stringpair("Shift_JIS", sjisstring); diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index ce227a6c8b..c2d7338042 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include class tst_qmessagehandler : public QObject { @@ -841,7 +841,7 @@ void tst_qmessagehandler::qMessagePattern() QVERIFY(!output.isEmpty()); QCOMPARE(!output.contains("QT_MESSAGE_PATTERN"), valid); - foreach (const QByteArray &e, expected) { + for (const QByteArray &e : qAsConst(expected)) { if (!output.contains(e)) { qDebug() << output; qDebug() << "expected: " << e; -- cgit v1.2.3