summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-09-04 19:35:21 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-09-20 13:14:43 +0000
commitdba42c925db368aa958c38c6a3481f18a57bd71f (patch)
tree12c3adc08ae21931fadeccf21a393c1a612c5045 /tests
parenta0499c7c3ed5d93d219199184da16e508dd84a36 (diff)
downloadqtxmlpatterns-dba42c925db368aa958c38c6a3481f18a57bd71f.tar.gz
Eradicate Q_FOREACH loops and mark the module as Q_FOREACH-free
In network-settings.h, replaced a few QList of static size with C arrays. Change-Id: Iac32e68f76e3c53fa03b6a2943e1dfb5adbe6fad Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/network-settings.h52
-rw-r--r--tests/auto/patternistexamples/tst_patternistexamples.cpp4
-rw-r--r--tests/auto/qabstractxmlnodemodel/LoadingModel.cpp2
-rw-r--r--tests/auto/qxmlquery/tst_qxmlquery.cpp4
-rw-r--r--tests/auto/xmlpatterns/tst_xmlpatterns.cpp5
5 files changed, 35 insertions, 32 deletions
diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h
index f02ed86..569069a 100644
--- a/tests/auto/network-settings.h
+++ b/tests/auto/network-settings.h
@@ -65,21 +65,22 @@ public:
static bool compareReplyIMAP(QByteArray const& actual)
{
- QList<QByteArray> expected;
+ const QByteArray expected[] = {
- // Mandriva; old test server
- expected << QByteArray( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] " )
+ // Mandriva; old test server
+ QByteArray( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] " )
.append(QtNetworkSettings::serverName().toLatin1())
- .append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n");
+ .append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"),
- // Ubuntu 10.04; new test server
- expected << QByteArray( "* OK " )
+ // Ubuntu 10.04; new test server
+ QByteArray( "* OK " )
.append(QtNetworkSettings::serverLocalName().toLatin1())
- .append(" Cyrus IMAP4 v2.2.13-Debian-2.2.13-19 server ready\r\n");
+ .append(" Cyrus IMAP4 v2.2.13-Debian-2.2.13-19 server ready\r\n"),
- // Feel free to add more as needed
+ // Feel free to add more as needed
+ };
- Q_FOREACH (QByteArray const& ba, expected) {
+ for (const QByteArray &ba : expected) {
if (ba == actual) {
return true;
}
@@ -90,21 +91,22 @@ public:
static bool compareReplyIMAPSSL(QByteArray const& actual)
{
- QList<QByteArray> expected;
+ const QByteArray expected[] = {
- // Mandriva; old test server
- expected << QByteArray( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=PLAIN SASL-IR] " )
+ // Mandriva; old test server
+ QByteArray( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=PLAIN SASL-IR] " )
.append(QtNetworkSettings::serverName().toLatin1())
- .append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n");
+ .append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"),
- // Ubuntu 10.04; new test server
- expected << QByteArray( "* OK " )
+ // Ubuntu 10.04; new test server
+ QByteArray( "* OK " )
.append(QtNetworkSettings::serverLocalName().toLatin1())
- .append(" Cyrus IMAP4 v2.2.13-Debian-2.2.13-19 server ready\r\n");
+ .append(" Cyrus IMAP4 v2.2.13-Debian-2.2.13-19 server ready\r\n"),
- // Feel free to add more as needed
+ // Feel free to add more as needed
+ };
- Q_FOREACH (QByteArray const& ba, expected) {
+ for (const QByteArray &ba : expected) {
if (ba == actual) {
return true;
}
@@ -115,14 +117,16 @@ public:
static bool compareReplyFtp(QByteArray const& actual)
{
- QList<QByteArray> expected;
+ const QByteArray expected[] = {
- // A few different vsFTPd versions.
- // Feel free to add more as needed
- expected << QByteArray( "220 (vsFTPd 2.0.5)\r\n221 Goodbye.\r\n" );
- expected << QByteArray( "220 (vsFTPd 2.2.2)\r\n221 Goodbye.\r\n" );
+ // A few different vsFTPd versions.
+ // Feel free to add more as needed
+ QByteArray( "220 (vsFTPd 2.0.5)\r\n221 Goodbye.\r\n" ),
+ QByteArray( "220 (vsFTPd 2.2.2)\r\n221 Goodbye.\r\n" ),
- Q_FOREACH (QByteArray const& ba, expected) {
+ };
+
+ for (const QByteArray &ba : expected) {
if (ba == actual) {
return true;
}
diff --git a/tests/auto/patternistexamples/tst_patternistexamples.cpp b/tests/auto/patternistexamples/tst_patternistexamples.cpp
index 3aed232..6abeb04 100644
--- a/tests/auto/patternistexamples/tst_patternistexamples.cpp
+++ b/tests/auto/patternistexamples/tst_patternistexamples.cpp
@@ -142,7 +142,7 @@ void tst_PatternistExamples::checkQueries_data() const
QCOMPARE(queryExamples.count(), int(XQueryFileCount));
- foreach(QString q, queryExamples)
+ for (const QString &q : queryExamples)
QTest::newRow(q.toLocal8Bit().constData()) << q;
}
@@ -183,7 +183,7 @@ void tst_PatternistExamples::checkXMLFiles_data() const
QCOMPARE(xmlFiles.count(), int(XMLFileCount));
- foreach(QString q, xmlFiles)
+ for (const QString &q : xmlFiles)
QTest::newRow(q.toLocal8Bit().constData()) << q;
}
diff --git a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp
index 76608f4..07a702b 100644
--- a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp
+++ b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp
@@ -169,7 +169,7 @@ QXmlNodeModelIndex LoadingModel::nextFromSimpleAxis(QAbstractXmlNodeModel::Simpl
QVector<QXmlNodeModelIndex> LoadingModel::attributes(const QXmlNodeModelIndex &ni) const
{
QVector<QXmlNodeModelIndex> retval;
- foreach(const Node *n, toInternal(ni)->attributes)
+ for (const Node *n : toInternal(ni)->attributes)
retval.append(createIndex(n));
return retval;
diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp
index 1754d7d..a7f3e8b 100644
--- a/tests/auto/qxmlquery/tst_qxmlquery.cpp
+++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp
@@ -977,8 +977,8 @@ void tst_QXmlQuery::evaluateToReceiver_data() const
{
QTest::addColumn<QString>("inputQuery");
- foreach (QString const& query, queries())
- {
+ const auto queries_ = queries();
+ for (QString const& query : queries_) {
/* This outputs a URI specific to the environment, so we can't use it for this
* particular test. */
if (query != QLatin1String("staticBaseURI.xq"))
diff --git a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
index 1a08a66..294e5fc 100644
--- a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
+++ b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
@@ -1028,7 +1028,7 @@ void tst_XmlPatterns::xsltSupport_data() const
*/
QString tst_XmlPatterns::filterStderr(const QString &in)
{
- static QList<QRegExp> irrelevant = QList<QRegExp>()
+ static const QList<QRegExp> irrelevant = QList<QRegExp>()
// specific filenames
<< QRegExp(QLatin1String("file:\\/\\/.*(\\.xq|\\.gccxml|\\.xml|\\.xsl|-)(,|:)"))
@@ -1040,9 +1040,8 @@ QString tst_XmlPatterns::filterStderr(const QString &in)
;
QString out = in;
- foreach (const QRegExp& rx, irrelevant) {
+ for (const QRegExp& rx : irrelevant)
out = out.remove(rx);
- }
return out;
}