diff --git a/modules/c++/hdf5.lite/include/hdf5/lite/Info.h b/modules/c++/hdf5.lite/include/hdf5/lite/Info.h index c910d528b..d21b7558d 100644 --- a/modules/c++/hdf5.lite/include/hdf5/lite/Info.h +++ b/modules/c++/hdf5.lite/include/hdf5/lite/Info.h @@ -99,8 +99,7 @@ struct FileInfo final : public GroupInfo CODA_OSS_API FileInfo fileInfo(coda_oss::filesystem::path); -CODA_OSS_API FileInfo fileInfo(coda_oss::filesystem::path, std::string loc); - +CODA_OSS_API GroupInfo groupInfo(coda_oss::filesystem::path, std::string loc); CODA_OSS_API DatasetInfo datasetInfo(coda_oss::filesystem::path, std::string loc); } diff --git a/modules/c++/hdf5.lite/source/Info.cpp b/modules/c++/hdf5.lite/source/Info.cpp index dde36c1ce..6c9fc7856 100644 --- a/modules/c++/hdf5.lite/source/Info.cpp +++ b/modules/c++/hdf5.lite/source/Info.cpp @@ -126,9 +126,9 @@ static std::vector getDatatypes(H5::Group& group) } // https://docs.hdfgroup.org/archive/support/HDF5/doc1.8/cpplus_RM/readdata_8cpp-example.html -static hdf5::lite::FileInfo fileInfo_(coda_oss::filesystem::path filename, std::string loc) +static hdf5::lite::GroupInfo groupInfo_(coda_oss::filesystem::path filename, std::string loc) { - hdf5::lite::FileInfo retval; + hdf5::lite::GroupInfo retval; retval.filename = filename.string(); retval.name = loc; @@ -144,13 +144,16 @@ static hdf5::lite::FileInfo fileInfo_(coda_oss::filesystem::path filename, std:: return retval; } -hdf5::lite::FileInfo hdf5::lite::fileInfo(coda_oss::filesystem::path filename, std::string loc) +hdf5::lite::GroupInfo hdf5::lite::groupInfo(coda_oss::filesystem::path filename, std::string loc) { - return details::try_catch_H5Exceptions(fileInfo_, filename, loc); + return details::try_catch_H5Exceptions(groupInfo_, filename, loc); } hdf5::lite::FileInfo hdf5::lite::fileInfo(coda_oss::filesystem::path filename) { - return fileInfo(filename, "/" /*loc*/); + hdf5::lite::FileInfo retval; + hdf5::lite::GroupInfo& retval_ = retval; + retval_= groupInfo(filename, "/" /*loc*/); + return retval; } static hdf5::lite::Class H5T_class_to_Class(H5T_class_t type_class) diff --git a/modules/c++/hdf5.lite/unittests/test_hdf5info.cpp b/modules/c++/hdf5.lite/unittests/test_hdf5info.cpp index 7c7277a3e..dd4fe0fed 100644 --- a/modules/c++/hdf5.lite/unittests/test_hdf5info.cpp +++ b/modules/c++/hdf5.lite/unittests/test_hdf5info.cpp @@ -34,20 +34,6 @@ static std::filesystem::path find_unittest_file(const std::filesystem::path& nam static const auto unittests = std::filesystem::path("modules") / "c++" / "hdf5.lite" / "unittests"; return sys::test::findGITModuleFile("coda-oss", unittests, name); } - -TEST_CASE(test_hdf5Info) -{ - static const auto path = find_unittest_file("example.h5"); - - // https://www.mathworks.com/help/matlab/ref/h5info.html - const auto info = hdf5::lite::fileInfo(path); - TEST_ASSERT_EQ(path.string(), info.filename); - TEST_ASSERT_EQ("/", info.name); - TEST_ASSERT_EQ(info.groups.size(), 4); - TEST_ASSERT_TRUE(info.datasets.empty()); - TEST_ASSERT_TRUE(info.datatypes.empty()); -} - TEST_CASE(test_hdf5Info_IOException) { static const std::filesystem::path path = "does not exist . h5"; @@ -63,12 +49,26 @@ TEST_CASE(test_hdf5Info_IOException) } } -TEST_CASE(test_hdf5Info_loc) + +TEST_CASE(test_hdf5FileInfo) +{ + static const auto path = find_unittest_file("example.h5"); + + // https://www.mathworks.com/help/matlab/ref/h5info.html + const auto info = hdf5::lite::fileInfo(path); + TEST_ASSERT_EQ(path.string(), info.filename); + TEST_ASSERT_EQ("/", info.name); + TEST_ASSERT_EQ(info.groups.size(), 4); + TEST_ASSERT_TRUE(info.datasets.empty()); + TEST_ASSERT_TRUE(info.datatypes.empty()); +} + +TEST_CASE(test_hdf5GroupInfo) { static const auto path = find_unittest_file("example.h5"); // https://www.mathworks.com/help/matlab/ref/h5info.html - const auto info = hdf5::lite::fileInfo(path, "/g4"); + const auto info = hdf5::lite::groupInfo(path, "/g4"); TEST_ASSERT_EQ(path.string(), info.filename); TEST_ASSERT_EQ("/g4", info.name); @@ -90,9 +90,9 @@ TEST_CASE(test_hdf5DatasetInfo) } TEST_MAIN( - TEST_CHECK(test_hdf5Info); TEST_CHECK(test_hdf5Info_IOException); - TEST_CHECK(test_hdf5Info_loc); + TEST_CHECK(test_hdf5FileInfo); + TEST_CHECK(test_hdf5GroupInfo); TEST_CHECK(test_hdf5DatasetInfo); )