Skip to content

Commit 97b2198

Browse files
committed
[test] H5: check ascii in file to utf8 memory
Check that ASCII encoded data in the file can be read into memory.
1 parent c277f0e commit 97b2198

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/hdf5/TestH5.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include "TestH5.hpp"
1212

13+
#include <nix/Hydra.hpp>
14+
1315
#include "hdf5/FileHDF5.hpp"
1416
#include "hdf5/h5x/H5Exception.hpp"
1517
#include "hdf5/h5x/H5PList.hpp"
@@ -379,4 +381,17 @@ void TestH5::testUTF8() {
379381
h5group.createLink(g, "zelda");
380382
h5group.linkInfo("zelda", li);
381383
CPPUNIT_ASSERT_EQUAL(H5T_CSET_UTF8, li.cset);
384+
385+
// ASCII in the file, utf8 in memory
386+
nix::hdf5::h5x::DataType ascii_type = nix::hdf5::h5x::DataType::makeStrType(H5T_VARIABLE, H5T_CSET_ASCII);
387+
std::string test_str = "Hallo";
388+
389+
const nix::Hydra<std::string> hydra(test_str);
390+
391+
nix::hdf5::DataSpace fileSpace = nix::hdf5::DataSpace::create(hydra.shape(), false);
392+
nix::hdf5::Attribute attr_ascii = g.createAttr("ascii", ascii_type, fileSpace);
393+
attr_ascii.write(nix::hdf5::data_type_to_h5_memtype(nix::DataType::String), hydra.shape(), hydra.data());
394+
395+
std::string str_out;
396+
g.getAttr("ascii", str_out);
382397
}

0 commit comments

Comments
 (0)