diff options
author | Samuel Gaist <samuel.gaist@idiap.ch> | 2019-06-10 16:49:19 +0200 |
---|---|---|
committer | Samuel Gaist <samuel.gaist@idiap.ch> | 2019-06-10 16:49:19 +0200 |
commit | 16cc3ea585f26bc403e051f105df677a6da79dd5 (patch) | |
tree | ec27be213d578c9a2674a71469fb3e0bab220281 /tests | |
parent | 605dc42a0faceaaeb100cf538a0655614ed1a8fa (diff) |
test: migrate QNetworkReply test to QRegularExpression
This is part of the migration of qtbase from QRexExp to
QRegularExpression.
Task-number: QTBUG-72587
Change-Id: Ibdd3f63d9069c3f01dfe8431bcc64bde4f2aa569
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/network-settings.h | 4 | ||||
-rw-r--r-- | tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index bf632c9846..77298342af 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -109,8 +109,8 @@ public: static bool compareReplyFtp(QByteArray const& actual) { // output would be e.g. "220 (vsFTPd 2.3.5)\r\n221 Goodbye.\r\n" - QRegExp ftpVersion(QStringLiteral("220 \\(vsFTPd \\d+\\.\\d+.\\d+\\)\\r\\n221 Goodbye.\\r\\n")); - return ftpVersion.exactMatch(actual); + QRegularExpression ftpVersion(QRegularExpression::anchoredPattern(QStringLiteral("220 \\(vsFTPd \\d+\\.\\d+.\\d+\\)\\r\\n221 Goodbye.\\r\\n"))); + return ftpVersion.match(actual).hasMatch(); } static bool hasIPv6() diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index ca870f1cbb..8867e4dbaa 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -34,6 +34,8 @@ #include <QtCore/QEventLoop> #include <QtCore/QFile> #include <QtCore/QRandomGenerator> +#include <QtCore/QRegularExpression> +#include <QtCore/QRegularExpressionMatch> #include <QtCore/QSharedPointer> #include <QtCore/QScopedPointer> #include <QtCore/QTemporaryFile> @@ -7917,9 +7919,10 @@ void tst_QNetworkReply::synchronousAuthenticationCache() "Content-Type: text/plain\r\n" "\r\n" "auth"; - QRegExp rx("Authorization: Basic ([^\r\n]*)\r\n"); - if (rx.indexIn(receivedData) > 0) { - if (QByteArray::fromBase64(rx.cap(1).toLatin1()) == "login:password") { + QRegularExpression rx("Authorization: Basic ([^\r\n]*)\r\n"); + QRegularExpressionMatch match = rx.match(receivedData); + if (match.hasMatch()) { + if (QByteArray::fromBase64(match.captured(1).toLatin1()) == "login:password") { dataToTransmit = "HTTP/1.0 200 OK\r\n" "Content-Type: text/plain\r\n" |