Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixAnthonisen committed Nov 12, 2024
1 parent 1b3850f commit 660b75d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Map;
import com.github.javaparser.ast.type.ClassOrInterfaceType;

import anthonisen.felix.astParsing.util.TypeHandler;
import io.github.bldl.astParsing.util.TypeHandler;

public class TestTypeHandler {
@Test
Expand Down
24 changes: 22 additions & 2 deletions src/test/java/anthonisen/felix/graph/TestClassHierarchyGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.HashSet;
import java.util.Set;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;;
import org.junit.jupiter.api.Test;

import io.github.bldl.graph.ClassHierarchyGraph;;

public class TestClassHierarchyGraph {
IDirectedGraph<Integer> graph;
ClassHierarchyGraph<Integer> graph;

@BeforeEach
public void setUpGraph() {
Expand Down Expand Up @@ -48,6 +51,14 @@ public void testAddEdge() {
assertTrue(found);
}

@Test
public void testCantAddEdgeThatCreatesCycle() {
for (int i = 0; i < 5; ++i) {
graph.addEdge(i, i + 1);
}
assertThrows(IllegalArgumentException.class, () -> graph.addEdge(4, 0));
}

@Test
public void testCantAddEdge() {
assertFalse(graph.addEdge(2, 10));
Expand All @@ -61,4 +72,13 @@ public void testGetVertices() {
graph.getVertices().forEach(vertex -> actualVerts.add(vertex));
assertEquals(expectedVerts, actualVerts);
}

@Test
public void testIsDescendant() {
for (int i = 0; i < 4; ++i) {
graph.addEdge(i, i + 1);
}
assertTrue(graph.isDescendant(0, 4));
assertFalse(graph.isDescendant(4, 0));
}
}

0 comments on commit 660b75d

Please sign in to comment.