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

View File

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

View File

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

View File

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