Skip to content
Permalink
Browse files

Fix coverity warnings in unit tests

  • Loading branch information
nyalldawson committed Apr 3, 2018
1 parent d164f8f commit 09241ea1951cb03e3222eff545935218006bdeb5
@@ -137,15 +137,15 @@ 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() );

// 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,15 +165,15 @@ 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() );

// 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" ) );

0 comments on commit 09241ea

Please sign in to comment.
You can’t perform that action at this time.