Skip to content

Commit

Permalink
DeathTest condition for TotalRealPowerGenerationAt non-existing `Ve…
Browse files Browse the repository at this point in the history
…rtex` with exception

Changes to be committed:
	modified:   tests/DataStructures/Graphs/TestPowerGrid.cpp
  • Loading branch information
franziska-wegner committed Dec 30, 2023
1 parent bace4a6 commit 1a72164
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 @@ -2572,6 +2572,7 @@ TEST_F ( TestNetworkEmpty
#endif // ifdef EGOA_ENABLE_EXCEPTION_HANDLING
#endif // ifdef EGOA_ENABLE_ASSERTION

#ifdef EGOA_ENABLE_ASSERTION
TEST_F ( TestPowerGridAcm2018MtsfFigure4aDeathTest
, TotalRealPowerGenerationAtNonExistingVertex )
{
Expand All @@ -2583,6 +2584,29 @@ TEST_F ( TestPowerGridAcm2018MtsfFigure4aDeathTest
ASSERT_DEATH ( {network_.TotalRealPowerGenerationAt<Vertices::GenerationStrategyDifferentiationType::totalVertexPowerGenerationPerSnapshot> ( static_cast<Types::vertexId>(9) );}
, assertionString );
}
#else
#ifdef EGOA_ENABLE_EXCEPTION_HANDLING
TEST_F ( TestPowerGridAcm2018MtsfFigure4a
, TotalRealPowerGenerationAtNonExistingVertexExceptionHandling )
{
auto assertionString = buildAssertionString ( "PowerGrid.hpp"
, "PowerGrid"
, "TotalRealPowerGenerationAt"
, "Graph\\(\\).VertexExists \\( vertexId \\)");

try {
network_.TotalRealPowerGenerationAt<Vertices::GenerationStrategyDifferentiationType::totalVertexPowerGenerationPerSnapshot> ( static_cast<Types::vertexId>(9) );
} 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 ( TestPowerGridAcm2018MtsfFigure4a
, TotalRealPowerGenerationAtWithVertexThatHasNoGenerator )
Expand Down

0 comments on commit 1a72164

Please sign in to comment.