File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
src/test/java/com/thealgorithms/sorts Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 33import static org .junit .jupiter .api .Assertions .assertEquals ;
44import static org .junit .jupiter .api .Assertions .assertIterableEquals ;
55import static org .junit .jupiter .api .Assertions .assertThrows ;
6+ import static org .junit .jupiter .api .Assertions .assertTrue ;
67
78import com .thealgorithms .sorts .TopologicalSort .Graph ;
89import 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}
You can’t perform that action at this time.
0 commit comments