LCOV - code coverage report
Current view: top level - autotest/cpp - test_gdal_mdim.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 19 19 100.0 %
Date: 2026-05-29 18:47:21 Functions: 5 5 100.0 %

          Line data    Source code
       1             : ///////////////////////////////////////////////////////////////////////////////
       2             : //
       3             : // Project:  C++ Test Suite for GDAL/OGR
       4             : // Purpose:  Test GDAL multidim API
       5             : // Author:   Even Rouault <even.rouault at spatialys.com>
       6             : //
       7             : ///////////////////////////////////////////////////////////////////////////////
       8             : // Copyright (c) 2026, Even Rouault <even.rouault at spatialys.com>
       9             : /*
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "gdal_unit_test.h"
      14             : 
      15             : #include "gdal_multidim_cpp.h"
      16             : #include "memdataset.h"
      17             : 
      18             : #include <vector>
      19             : 
      20             : #if defined(__clang__)
      21             : #pragma clang diagnostic push
      22             : #pragma clang diagnostic ignored "-Wweak-vtables"
      23             : #endif
      24             : 
      25             : namespace test_gdal_mdim
      26             : {
      27             : 
      28             : struct test_gdal_mdim : public ::testing::Test
      29             : {
      30             : };
      31             : 
      32           4 : TEST_F(test_gdal_mdim, RecursivelyVisitArrays)
      33             : {
      34             :     auto poDS = std::unique_ptr<GDALDataset>(
      35           1 :         MEMDataset::CreateMultiDimensional("", nullptr, nullptr));
      36             : 
      37           1 :     auto poRG = poDS->GetRootGroup();
      38           1 :     auto poArray1 = poRG->CreateMDArray("array1", {},
      39           2 :                                         GDALExtendedDataType::Create(GDT_Byte));
      40           2 :     auto poSubGroup = poRG->CreateGroup("subgroup");
      41           1 :     auto poArray2 = poSubGroup->CreateMDArray(
      42           2 :         "array2", {}, GDALExtendedDataType::Create(GDT_Byte));
      43           2 :     auto poSubGroup2 = poRG->CreateGroup("subgroup2");
      44           1 :     auto poArray3 = poSubGroup2->CreateMDArray(
      45           2 :         "array3", {}, GDALExtendedDataType::Create(GDT_Byte));
      46             : 
      47           1 :     std::vector<std::shared_ptr<GDALMDArray>> visitedArrays;
      48           1 :     poRG->RecursivelyVisitArrays(
      49           3 :         [&visitedArrays](const std::shared_ptr<GDALMDArray> &array)
      50           3 :         { visitedArrays.push_back(array); });
      51             : 
      52           1 :     ASSERT_EQ(visitedArrays.size(), 3U);
      53           1 :     EXPECT_EQ(visitedArrays[0].get(), poArray1.get());
      54           1 :     EXPECT_EQ(visitedArrays[1].get(), poArray2.get());
      55           1 :     EXPECT_EQ(visitedArrays[2].get(), poArray3.get());
      56             : }
      57             : 
      58             : }  // namespace test_gdal_mdim
      59             : 
      60             : #if defined(__clang__)
      61             : #pragma clang diagnostic pop
      62             : #endif

Generated by: LCOV version 1.14