Skip to content

Commit

Permalink
Adapt Coretests
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jul 24, 2023
1 parent 60b063f commit a98eacd
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions test/CoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ TEST_CASE("myPath", "[core]")
"particles",
"e",
"particlePatches",
"numParticles",
RecordComponent::SCALAR});
"numParticles"});
#endif
}

Expand Down Expand Up @@ -441,16 +440,21 @@ TEST_CASE("record_constructor_test", "[core]")
ps["position"][RecordComponent::SCALAR].resetDataset(dset);
ps["positionOffset"][RecordComponent::SCALAR].resetDataset(dset);

REQUIRE(r["x"].resetDataset(dset).unitSI() == 1);
REQUIRE(r["x"].numAttributes() == 1); /* unitSI */
REQUIRE(r["y"].resetDataset(dset).unitSI() == 1);
REQUIRE(r["y"].numAttributes() == 1); /* unitSI */
REQUIRE(r["z"].resetDataset(dset).unitSI() == 1);
REQUIRE(r["z"].numAttributes() == 1); /* unitSI */
// unitSI is set upon flushing
// REQUIRE(r["x"].unitSI() == 1);
REQUIRE(r["x"].resetDataset(dset).numAttributes() == 0); /* unitSI */
// REQUIRE(r["y"].unitSI() == 1);
REQUIRE(r["y"].resetDataset(dset).numAttributes() == 0); /* unitSI */
// REQUIRE(r["z"].unitSI() == 1);
REQUIRE(r["z"].resetDataset(dset).numAttributes() == 0); /* unitSI */
std::array<double, 7> zeros{{0., 0., 0., 0., 0., 0., 0.}};
REQUIRE(r.unitDimension() == zeros);
REQUIRE(r.timeOffset<float>() == static_cast<float>(0));
REQUIRE(r.numAttributes() == 2); /* timeOffset, unitDimension */
o.flush();
REQUIRE(r["x"].unitSI() == 1);
REQUIRE(r["y"].unitSI() == 1);
REQUIRE(r["z"].unitSI() == 1);
}

TEST_CASE("record_modification_test", "[core]")
Expand Down Expand Up @@ -509,15 +513,11 @@ TEST_CASE("mesh_constructor_test", "[core]")
Mesh &m = o.iterations[42].meshes["E"];

std::vector<double> pos{0};
REQUIRE(m["x"].resetDataset(globalDataset).unitSI() == 1);
REQUIRE(m["x"].numAttributes() == 2); /* unitSI, position */
REQUIRE(m["x"].position<double>() == pos);
REQUIRE(m["y"].resetDataset(globalDataset).unitSI() == 1);
REQUIRE(m["y"].numAttributes() == 2); /* unitSI, position */
REQUIRE(m["y"].position<double>() == pos);
REQUIRE(m["z"].resetDataset(globalDataset).unitSI() == 1);
REQUIRE(m["z"].numAttributes() == 2); /* unitSI, position */
REQUIRE(m["z"].position<double>() == pos);
/* unitSI and position are set to default values upon flushing */
REQUIRE(m["x"].resetDataset(globalDataset).numAttributes() == 0);
REQUIRE(m["y"].resetDataset(globalDataset).numAttributes() == 0);
REQUIRE(m["z"].resetDataset(globalDataset).numAttributes() == 0);

REQUIRE(m.geometry() == Mesh::Geometry::cartesian);
REQUIRE(m.dataOrder() == Mesh::DataOrder::C);
std::vector<std::string> al{"x"};
Expand All @@ -531,6 +531,17 @@ TEST_CASE("mesh_constructor_test", "[core]")
m.numAttributes() ==
8); /* axisLabels, dataOrder, geometry, gridGlobalOffset, gridSpacing,
gridUnitSI, timeOffset, unitDimension */

o.flush();
REQUIRE(m["x"].unitSI() == 1);
REQUIRE(m["x"].numAttributes() == 2); /* unitSI, position */
REQUIRE(m["x"].position<double>() == pos);
REQUIRE(m["y"].unitSI() == 1);
REQUIRE(m["y"].numAttributes() == 2); /* unitSI, position */
REQUIRE(m["y"].position<double>() == pos);
REQUIRE(m["z"].unitSI() == 1);
REQUIRE(m["z"].numAttributes() == 2); /* unitSI, position */
REQUIRE(m["z"].position<double>() == pos);
}

TEST_CASE("mesh_modification_test", "[core]")
Expand Down Expand Up @@ -1014,6 +1025,8 @@ TEST_CASE("empty_record_test", "[core]")
"RecordComponents: E"));
o.iterations[1].meshes["E"][RecordComponent::SCALAR].resetDataset(
Dataset(Datatype::DOUBLE, {1}));
auto B = o.iterations[1].meshes["B"];
B.resetDataset(Dataset(Datatype::DOUBLE, {1}));
o.flush();
}

Expand Down

0 comments on commit a98eacd

Please sign in to comment.