Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
(cherry picked from commit 872c9a1)
  • Loading branch information
wonder-sk authored and nyalldawson committed Nov 10, 2018
1 parent 267c80c commit 016b251
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/src/providers/testqgsgdalprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class TestQgsGdalProvider : public QObject
void scaleDataType(); //test resultant data types for int raster with float scale (#11573)
void warpedVrt(); //test loading raster which requires a warped vrt
void noData();
void noDataOutsideExtent();
void invalidNoDataInSourceIgnored();
void isRepresentableValue();
void mask();
Expand Down Expand Up @@ -151,6 +152,30 @@ void TestQgsGdalProvider::noData()
delete provider;
}

void TestQgsGdalProvider::noDataOutsideExtent()
{
QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/band1_byte_ct_epsg4326.tif";
QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() );
QVERIFY( provider->isValid() );
QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider );
QVERIFY( rp );
if ( rp )
{
std::unique_ptr<QgsRasterBlock> block( rp->block( 1, QgsRectangle( 10, 10, 12, 12 ), 16, 16 ) );
QVERIFY( block );
QCOMPARE( block->width(), 16 );
QCOMPARE( block->height(), 16 );
for ( int y = 0; y < 16; ++y )
{
for ( int x = 0; x < 16; ++x )
{
QVERIFY( block->isNoData( y, x ) );
}
}
}
delete provider;
}

void TestQgsGdalProvider::invalidNoDataInSourceIgnored()
{
QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/byte_with_nan_nodata.tif";
Expand Down

0 comments on commit 016b251

Please sign in to comment.