Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate DynamicGraph Datastructure Tests #52

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ add_executable(TestGraph DataStructures/Graphs/TestGraph.cpp)
target_link_libraries(TestGraph EGOA ${GUROBI_LIBRARIES} gtest gtest_main gmock_main)
add_test(NAME TestGraph COMMAND TestGraph)

# add_executable(TestDynamicGraph DataStructures/Graphs/TestDynamicGraph.cpp)
# target_link_libraries(TestDynamicGraph EGOA ${GUROBI_LIBRARIES} gtest gtest_main gmock_main)
# add_test(NAME TestDynamicGraph COMMAND TestDynamicGraph)
add_executable(TestDynamicGraph DataStructures/Graphs/TestDynamicGraph.cpp)
target_link_libraries(TestDynamicGraph EGOA ${GUROBI_LIBRARIES} gtest gtest_main gmock_main)
add_test(NAME TestDynamicGraph COMMAND TestDynamicGraph)

# add_executable(TestPowerGrid DataStructures/Graphs/TestPowerGrid.cpp)
# target_link_libraries(TestPowerGrid EGOA ${GUROBI_LIBRARIES} gtest gtest_main gmock_main)
Expand Down
35 changes: 29 additions & 6 deletions tests/DataStructures/Graphs/TestDynamicGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,39 @@

#include "TestDynamicGraph.hpp"

using ::testing::MatchesRegex;

namespace egoa::test {

#pragma mark DeleteVertex

TEST_F(TestDynamicGraphEmptyDeathTest, DeleteVertex) {
auto assertionMessage =
this->assertionString("RemoveVertexAt", "VertexExists\\(id\\)");
Types::vertexId id = 0;
EXPECT_DEATH( { this->graph_.RemoveVertexAt(id); }, assertionMessage);
}
#ifdef EGOA_ENABLE_ASSERTION
TEST_F(TestDynamicGraphEmptyDeathTest, DeleteVertex) {
auto assertionMessage =
this->assertionString("RemoveVertexAt", "VertexExists\\(id\\)");
Types::vertexId id = 0;
EXPECT_DEATH( { this->graph_.RemoveVertexAt(id); }, assertionMessage);
}
#else
#ifdef EGOA_ENABLE_EXCEPTION_HANDLING
TEST_F ( TestDynamicGraphEmpty
, DeleteVertexExceptionHandling )
{
auto assertionString = this->assertionString("RemoveVertexAt", "VertexExists\\(id\\)");
Types::vertexId id = 0;
try {
this->graph_.RemoveVertexAt(id);
} 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(TestDynamicGraphSingleVertex, DeleteVertex) {
this->graph_.RemoveVertexAt(this->id_);
Expand Down