mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Fix coverity warnings in unit tests
This commit is contained in:
parent
d164f8ff98
commit
09241ea195
@ -137,7 +137,7 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
|
||||
QCOMPARE( sinkParam->defaultFileExtension(), QStringLiteral( "shp" ) ); // before alg is accessible
|
||||
QVERIFY( !sinkParam->algorithm() );
|
||||
QVERIFY( !sinkParam->provider() );
|
||||
addParameter( sinkParam );
|
||||
QVERIFY( addParameter( sinkParam ) );
|
||||
QCOMPARE( sinkParam->defaultFileExtension(), QStringLiteral( "shp" ) );
|
||||
QCOMPARE( sinkParam->algorithm(), this );
|
||||
QVERIFY( !sinkParam->provider() );
|
||||
@ -145,7 +145,7 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
|
||||
// default raster format extension
|
||||
QgsProcessingParameterRasterDestination *rasterParam = new QgsProcessingParameterRasterDestination( "raster" );
|
||||
QCOMPARE( rasterParam->defaultFileExtension(), QStringLiteral( "tif" ) ); // before alg is accessible
|
||||
addParameter( rasterParam );
|
||||
QVERIFY( addParameter( rasterParam ) );
|
||||
QCOMPARE( rasterParam->defaultFileExtension(), QStringLiteral( "tif" ) );
|
||||
|
||||
// should allow parameters with same name but different case (required for grass provider)
|
||||
@ -165,7 +165,7 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
|
||||
QCOMPARE( sinkParam->defaultFileExtension(), QStringLiteral( "shp" ) ); // before alg is accessible
|
||||
QVERIFY( !sinkParam->algorithm() );
|
||||
QVERIFY( !sinkParam->provider() );
|
||||
addParameter( sinkParam );
|
||||
QVERIFY( addParameter( sinkParam ) );
|
||||
QCOMPARE( sinkParam->defaultFileExtension(), QStringLiteral( "xshp" ) );
|
||||
QCOMPARE( sinkParam->algorithm(), this );
|
||||
QCOMPARE( sinkParam->provider(), provider() );
|
||||
@ -173,7 +173,7 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
|
||||
// default raster format extension
|
||||
QgsProcessingParameterRasterDestination *rasterParam = new QgsProcessingParameterRasterDestination( "raster2" );
|
||||
QCOMPARE( rasterParam->defaultFileExtension(), QStringLiteral( "tif" ) ); // before alg is accessible
|
||||
addParameter( rasterParam );
|
||||
QVERIFY( addParameter( rasterParam ) );
|
||||
QCOMPARE( rasterParam->defaultFileExtension(), QStringLiteral( "pcx" ) );
|
||||
}
|
||||
|
||||
@ -1096,7 +1096,7 @@ void TestQgsProcessing::algorithm()
|
||||
QVERIFY( !p->algorithms().empty() );
|
||||
|
||||
QgsProcessingRegistry r;
|
||||
r.addProvider( p );
|
||||
QVERIFY( r.addProvider( p ) );
|
||||
QCOMPARE( r.algorithms().size(), 2 );
|
||||
QVERIFY( r.algorithms().contains( p->algorithm( "alg1" ) ) );
|
||||
QVERIFY( r.algorithms().contains( p->algorithm( "alg2" ) ) );
|
||||
@ -1134,7 +1134,7 @@ void TestQgsProcessing::algorithm()
|
||||
// test that adding a provider to the registry automatically refreshes algorithms (via load)
|
||||
DummyProvider *p3 = new DummyProvider( "p3" );
|
||||
QVERIFY( p3->algorithms().isEmpty() );
|
||||
r.addProvider( p3 );
|
||||
QVERIFY( r.addProvider( p3 ) );
|
||||
QCOMPARE( p3->algorithms().size(), 2 );
|
||||
}
|
||||
|
||||
|
@ -566,8 +566,8 @@ void TestQgsCompositionConverter::isCompositionTemplate()
|
||||
QString templatePath( QStringLiteral( TEST_DATA_DIR ) + "/layouts/2x_template.qpt" );
|
||||
QDomDocument doc( "mydocument" );
|
||||
QFile file( templatePath );
|
||||
file.open( QIODevice::ReadOnly );
|
||||
doc.setContent( &file );
|
||||
QVERIFY( file.open( QIODevice::ReadOnly ) );
|
||||
QVERIFY( doc.setContent( &file ) );
|
||||
file.close();
|
||||
|
||||
QVERIFY( QgsCompositionConverter::isCompositionTemplate( doc ) );
|
||||
@ -579,8 +579,8 @@ void TestQgsCompositionConverter::convertCompositionTemplate()
|
||||
QString templatePath( QStringLiteral( TEST_DATA_DIR ) + "/layouts/2x_template.qpt" );
|
||||
QDomDocument doc( "mydocument" );
|
||||
QFile file( templatePath );
|
||||
file.open( QIODevice::ReadOnly );
|
||||
doc.setContent( &file );
|
||||
QVERIFY( file.open( QIODevice::ReadOnly ) );
|
||||
QVERIFY( doc.setContent( &file ) );
|
||||
file.close();
|
||||
|
||||
QgsProject project;
|
||||
@ -711,8 +711,8 @@ QDomElement TestQgsCompositionConverter::loadComposer( const QString name )
|
||||
QString templatePath( QStringLiteral( TEST_DATA_DIR ) + "/layouts/" + name );
|
||||
QDomDocument doc( "mydocument" );
|
||||
QFile file( templatePath );
|
||||
file.open( QIODevice::ReadOnly );
|
||||
doc.setContent( &file );
|
||||
Q_ASSERT( file.open( QIODevice::ReadOnly ) );
|
||||
Q_ASSERT( doc.setContent( &file ) );
|
||||
file.close();
|
||||
QDomNodeList nodes( doc.elementsByTagName( QStringLiteral( "Composer" ) ) );
|
||||
if ( nodes.length() > 0 )
|
||||
|
@ -132,7 +132,7 @@ void TestQgsProject::testPathResolver()
|
||||
QgsPathResolver tempRel( tmpName );
|
||||
QFileInfo fi( tmpName );
|
||||
QFile testFile( fi.path() + QStringLiteral( "/file1.txt" ) );
|
||||
testFile.open( QIODevice::WriteOnly | QIODevice::Text );
|
||||
QVERIFY( testFile.open( QIODevice::WriteOnly | QIODevice::Text ) );
|
||||
testFile.close();
|
||||
QVERIFY( QFile::exists( fi.path() + QStringLiteral( "/file1.txt" ) ) );
|
||||
QCOMPARE( tempRel.readPath( "file1.txt" ), fi.path() + QStringLiteral( "/file1.txt" ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user