selftests/badxml/tst_badxml: compile with QT_NO_FOREACH
badString(): const'ify the static QList, this is both faster as the compiler doesn't need to check if it has been already initialized, and it means we can use it directly in ranged-for as the method returns const QList&. Drive-by change: don't go the long way around to get a const char*: qPrintable(QString("fail %1").arg(ba)) instead use: QTest::addRow("fail %s", ba.constData()) (thanks to dfaure for pointing it out in review). Task-number: QTBUG-115839 Change-Id: I6e8efa6df47ee94f1d71a63e22ab121647e6bf20 Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
9aeb38650d
commit
f516cf93b4
@ -1,8 +1,6 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
// Copyright (C) 2016 The Qt Company Ltd.
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
|
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
@ -81,9 +79,9 @@ void tst_BadXml::badDataTag_data() const
|
|||||||
{
|
{
|
||||||
QTest::addColumn<bool>("shouldFail");
|
QTest::addColumn<bool>("shouldFail");
|
||||||
|
|
||||||
foreach (char const* str, badStrings()) {
|
for (const QByteArray &ba: badStrings()) {
|
||||||
QTest::newRow(qPrintable(QString("fail %1").arg(str))) << true;
|
QTest::addRow("fail %s", ba.constData()) << true;
|
||||||
QTest::newRow(qPrintable(QString("pass %1").arg(str))) << false;
|
QTest::addRow("pass %s", ba.constData()) << false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,9 +122,8 @@ void tst_BadXml::badMessage_data() const
|
|||||||
QTest::addColumn<QByteArray>("message");
|
QTest::addColumn<QByteArray>("message");
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (QByteArray const& str, badStrings()) {
|
for (const QByteArray &str : badStrings())
|
||||||
QTest::newRow(qPrintable(QString::fromLatin1("string %1").arg(i++))) << str;
|
QTest::newRow(qPrintable(QString::fromLatin1("string %1").arg(i++))) << str;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -134,13 +131,12 @@ void tst_BadXml::badMessage_data() const
|
|||||||
*/
|
*/
|
||||||
QList<QByteArray> const& tst_BadXml::badStrings()
|
QList<QByteArray> const& tst_BadXml::badStrings()
|
||||||
{
|
{
|
||||||
static QList<QByteArray> out;
|
static const QList<QByteArray> out = {
|
||||||
if (out.isEmpty()) {
|
"end cdata ]]> text ]]> more text",
|
||||||
out << "end cdata ]]> text ]]> more text";
|
"quotes \" text\" more text",
|
||||||
out << "quotes \" text\" more text";
|
"xml close > open < tags < text",
|
||||||
out << "xml close > open < tags < text";
|
"all > \" mixed ]]> up > \" in < the ]]> hopes < of triggering \"< ]]> bugs",
|
||||||
out << "all > \" mixed ]]> up > \" in < the ]]> hopes < of triggering \"< ]]> bugs";
|
};
|
||||||
}
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user