Skip to content

Commit d1ed98f

Browse files
Merge branch 'master' into add-lambda-utils
2 parents 068ece1 + e41c2b9 commit d1ed98f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>org.junit</groupId>
2222
<artifactId>junit-bom</artifactId>
23-
<version>5.13.0</version>
23+
<version>5.13.1</version>
2424
<type>pom</type>
2525
<scope>import</scope>
2626
</dependency>

src/test/java/com/thealgorithms/sorts/TopologicalSortTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
55
import static org.junit.jupiter.api.Assertions.assertThrows;
6+
import static org.junit.jupiter.api.Assertions.assertTrue;
67

78
import com.thealgorithms.sorts.TopologicalSort.Graph;
89
import java.util.LinkedList;
@@ -59,4 +60,18 @@ public void failureTest() {
5960
+ "Back edge: 6 -> 2";
6061
assertEquals(exception.getMessage(), expected);
6162
}
63+
@Test
64+
void testEmptyGraph() {
65+
Graph graph = new Graph();
66+
LinkedList<String> sorted = TopologicalSort.sort(graph);
67+
assertTrue(sorted.isEmpty());
68+
}
69+
@Test
70+
void testSingleNode() {
71+
Graph graph = new Graph();
72+
graph.addEdge("A", "");
73+
LinkedList<String> sorted = TopologicalSort.sort(graph);
74+
assertEquals(1, sorted.size());
75+
assertEquals("A", sorted.getFirst());
76+
}
6277
}

0 commit comments

Comments
 (0)