Skip to content

Commit

Permalink
Add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jan 24, 2025
1 parent 668c5a7 commit a843833
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/src/analysis/testqgsrastercalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class TestQgsRasterCalculator : public QgsTest
void findNodes();

void testRasterEntries();
void testOutputCrsFromRasterEntries();
void calcFormulasWithReprojectedLayers();

void testStatistics();
Expand Down Expand Up @@ -717,6 +718,30 @@ void TestQgsRasterCalculator::toString()
QVERIFY( calcNode == nullptr );
}

void TestQgsRasterCalculator::testOutputCrsFromRasterEntries()
{
QgsRasterCalculatorEntry entry1;
entry1.bandNumber = 1;
entry1.raster = mpLandsatRasterLayer;
entry1.ref = QStringLiteral( "landsat@0" );

QVector<QgsRasterCalculatorEntry> entries;
entries << entry1;

QgsRectangle extent( 783235, 3348110, 783350, 3347960 );

QTemporaryFile tmpFile;
tmpFile.open(); // fileName is not available until open
QString tmpName = tmpFile.fileName();
tmpFile.close();

QgsRasterCalculator rc( QStringLiteral( "\"landsat@0\"" ), tmpName, QStringLiteral( "GTiff" ), extent, 2, 3, entries, QgsProject::instance()->transformContext() );
QCOMPARE( static_cast<int>( rc.processCalculation() ), 0 );
//open output file and check results
QgsRasterLayer *result = new QgsRasterLayer( tmpName, QStringLiteral( "result" ) );
QCOMPARE( result->crs(), mpLandsatRasterLayer->crs() );
}

void TestQgsRasterCalculator::calcFormulasWithReprojectedLayers()
{
QgsRasterCalculatorEntry entry1;
Expand Down

0 comments on commit a843833

Please sign in to comment.