Skip to content

Commit

Permalink
Add dfs GraphSearch tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
theViz343 committed Nov 3, 2023
1 parent 9fd0504 commit 3b37cee
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/test/java/GraphDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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<String> 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 {
Expand Down

0 comments on commit 3b37cee

Please sign in to comment.