From a8ec1c9b7b10d48e3fa2dca7c6ff5d15fac9ff41 Mon Sep 17 00:00:00 2001 From: Franziska Wegner Date: Tue, 26 Dec 2023 12:43:49 -0800 Subject: [PATCH 1/3] Activate DynamicGraph tests Changes to be committed: modified: tests/CMakeLists.txt --- tests/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f6332b3f..ab64163e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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) From 9a38bcf37803e726d45d6bd7e174132d6755953d Mon Sep 17 00:00:00 2001 From: Franziska Wegner Date: Tue, 26 Dec 2023 13:33:25 -0800 Subject: [PATCH 2/3] Fix the death test error Changes to be committed: modified: tests/DataStructures/Graphs/TestDynamicGraph.cpp --- .../Graphs/TestDynamicGraph.cpp | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/tests/DataStructures/Graphs/TestDynamicGraph.cpp b/tests/DataStructures/Graphs/TestDynamicGraph.cpp index 436e35d3..b341ba95 100644 --- a/tests/DataStructures/Graphs/TestDynamicGraph.cpp +++ b/tests/DataStructures/Graphs/TestDynamicGraph.cpp @@ -11,12 +11,33 @@ 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_); From 40239cc9941bcd5cb628a64858cb8b8b1798687a Mon Sep 17 00:00:00 2001 From: Franziska Wegner Date: Tue, 26 Dec 2023 14:59:33 -0800 Subject: [PATCH 3/3] Add missing namespace ::testing::MatchesRegex Changes to be committed: modified: tests/DataStructures/Graphs/TestDynamicGraph.cpp --- tests/DataStructures/Graphs/TestDynamicGraph.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/DataStructures/Graphs/TestDynamicGraph.cpp b/tests/DataStructures/Graphs/TestDynamicGraph.cpp index b341ba95..41ec042e 100644 --- a/tests/DataStructures/Graphs/TestDynamicGraph.cpp +++ b/tests/DataStructures/Graphs/TestDynamicGraph.cpp @@ -7,6 +7,8 @@ #include "TestDynamicGraph.hpp" +using ::testing::MatchesRegex; + namespace egoa::test { #pragma mark DeleteVertex