Skip to content

Commit 660b75d

Browse files
add more tests
1 parent 1b3850f commit 660b75d

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/test/java/anthonisen/felix/astParsing/TestTypeHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.util.Map;
99
import com.github.javaparser.ast.type.ClassOrInterfaceType;
1010

11-
import anthonisen.felix.astParsing.util.TypeHandler;
11+
import io.github.bldl.astParsing.util.TypeHandler;
1212

1313
public class TestTypeHandler {
1414
@Test

src/test/java/anthonisen/felix/graph/TestClassHierarchyGraph.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.junit.jupiter.api.Assertions.assertFalse;
5+
import static org.junit.jupiter.api.Assertions.assertThrows;
56
import static org.junit.jupiter.api.Assertions.assertTrue;
67

78
import java.util.HashSet;
89
import java.util.Set;
910

1011
import org.junit.jupiter.api.BeforeEach;
11-
import org.junit.jupiter.api.Test;;
12+
import org.junit.jupiter.api.Test;
13+
14+
import io.github.bldl.graph.ClassHierarchyGraph;;
1215

1316
public class TestClassHierarchyGraph {
14-
IDirectedGraph<Integer> graph;
17+
ClassHierarchyGraph<Integer> graph;
1518

1619
@BeforeEach
1720
public void setUpGraph() {
@@ -48,6 +51,14 @@ public void testAddEdge() {
4851
assertTrue(found);
4952
}
5053

54+
@Test
55+
public void testCantAddEdgeThatCreatesCycle() {
56+
for (int i = 0; i < 5; ++i) {
57+
graph.addEdge(i, i + 1);
58+
}
59+
assertThrows(IllegalArgumentException.class, () -> graph.addEdge(4, 0));
60+
}
61+
5162
@Test
5263
public void testCantAddEdge() {
5364
assertFalse(graph.addEdge(2, 10));
@@ -61,4 +72,13 @@ public void testGetVertices() {
6172
graph.getVertices().forEach(vertex -> actualVerts.add(vertex));
6273
assertEquals(expectedVerts, actualVerts);
6374
}
75+
76+
@Test
77+
public void testIsDescendant() {
78+
for (int i = 0; i < 4; ++i) {
79+
graph.addEdge(i, i + 1);
80+
}
81+
assertTrue(graph.isDescendant(0, 4));
82+
assertFalse(graph.isDescendant(4, 0));
83+
}
6484
}

0 commit comments

Comments
 (0)