Skip to content

Commit

Permalink
DeathTest condition for TotalRealPowerGenerationAt with exception
Browse files Browse the repository at this point in the history
Changes to be committed:
	modified:   tests/DataStructures/Graphs/TestPowerGrid.cpp
  • Loading branch information
franziska-wegner committed Dec 30, 2023
1 parent 472a3f5 commit bace4a6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/DataStructures/Graphs/TestPowerGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2536,6 +2536,7 @@ TEST_F ( TestPowerGridPyPsaExample
// ***********************************************************************
// ***********************************************************************

#ifdef EGOA_ENABLE_ASSERTION
TEST_F ( TestNetworkEmptyDeathTest
, TotalRealPowerGenerationAt )
{
Expand All @@ -2547,6 +2548,29 @@ TEST_F ( TestNetworkEmptyDeathTest
ASSERT_DEATH ( {network_.TotalRealPowerGenerationAt<Vertices::GenerationStrategyDifferentiationType::totalVertexPowerGenerationPerSnapshot> ( static_cast<Types::vertexId>(0) ); }
, assertionString );
}
#else
#ifdef EGOA_ENABLE_EXCEPTION_HANDLING
TEST_F ( TestNetworkEmpty
, TotalRealPowerGenerationAtExceptionHandling )
{
auto assertionString = buildAssertionString ( "PowerGrid.hpp"
, "PowerGrid"
, "TotalRealPowerGenerationAt"
, "Graph\\(\\).VertexExists \\( vertexId \\)");

try {
network_.TotalRealPowerGenerationAt<Vertices::GenerationStrategyDifferentiationType::totalVertexPowerGenerationPerSnapshot> ( static_cast<Types::vertexId>(0) );
} catch ( std::runtime_error const & error )
{
EXPECT_THAT ( error.what(), MatchesRegex(assertionString.c_str()) );
} catch ( ... )
{
FAIL() << "Expected std::runtime_error with message: "
<< assertionString;
}
}
#endif // ifdef EGOA_ENABLE_EXCEPTION_HANDLING
#endif // ifdef EGOA_ENABLE_ASSERTION

TEST_F ( TestPowerGridAcm2018MtsfFigure4aDeathTest
, TotalRealPowerGenerationAtNonExistingVertex )
Expand Down

0 comments on commit bace4a6

Please sign in to comment.