Skip to content

Commit

Permalink
Revert "Prevent throwing in destructor in close_iteration_test"
Browse files Browse the repository at this point in the history
This reverts commit 1490db6.
  • Loading branch information
franzpoeschel committed Jul 10, 2020
1 parent 9cc7259 commit c320171
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,15 @@ close_iteration_test( std::string file_ending )

std::vector<int> data{2, 4, 6, 8};
// { // we do *not* need these parentheses

// let this Series leak, otherwise the destructor will throw
// catch2 does not catch exceptions from within destructors
Series * write = new Series(name, Access::CREATE);
Series write(name, Access::CREATE);
{
Iteration it0 = write->iterations[ 0 ];
Iteration it0 = write.iterations[ 0 ];
auto E_x = it0.meshes[ "E" ][ "x" ];
E_x.resetDataset( { Datatype::INT, { 2, 2 } } );
E_x.storeChunk( data, { 0, 0 }, { 2, 2 } );
it0.close( /* flush = */ false );
}
write->flush();
write.flush();
// }

if (isAdios1)
Expand All @@ -141,15 +138,15 @@ close_iteration_test( std::string file_ending )
}

{
Iteration it1 = write->iterations[1];
Iteration it1 = write.iterations[1];
auto E_x = it1.meshes[ "E" ][ "x" ];
E_x.resetDataset( { Datatype::INT, { 2, 2 } } );
E_x.storeChunk( data, { 0, 0 }, { 2, 2 } );
it1.close( /* flush = */ true );

// illegally access iteration after closing
E_x.storeChunk( data, { 0, 0 }, { 2, 2 } );
REQUIRE_THROWS( write->flush() );
REQUIRE_THROWS( write.flush() );
}

if (isAdios1)
Expand All @@ -160,10 +157,8 @@ close_iteration_test( std::string file_ending )
}
else
{
// let this Series leak, otherwise the destructor will throw
// catch2 does not catch exceptions from within destructors
Series * read = new Series( name, Access::READ_ONLY );
Iteration it1 = read->iterations[ 1 ];
Series read( name, Access::READ_ONLY );
Iteration it1 = read.iterations[ 1 ];
auto E_x_read = it1.meshes[ "E" ][ "x" ];
auto chunk = E_x_read.loadChunk< int >( { 0, 0 }, { 2, 2 } );
it1.close( /* flush = */ true );
Expand All @@ -172,7 +167,7 @@ close_iteration_test( std::string file_ending )
REQUIRE( data[ i ] == chunk.get()[ i ] );
}
auto read_again = E_x_read.loadChunk< int >( { 0, 0 }, { 2, 2 } );
REQUIRE_THROWS( read->flush() );
REQUIRE_THROWS( read.flush() );
}
}

Expand Down

0 comments on commit c320171

Please sign in to comment.