From 3b37cee0d51486a164900ca3f8bba6b49218efa5 Mon Sep 17 00:00:00 2001 From: vishwesh Date: Fri, 3 Nov 2023 14:07:16 -0700 Subject: [PATCH] Add dfs GraphSearch tests. --- src/test/java/GraphDataTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/GraphDataTest.java b/src/test/java/GraphDataTest.java index 7fed958..102d717 100644 --- a/src/test/java/GraphDataTest.java +++ b/src/test/java/GraphDataTest.java @@ -7,6 +7,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashSet; +import java.util.List; import java.util.Set; import static org.junit.jupiter.api.Assertions.*; @@ -154,6 +155,21 @@ public void TestRemoveEdgeIfExists(){ assertThrows(Exception.class, () -> graphApi.removeEdge("B","C")); } + @Test + @DisplayName("Test dfs graph search api") + public void TestGraphSearch() { + Path path = graphApi.GraphSearch("C", "D"); + List expected = List.of(new String[]{"D", "A", "C"}); + assertEquals(path.path, expected); + } + + @Test + @DisplayName("Test dfs graph search api (node does not exist)") + public void TestGraphSearchNotExist() { + Path path = graphApi.GraphSearch("C", "X"); + assertNull(path); + } + @Test @DisplayName("Test DOT graph generation") public void TestOutputDOTGraph() throws IOException {