Skip to content

Commit 016b251

Browse files
wonder-sknyalldawson
authored andcommittedNov 10, 2018
Add unit test
(cherry picked from commit 872c9a1)
1 parent 267c80c commit 016b251

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
 

‎tests/src/providers/testqgsgdalprovider.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class TestQgsGdalProvider : public QObject
4848
void scaleDataType(); //test resultant data types for int raster with float scale (#11573)
4949
void warpedVrt(); //test loading raster which requires a warped vrt
5050
void noData();
51+
void noDataOutsideExtent();
5152
void invalidNoDataInSourceIgnored();
5253
void isRepresentableValue();
5354
void mask();
@@ -151,6 +152,30 @@ void TestQgsGdalProvider::noData()
151152
delete provider;
152153
}
153154

155+
void TestQgsGdalProvider::noDataOutsideExtent()
156+
{
157+
QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/band1_byte_ct_epsg4326.tif";
158+
QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() );
159+
QVERIFY( provider->isValid() );
160+
QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider );
161+
QVERIFY( rp );
162+
if ( rp )
163+
{
164+
std::unique_ptr<QgsRasterBlock> block( rp->block( 1, QgsRectangle( 10, 10, 12, 12 ), 16, 16 ) );
165+
QVERIFY( block );
166+
QCOMPARE( block->width(), 16 );
167+
QCOMPARE( block->height(), 16 );
168+
for ( int y = 0; y < 16; ++y )
169+
{
170+
for ( int x = 0; x < 16; ++x )
171+
{
172+
QVERIFY( block->isNoData( y, x ) );
173+
}
174+
}
175+
}
176+
delete provider;
177+
}
178+
154179
void TestQgsGdalProvider::invalidNoDataInSourceIgnored()
155180
{
156181
QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/byte_with_nan_nodata.tif";

0 commit comments

Comments
 (0)
Please sign in to comment.