Files
karl/test/test_hdf.cpp

32 lines
913 B
C++
Executable File

#include "catch.hpp"
#include "IO/hdf5_reader.h"
#include "IO/hdf5_writer.h"
#include "simulation/homebase.h"
TEST_CASE("Hdf5", "[Hdf5]") {
SECTION("Reader and Writing the same data") {
std::string directory = BUILD_HOMEBASE_STRING + std::string("/test");
std::string filename = "test_output";
std::string absolute_filename = directory + filename;
Hdf5Writer writer(directory, filename);
Hdf5Reader reader(directory, filename);
SECTION("1d data") {
blitz::Array<double, 1> data(4);
data = 0.1, -0.1, 1.2, 3.0;
std::string path_1d = "/1d_double";
writer.write(data, path_1d);
blitz::Array<double, 1> read_data = reader.readD1Double(path_1d);
REQUIRE(read_data.size() == 4);
REQUIRE(read_data(0) == data(0));
REQUIRE(read_data(1) == data(1));
REQUIRE(read_data(2) == data(2));
REQUIRE(read_data(3) == data(3));
}
}
}