Skip to content

Commit

Permalink
added test for UnMarkSuppressOnClose()
Browse files Browse the repository at this point in the history
helps code coverage buildbot
  • Loading branch information
chacha21 committed Dec 19, 2023
1 parent 80a1ee1 commit 6e3990c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions autotest/cpp/test_gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2533,6 +2533,35 @@ TEST_F(test_gdal, MarkSuppressOnClose)
}
}

// Test effect of UnMarkSuppressOnClose()
TEST_F(test_gdal, UnMarkSuppressOnClose)
{
const char *pszFilename = "/vsimem/out.tif";
const char *const apszOptions[] = {"PROFILE=BASELINE", nullptr};
{
GDALDatasetUniquePtr poDstDS(
GDALDriver::FromHandle(GDALGetDriverByName("GTiff"))
->Create(pszFilename, 1, 1, 1, GDT_Byte, apszOptions));
poDstDS->SetMetadataItem("FOO", "BAR");
poDstDS->MarkSuppressOnClose();
poDstDS->GetRasterBand(1)->Fill(255);
if (poDstDS->IsMarkedSuppressOnClose())
poDstDS->UnMarkSuppressOnClose();
poDstDS->FlushCache(true);
// All buffers have been flushed, and our dirty block should have
// been written hence the checksum will not be 0
EXPECT_NE(GDALChecksumImage(
GDALRasterBand::FromHandle(poDstDS->GetRasterBand(1)), 0,
0, 1, 1),
0);
}
{
VSIStatBufL sStat;
EXPECT_TRUE(VSIStatL(CPLSPrintf("%s.aux.xml", pszFilename), &sStat) ==
0);
}
}

template <class T> void TestCachedPixelAccessor()
{
constexpr auto eType = GDALCachedPixelAccessorGetDataType<T>::DataType;
Expand Down

0 comments on commit 6e3990c

Please sign in to comment.