Migrate all uses of of QRegEXp in tests/

This commit is contained in:
nirvn 2021-07-15 11:48:11 +07:00
parent adb5362463
commit 9d64e14209
4 changed files with 13 additions and 8 deletions

View File

@ -52,6 +52,7 @@
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QStandardItemModel>
#include <QRegularExpression>
#include "modeltest.h"
#include "dynamictreemodel.h"
@ -116,7 +117,7 @@ void tst_ModelTest::stringListModel()
model.setStringList( QStringList() << "a" << "e" << "plop" << "b" << "c" );
proxy.setDynamicSortFilter( true );
proxy.setFilterRegExp( QRegExp( "[^b]" ) );
proxy.setFilterRegularExpression( QRegularExpression( "[^b]" ) );
}
void tst_ModelTest::treeWidgetModel()

View File

@ -19,6 +19,7 @@
#include <QSplashScreen>
#include <QString>
#include <QStringList>
#include <QRegularExpression>
#include "qgisapp.h"
#include "qgsapplication.h"
@ -179,9 +180,9 @@ void TestQgisAppClipboard::copyToText()
// just test coordinates as integers - that's enough to verify that reprojection has occurred
// and helps avoid rounding issues
QRegExp regex( "\\[([-\\d.]+),([-\\d.]+)\\]" );
( void )regex.indexIn( result );
QStringList list = regex.capturedTexts();
QRegularExpression regex( "\\[([-\\d.]+),([-\\d.]+)\\]" );
QRegularExpressionMatch match = regex.match( result );
QStringList list = match.capturedTexts();
QCOMPARE( list.count(), 3 );
int x = std::round( list.at( 1 ).toDouble() );

View File

@ -23,6 +23,8 @@
#include "qgsapplication.h"
#include "qgsvectorlayer.h"
#include <QRegularExpression>
/**
* \ingroup UnitTests
* This is a unit test for OGC utilities
@ -103,9 +105,9 @@ void TestQgsOgcUtils::testGeometryFromGML()
static bool compareElements( QDomElement &element1, QDomElement &element2 )
{
QString tag1 = element1.tagName();
tag1.replace( QRegExp( ".*:" ), QString() );
tag1.replace( QRegularExpression( ".*:" ), QString() );
QString tag2 = element2.tagName();
tag2.replace( QRegExp( ".*:" ), QString() );
tag2.replace( QRegularExpression( ".*:" ), QString() );
if ( tag1 != tag2 )
{
qDebug( "Different tag names: %s, %s", tag1.toLatin1().data(), tag2.toLatin1().data() );

View File

@ -21,6 +21,7 @@
#include <QString>
#include <QStringList>
#include <QTextStream>
#include <QRegularExpression>
#include "qgsapplication.h"
#include "qgsdatasourceuri.h"
@ -272,8 +273,8 @@ void TestQgsWcsPublicServers::test()
QStringList myServerLog;
myServerLog << "server:" + serverUrl;
QString myServerDirName = serverUrl;
myServerDirName.replace( QRegExp( "[:/]+" ), QStringLiteral( "." ) );
myServerDirName.remove( QRegExp( "\\.$" ) );
myServerDirName.replace( QRegularExpression( "[:/]+" ), QStringLiteral( "." ) );
myServerDirName.remove( QRegularExpression( "\\.$" ) );
QgsDebugMsg( "myServerDirName = " + myServerDirName );
QDir myServerDir( mCacheDir.absolutePath() + '/' + myServerDirName );