diff --git a/modules/c++/hdf5.lite/unittests/test_hdf5write.cpp b/modules/c++/hdf5.lite/unittests/test_hdf5write.cpp index fc1000e3c..0d99d1105 100644 --- a/modules/c++/hdf5.lite/unittests/test_hdf5write.cpp +++ b/modules/c++/hdf5.lite/unittests/test_hdf5write.cpp @@ -31,6 +31,8 @@ #include "hdf5/lite/Write.h" #include "hdf5/lite/HDF5Exception.h" +#include "hdf5/lite/Info.h" +#include "hdf5/lite/Read.h" static std::filesystem::path find_unittest_file(const std::filesystem::path& name) { @@ -41,12 +43,51 @@ static std::filesystem::path find_unittest_file(const std::filesystem::path& nam TEST_CASE(test_hdf5Create) { static const auto path_ = find_unittest_file("example.h5"); - static const auto path = path_.parent_path() / "TEST_myfile_TMP.h5"; + static const auto path = path_.parent_path() / "TEST_hdf5Create_TMP.h5"; // https://www.mathworks.com/help/matlab/ref/h5write.html hdf5::lite::createFile(path, "/DS1", {10, 20}); } +TEST_CASE(test_hdf5Write) +{ + static const auto path_ = find_unittest_file("example.h5"); + static const auto path = path_.parent_path() / "TEST_hdf5Write_TMP.h5"; + + const types::RowCol dims{10, 20}; + std::vector data_(dims.area()); + const hdf5::lite::SpanRC data(data_.data(), dims); + double d = 0.0; + for (size_t r = 0; r result; + const auto rc = hdf5::lite::readFile(path, "/DS1", result); + TEST_ASSERT(rc.dims() == dims); + TEST_ASSERT_EQ(dims.area(), result.size()); + for (size_t i = 0; i < result.size(); i++) + { + const auto expected = static_cast(i); + TEST_ASSERT_ALMOST_EQ(result[i], expected); + } +} + TEST_MAIN( TEST_CHECK(test_hdf5Create); + TEST_CHECK(test_hdf5Write); )