Skip to content

Commit

Permalink
Test that the error is correctly thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jul 25, 2023
1 parent 6781c0f commit 5f98403
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5467,18 +5467,24 @@ TEST_CASE("git_adios2_sample_test", "[serial][adios2]")

void variableBasedSeries(std::string const &file)
{
std::string selectADIOS2 = R"({"backend": "adios2"})";
constexpr Extent::value_type extent = 1000;
{
Series writeSeries(file, Access::CREATE, selectADIOS2);
Series writeSeries(file, Access::CREATE);
writeSeries.setAttribute("some_global", "attribute");
writeSeries.setIterationEncoding(IterationEncoding::variableBased);
REQUIRE(
writeSeries.iterationEncoding() ==
IterationEncoding::variableBased);
auto iterations = writeSeries.writeIterations();
bool is_not_adios2 = !auxiliary::contains(file, ".bp");
for (size_t i = 0; i < 10; ++i)
{
if (i > 0 && is_not_adios2)
{
REQUIRE_THROWS_AS(
iterations[i], error::OperationUnsupportedInBackend);
return;
}
auto iteration = iterations[i];
auto E_x = iteration.meshes["E"]["x"];
E_x.resetDataset({openPMD::Datatype::INT, {1000}});
Expand Down Expand Up @@ -5518,14 +5524,12 @@ void variableBasedSeries(std::string const &file)

REQUIRE(auxiliary::directory_exists(file));

auto testRead = [&file, &extent, &selectADIOS2](
std::string const &jsonConfig) {
auto testRead = [&file, &extent](std::string const &jsonConfig) {
/*
* Need linear read mode to access more than a single iteration in
* variable-based iteration encoding.
*/
Series readSeries(
file, Access::READ_LINEAR, json::merge(selectADIOS2, jsonConfig));
Series readSeries(file, Access::READ_LINEAR, jsonConfig);

size_t last_iteration_index = 0;
REQUIRE(!readSeries.containsAttribute("some_global"));
Expand Down Expand Up @@ -5600,7 +5604,11 @@ void variableBasedSeries(std::string const &file)
#if openPMD_HAVE_ADIOS2
TEST_CASE("variableBasedSeries", "[serial][adios2]")
{
variableBasedSeries("../samples/variableBasedSeries.bp");
for (auto const &t : testedFileExtensions())

{
variableBasedSeries("../samples/variableBasedSeries." + t);
}
}
#endif

Expand Down

0 comments on commit 5f98403

Please sign in to comment.