test: migrate QLibrary test to QRegularExpression

This is part of the migration of qtbase from QRexExp to
QRegularExpression.

Task-number: QTBUG-72587
Change-Id: I60ffa6df83aaf520730cfbb1dd3f18a2d2e19977
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Samuel Gaist 2019-06-10 08:52:37 +02:00
parent c0f0e94db5
commit fd58792ef8
1 changed files with 5 additions and 3 deletions

View File

@ -30,7 +30,7 @@
#include <QtTest/QtTest>
#include <qdir.h>
#include <qlibrary.h>
#include <QtCore/QRegExp>
#include <QtCore/QRegularExpression>
// Helper macros to let us know if some suffixes and prefixes are valid
@ -414,10 +414,12 @@ void tst_QLibrary::errorString()
QFAIL(qPrintable(QString("Unknown operation: %1").arg(operation)));
break;
}
QRegExp re(errorString);
#if QT_CONFIG(regularexpression)
QRegularExpression re(QRegularExpression::anchoredPattern(errorString));
QString libErrorString = lib.errorString();
QVERIFY2(re.match(libErrorString).hasMatch(), qPrintable(libErrorString));
#endif
QVERIFY(!lib.isLoaded() || lib.unload());
QVERIFY2(re.exactMatch(libErrorString), qPrintable(libErrorString));
QCOMPARE(ok, success);
}