We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f4169c4 commit 213ec92Copy full SHA for 213ec92
src/test/java/com/thealgorithms/datastructures/trees/BinaryTreeTest.java
@@ -37,8 +37,11 @@ void test2() {
37
t.remove(5);
38
t.remove(7);
39
40
- Assertions.assertNotNull(t.getRoot(), "Root should not be null after removals.");
41
- Assertions.assertEquals(9, t.getRoot().data);
+ BinaryTree.Node newRoot = t.getRoot();
+ Assertions.assertNotNull(newRoot, "Root should not be null after removals.");
42
+ if (newRoot != null) { // Add null check
43
+ Assertions.assertEquals(9, newRoot.data);
44
+ }
45
}
46
47
// Test for attempting to remove a nonexistent node
0 commit comments