diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-08-05 10:04:11 +0300 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-08-06 14:49:09 +0000 |
commit | c0b6e16ffa0edf0ed76cfdfeb71ec3aae99c98dd (patch) | |
tree | a01337a47f4860490f819e5a58bf3f799cfebd5c /tests/auto/corelib/global/qglobal | |
parent | 96317570efd959b9bcc0092ad65a3b228a75f5f1 (diff) |
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 <david.faure@kdab.com>
Diffstat (limited to 'tests/auto/corelib/global/qglobal')
-rw-r--r-- | tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 16 |
1 files changed, 8 insertions, 8 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<int> list; + QVector<int> 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<int>(list)) { + foreach (int i, QVector<int>(list)) { QCOMPARE(i, counter++); } QCOMPARE(counter, list.count()); @@ -589,7 +589,7 @@ Q_DECLARE_METATYPE(stringpair) void tst_QGlobal::qprintable() { - QFETCH(QList<stringpair>, localestrings); + QFETCH(QVector<stringpair>, 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<QList<stringpair> >("localestrings"); + QTest::addColumn<QVector<stringpair> >("localestrings"); QTest::addColumn<int>("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<stringpair> japanesestrings; + QVector<stringpair> japanesestrings; japanesestrings << stringpair("UTF-8", utf8string) << stringpair("EUC-JP", eucjpstring) << stringpair("Shift_JIS", sjisstring); |