From 7a79aec1907b4622489e2323650aa8a2900d4bcf Mon Sep 17 00:00:00 2001 From: sbaldu Date: Tue, 26 Sep 2023 16:30:28 +0200 Subject: [PATCH] Add test for getNode method --- test/GraphTest.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/GraphTest.cpp b/test/GraphTest.cpp index 29450e250..8bcdb3626 100644 --- a/test/GraphTest.cpp +++ b/test/GraphTest.cpp @@ -794,3 +794,24 @@ TEST(TestRemoveNode, Test_connectedNode) { ASSERT_EQ(graph.getNodeSet().size(), 5); ASSERT_EQ(graph.getEdgeSet().size(), 1); } + +TEST(TestGetNode, Test_1) { + CXXGraph::Node node1("1", 1); + CXXGraph::Node node2("2", 2); + CXXGraph::Node node3("3", 3); + CXXGraph::DirectedEdge edge1(1, node1, node2); + CXXGraph::DirectedEdge edge2(2, node2, node1); + CXXGraph::DirectedEdge edge3(3, node1, node3); + CXXGraph::T_EdgeSet edgeSet; + edgeSet.insert(make_shared>(edge1)); + edgeSet.insert(make_shared>(edge2)); + edgeSet.insert(make_shared>(edge3)); + CXXGraph::Graph graph(edgeSet); + + auto node_found = graph.getNode("2"); + ASSERT_TRUE(node_found.has_value()); + ASSERT_EQ(node_found.value()->getUserId(), "2"); + + auto node_notfound = graph.getNode("5"); + ASSERT_FALSE(node_notfound.has_value()); +}