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 3
3
import static org .junit .jupiter .api .Assertions .assertEquals ;
4
4
import static org .junit .jupiter .api .Assertions .assertIterableEquals ;
5
5
import static org .junit .jupiter .api .Assertions .assertThrows ;
6
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
6
7
7
8
import com .thealgorithms .sorts .TopologicalSort .Graph ;
8
9
import java .util .LinkedList ;
@@ -59,4 +60,18 @@ public void failureTest() {
59
60
+ "Back edge: 6 -> 2" ;
60
61
assertEquals (exception .getMessage (), expected );
61
62
}
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
+ }
62
77
}
You can’t perform that action at this time.
0 commit comments