File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
src/test/java/com/thealgorithms/sorts Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 11package com .thealgorithms .sorts ;
22
3- import static org .junit .jupiter .api .Assertions .assertEquals ;
4- import static org .junit .jupiter .api .Assertions .assertIterableEquals ;
5- import static org .junit .jupiter .api .Assertions .assertThrows ;
6-
73import com .thealgorithms .sorts .TopologicalSort .Graph ;
84import java .util .LinkedList ;
95import org .junit .jupiter .api .Test ;
106
7+ import static org .junit .jupiter .api .Assertions .*;
8+
119class TopologicalSortTest {
1210
1311 @ Test
@@ -59,4 +57,18 @@ public void failureTest() {
5957 + "Back edge: 6 -> 2" ;
6058 assertEquals (exception .getMessage (), expected );
6159 }
60+ @ Test
61+ void testEmptyGraph () {
62+ Graph graph = new Graph ();
63+ LinkedList <String > sorted = TopologicalSort .sort (graph );
64+ assertTrue (sorted .isEmpty ());
65+ }
66+ @ Test
67+ void testSingleNode () {
68+ Graph graph = new Graph ();
69+ graph .addEdge ("A" , "" );
70+ LinkedList <String > sorted = TopologicalSort .sort (graph );
71+ assertEquals (1 , sorted .size ());
72+ assertEquals ("A" , sorted .getFirst ());
73+ }
6274}
You can’t perform that action at this time.
0 commit comments