Skip to content

Commit

Permalink
Add test for getNode method
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaldu committed Sep 26, 2023
1 parent cc1e11f commit 7a79aec
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/GraphTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> node1("1", 1);
CXXGraph::Node<int> node2("2", 2);
CXXGraph::Node<int> node3("3", 3);
CXXGraph::DirectedEdge<int> edge1(1, node1, node2);
CXXGraph::DirectedEdge<int> edge2(2, node2, node1);
CXXGraph::DirectedEdge<int> edge3(3, node1, node3);
CXXGraph::T_EdgeSet<int> edgeSet;
edgeSet.insert(make_shared<CXXGraph::Edge<int>>(edge1));
edgeSet.insert(make_shared<CXXGraph::Edge<int>>(edge2));
edgeSet.insert(make_shared<CXXGraph::Edge<int>>(edge3));
CXXGraph::Graph<int> 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());
}

0 comments on commit 7a79aec

Please sign in to comment.