Skip to content

Commit

Permalink
groupInfo()
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Dec 26, 2022
1 parent 460e7d7 commit 61fa68f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
3 changes: 1 addition & 2 deletions modules/c++/hdf5.lite/include/hdf5/lite/Info.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Expand Down
13 changes: 8 additions & 5 deletions modules/c++/hdf5.lite/source/Info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ static std::vector<hdf5::lite::DatatypeInfo> 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;

Expand All @@ -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)
Expand Down
36 changes: 18 additions & 18 deletions modules/c++/hdf5.lite/unittests/test_hdf5info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
Expand All @@ -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);
)

0 comments on commit 61fa68f

Please sign in to comment.