Skip to content

Commit 602ed08

Browse files
committed
More extended testing
1 parent bcbd536 commit 602ed08

File tree

1 file changed

+84
-1
lines changed

1 file changed

+84
-1
lines changed

test/CoreTest.cpp

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ TEST_CASE("custom_hierarchies", "[core]")
212212

213213
auto meshesViaAlias = write.iterations[0].meshes;
214214
meshesViaAlias["E"]["x"].makeEmpty<float>(2);
215-
write.setMeshesPath("fields");
215+
write.setMeshesPath(std::vector<std::string>{"fields/", ".*/meshes/"});
216216
auto meshesManually =
217217
write.iterations[0]["fields"].asContainerOf<Mesh>();
218218
REQUIRE(meshesManually.contains("E"));
@@ -297,6 +297,89 @@ TEST_CASE("custom_hierarchies", "[core]")
297297
REQUIRE(constant_dataset.getDatatype() == Datatype::FLOAT);
298298
REQUIRE(constant_dataset.getExtent() == Extent{0, 0, 0});
299299
}
300+
read.close();
301+
302+
write = Series(filePath, Access::READ_WRITE);
303+
{
304+
std::vector<int> data(10, 3);
305+
306+
auto E_x = write.iterations[0]["custom_meshes"].meshes["E"]["x"];
307+
E_x.resetDataset({Datatype::INT, {10}});
308+
E_x.storeChunk(data, {0}, {10});
309+
310+
auto e_pos_x = write.iterations[0]["custom_particles"]
311+
.particles["e"]["position"]["x"];
312+
e_pos_x.resetDataset({Datatype::INT, {10}});
313+
e_pos_x.storeChunk(data, {0}, {10});
314+
write.close();
315+
}
316+
317+
read = Series(filePath, Access::READ_ONLY);
318+
{
319+
auto it0 = read.iterations[0];
320+
auto custom_meshes = it0["custom_meshes"];
321+
REQUIRE(custom_meshes.meshes.size() == 1);
322+
REQUIRE(read.iterations[0]["custom_meshes"].meshes.count("E") == 1);
323+
auto E_x_loaded = read.iterations[0]["custom_meshes"]
324+
.meshes["E"]["x"]
325+
.loadChunk<int>();
326+
REQUIRE(read.iterations[0]["custom_particles"].particles.size() == 1);
327+
REQUIRE(
328+
read.iterations[0]["custom_particles"].particles.count("e") == 1);
329+
auto e_pos_x_loaded = read.iterations[0]["custom_particles"]
330+
.particles["e"]["position"]["x"]
331+
.loadChunk<int>();
332+
read.flush();
333+
334+
for (size_t i = 0; i < 10; ++i)
335+
{
336+
REQUIRE(E_x_loaded.get()[i] == 3);
337+
REQUIRE(e_pos_x_loaded.get()[i] == 3);
338+
}
339+
}
340+
}
341+
342+
TEST_CASE("custom_hierarchies_no_rw", "[core]")
343+
{
344+
std::string filePath = "../samples/custom_hierarchies_no_rw.json";
345+
Series write(filePath, Access::CREATE);
346+
write.setMeshesPath(std::vector<std::string>{".*/meshes/"});
347+
write.iterations[0]["custom"]["hierarchy"];
348+
write.iterations[0]["custom"].setAttribute("string", "attribute");
349+
write.iterations[0]["custom"]["hierarchy"].setAttribute("number", 3);
350+
write.iterations[0]["no_attributes"];
351+
352+
{
353+
write.iterations[0]["custom"]["hierarchy"];
354+
write.iterations[0]["custom"]
355+
.asContainerOf<RecordComponent>()["emptyDataset"]
356+
.makeEmpty(Datatype::FLOAT, 3);
357+
write.iterations[0]["custom"]["hierarchy"].setAttribute("number", 3);
358+
write.iterations[0]["no_attributes"];
359+
auto iteration_level_ds =
360+
write.iterations[0]
361+
.asContainerOf<RecordComponent>()["iteration_level_dataset"];
362+
iteration_level_ds.resetDataset({Datatype::INT, {10}});
363+
std::vector<int> data(10, 5);
364+
iteration_level_ds.storeChunk(data);
365+
write.flush();
366+
}
367+
368+
{
369+
std::vector<int> data(10, 3);
370+
371+
auto E_x = write.iterations[0]["custom_meshes"].meshes["E"]["x"];
372+
E_x.resetDataset({Datatype::INT, {10}});
373+
E_x.storeChunk(data, {0}, {10});
374+
375+
auto e_pos_x = write.iterations[0]["custom_particles"]
376+
.particles["e"]["position"]["x"];
377+
e_pos_x.resetDataset({Datatype::INT, {10}});
378+
e_pos_x.storeChunk(data, {0}, {10});
379+
write.close();
380+
}
381+
382+
Series read(filePath, Access::READ_ONLY);
300383
}
301384

302385
TEST_CASE("myPath", "[core]")

0 commit comments

Comments
 (0)