Merge pull request #27504 from asmorkalov:as/optional_gdal

Made some GDAL specific tests optional
This commit is contained in:
Alexander Smorkalov 2025-07-02 10:53:47 +03:00 committed by GitHub
commit 6b55ae0319
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,10 +8,14 @@ namespace opencv_test { namespace {
#ifdef HAVE_GDAL
static void test_gdal_read(const string filename) {
static void test_gdal_read(const string filename, bool required = true) {
const string path = cvtest::findDataFile(filename);
Mat img;
ASSERT_NO_THROW(img = imread(path, cv::IMREAD_LOAD_GDAL | cv::IMREAD_ANYDEPTH | cv::IMREAD_ANYCOLOR));
if(!required && img.empty())
{
throw SkipTestException("GDAL is built wihout required back-end support");
}
ASSERT_FALSE(img.empty());
EXPECT_EQ(3, img.cols);
EXPECT_EQ(5, img.rows);
@ -26,13 +30,12 @@ TEST(Imgcodecs_gdal, read_envi)
test_gdal_read("../cv/gdal/envi_test.raw");
}
TEST(Imgcodecs_gdal, read_fits)
{
test_gdal_read("../cv/gdal/fits_test.fit");
// .fit test is optional because GDAL may be built wihtout CFITSIO library support
test_gdal_read("../cv/gdal/fits_test.fit", false);
}
#endif // HAVE_GDAL
}} // namespace