Skip to content
Permalink
Browse files

Add unit test

  • Loading branch information
wonder-sk committed Nov 8, 2018
1 parent afca644 commit 872c9a10a3522e507150d55c6d2bd4243ce7e1b5
Showing with 25 additions and 0 deletions.
  1. +25 −0 tests/src/providers/testqgsgdalprovider.cpp
@@ -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();
@@ -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";

0 comments on commit 872c9a1

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