HDF5: Groups and attributes creation can be reused
This commit is contained in:
@@ -13,6 +13,64 @@
|
||||
|
||||
using namespace std::literals::chrono_literals;
|
||||
|
||||
TEST_CASE("HDF5Group_create_reopen_and_fail", "[HDF5][Unit]") {
|
||||
{
|
||||
HDF5File file("scratch_group_reopen.h5");
|
||||
|
||||
REQUIRE_NOTHROW(HDF5Group(file, "/group1"));
|
||||
REQUIRE(file.Exists("/group1"));
|
||||
|
||||
REQUIRE_NOTHROW(HDF5Group(file, "/group1"));
|
||||
REQUIRE(file.Exists("/group1"));
|
||||
|
||||
REQUIRE_THROWS(HDF5Group(file, "/missing_parent/group2"));
|
||||
}
|
||||
|
||||
remove("scratch_group_reopen.h5");
|
||||
REQUIRE(H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("HDF5Attr_string_update", "[HDF5][Unit]") {
|
||||
const std::string first_value = "abc";
|
||||
const std::string second_value = "a much longer attribute value";
|
||||
|
||||
{
|
||||
HDF5File file("scratch_attr_string_update.h5");
|
||||
REQUIRE_NOTHROW(file.Attr("str_attr", first_value));
|
||||
REQUIRE_NOTHROW(file.Attr("str_attr", second_value));
|
||||
}
|
||||
|
||||
{
|
||||
HDF5ReadOnlyFile file("scratch_attr_string_update.h5");
|
||||
REQUIRE(file.ReadAttrStr("str_attr") == second_value);
|
||||
}
|
||||
|
||||
remove("scratch_attr_string_update.h5");
|
||||
REQUIRE(H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("HDF5Attr_int64_update", "[HDF5][Unit]") {
|
||||
const int64_t first_value = -1234567890123LL;
|
||||
const int64_t second_value = 9876543210123LL;
|
||||
|
||||
{
|
||||
HDF5File file("scratch_attr_int64_update.h5");
|
||||
REQUIRE_NOTHROW(file.Attr("int_attr", first_value));
|
||||
REQUIRE(file.ReadAttrInt("int_attr") == first_value);
|
||||
|
||||
REQUIRE_NOTHROW(file.Attr("int_attr", second_value));
|
||||
REQUIRE(file.ReadAttrInt("int_attr") == second_value);
|
||||
}
|
||||
|
||||
{
|
||||
HDF5ReadOnlyFile file("scratch_attr_int64_update.h5");
|
||||
REQUIRE(file.ReadAttrInt("int_attr") == second_value);
|
||||
}
|
||||
|
||||
remove("scratch_attr_int64_update.h5");
|
||||
REQUIRE(H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("HDF5DataSet_scalar", "[HDF5][Unit]") {
|
||||
uint16_t tmp_scalar = 16788;
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user