Skip to content

Commit 19fecb4

Browse files
committed
Add additional test case for HDF5IO::getStorageObjects
1 parent 67bc2cd commit 19fecb4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/testHDF5IO.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,38 @@ TEST_CASE("getStorageObjects", "[hdf5io]")
142142
REQUIRE(groupContent.size() == 0);
143143
}
144144

145+
SECTION("attribute")
146+
{
147+
int attrData1 = 42;
148+
hdf5io.createAttribute(BaseDataType::I32, &attrData1, "/", "attr1");
149+
auto attributeContent = hdf5io.getStorageObjects("/attr1");
150+
REQUIRE(attributeContent.size() == 0);
151+
}
152+
153+
SECTION("dataset w/o attribute")
154+
{
155+
// Dataset without attributes
156+
hdf5io.createArrayDataSet(
157+
BaseDataType::I32, SizeArray {0}, SizeArray {1}, "/data");
158+
auto datasetContent = hdf5io.getStorageObjects("/data");
159+
REQUIRE(datasetContent.size() == 0);
160+
161+
// Dataset with attribute
162+
int attrData1 = 42;
163+
hdf5io.createAttribute(BaseDataType::I32, &attrData1, "/data", "attr1");
164+
auto dataContent2 = hdf5io.getStorageObjects("/data");
165+
REQUIRE(dataContent2.size() == 1);
166+
REQUIRE(
167+
dataContent2[0]
168+
== std::make_pair(std::string("attr1"), StorageObjectType::Attribute));
169+
}
170+
171+
SECTION("invalid path")
172+
{
173+
auto invalidPathContent = hdf5io.getStorageObjects("/invalid/path");
174+
REQUIRE(invalidPathContent.size() == 0);
175+
}
176+
145177
SECTION("group with datasets, subgroups, and attributes")
146178
{
147179
hdf5io.createGroup("/data");

0 commit comments

Comments
 (0)