We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9654d1a commit f2fef25Copy full SHA for f2fef25
src/test/java/com/thealgorithms/datastructures/trees/BinaryTreeTest.java
@@ -1,6 +1,7 @@
1
package com.thealgorithms.datastructures.trees;
2
3
import static org.junit.jupiter.api.Assertions.assertEquals;
4
+import static org.junit.jupiter.api.Assertions.fail;
5
6
import org.junit.jupiter.api.Test;
7
@@ -35,7 +36,12 @@ void test2() {
35
36
t.remove(5);
37
t.remove(7);
38
- assertEquals(t.getRoot().data, 9);
39
+ // Checks whether the root is null before accessing date
40
+ if (t.getRoot() != null) {
41
+ assertEquals(t.getRoot().data, 9);
42
+ } else {
43
+ fail("The root node is null after removal.");
44
+ }
45
}
46
47
// checks that removing an unexistend node returns false
0 commit comments