Skip to content

Commit 64ab5ac

Browse files
committed
WIP: Testing
1 parent 7ff50cb commit 64ab5ac

File tree

5 files changed

+61
-2
lines changed

5 files changed

+61
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ if(openPMD_BUILD_TESTING)
804804
test/Files_SerialIO/close_and_reopen_test.cpp
805805
test/Files_SerialIO/filebased_write_test.cpp
806806
test/Files_SerialIO/issue_1744_unique_ptrs_at_close_time.cpp
807+
test/Files_SerialIO/components_without_extent.cpp
807808
)
808809
elseif(${test_name} STREQUAL "ParallelIO" AND openPMD_HAVE_MPI)
809810
list(APPEND ${out_list}

src/RecordComponent.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,9 @@ RecordComponent &RecordComponent::resetDataset(Dataset d)
216216
rc.m_hasBeenExtended = true;
217217
}
218218

219-
if (d.extent.empty())
220-
throw std::runtime_error("Dataset extent must be at least 1D.");
219+
// @todo check this while flushing
220+
// if (d.extent.empty())
221+
// throw std::runtime_error("Dataset extent must be at least 1D.");
221222
if (d.empty())
222223
{
223224
if (d.extent.empty())

test/Files_SerialIO/SerialIOTests.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ namespace issue_1744_unique_ptrs_at_close_time
1212
{
1313
auto issue_1744_unique_ptrs_at_close_time() -> void;
1414
}
15+
namespace components_without_extent
16+
{
17+
auto components_without_extent() -> void;
18+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include "SerialIOTests.hpp"
2+
3+
#include "openPMD/openPMD.hpp"
4+
5+
#include <catch2/catch.hpp>
6+
7+
#include <memory>
8+
#include <numeric>
9+
10+
namespace components_without_extent
11+
{
12+
auto components_without_extent() -> void
13+
{
14+
auto filepath = "../samples/components_without_extent.bp5";
15+
// write
16+
{
17+
openPMD::Series write(filepath, openPMD::Access::CREATE);
18+
auto it0 = write.writeIterations()[0];
19+
auto e = it0.particles["e"];
20+
for (auto comp_id : {"x", "y", "z"})
21+
{
22+
auto position_comp = e["position"][comp_id];
23+
position_comp.resetDataset({openPMD::Datatype::FLOAT, {5}});
24+
std::unique_ptr<float[]> data{new float[5]};
25+
std::iota(data.get(), data.get() + 5, 0);
26+
position_comp.storeChunk(std::move(data), {0}, {5});
27+
28+
auto offset_comp = e["positionOffset"][comp_id];
29+
offset_comp.resetDataset({openPMD::Datatype::INT, {}});
30+
offset_comp.makeConstant(0);
31+
}
32+
write.close();
33+
}
34+
35+
// read
36+
{
37+
openPMD::Series read(filepath, openPMD::Access::READ_RANDOM_ACCESS);
38+
auto e = read.snapshots()[0].particles["e"];
39+
for (auto const &record : e)
40+
{
41+
for (auto const &component : record.second)
42+
{
43+
REQUIRE(component.second.getExtent() == openPMD::Extent{5});
44+
}
45+
}
46+
}
47+
}
48+
} // namespace components_without_extent

test/SerialIOTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,11 @@ TEST_CASE("issue_1744_unique_ptrs_at_close_time", "[serial]")
768768
#endif
769769
}
770770

771+
TEST_CASE("components_without_extent", "[serial]")
772+
{
773+
components_without_extent::components_without_extent();
774+
}
775+
771776
#if openPMD_HAVE_ADIOS2
772777
TEST_CASE("close_and_reopen_test", "[serial]")
773778
{

0 commit comments

Comments
 (0)