57 {
58 const std::string groupChain = "a/b/c";
59 const std::string dsPath = "/a/b/c/dataset";
60 const hsize_t
rows = 5;
61
62 {
63 H5::H5File
src(
"merge_test_src1.h5", H5F_ACC_TRUNC);
64 writeNestedDataset(src, groupChain, "dataset", 0, rows);
65 }
66 {
67 H5::H5File
src(
"merge_test_src2.h5", H5F_ACC_TRUNC);
68 writeNestedDataset(src, groupChain, "dataset", 100, rows);
69 }
70
71 H5::H5File
target(
"merge_test_out.h5", H5F_ACC_TRUNC);
73
74
75
76 {
77 H5::H5File src1("merge_test_src1.h5", H5F_ACC_RDONLY);
78 merger.
merge(target, src1);
79 }
80 hsize_t afterFirst = readExtent(target, dsPath);
81 if (afterFirst != rows) {
82 std::cerr << "FAIL: merging into a brand-new nested group produced "
83 << afterFirst <<
" rows, expected " <<
rows
84 << " (double-merge bug?)" << std::endl;
85 return 1;
86 }
87
88
89
90 {
91 H5::H5File src2("merge_test_src2.h5", H5F_ACC_RDONLY);
92 merger.
merge(target, src2);
93 }
94 hsize_t afterSecond = readExtent(target, dsPath);
95 if (afterSecond != 2 * rows) {
96 std::cerr << "FAIL: merging into an existing nested group produced "
97 << afterSecond <<
" rows, expected " << 2 *
rows << std::endl;
98 return 1;
99 }
100
101 std::cout << "test-hdf5-merge: OK" << std::endl;
102 return 0;
103}
void merge(H5::Group &target, const H5::Group &source)
Merge a source group into a target group.