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