Skip to content

Commit c1775b4

Browse files
resolved spotbug
1 parent 0cce10d commit c1775b4

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/test/java/com/thealgorithms/datastructures/trees/BinaryTreeTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ void test1() {
2222
Assertions.assertEquals(7, t.find(7).data);
2323
}
2424

25-
// Test for removing data and checking the new root
2625
@Test
2726
void test2() {
2827
BinaryTree t = new BinaryTree();
@@ -37,11 +36,8 @@ void test2() {
3736
t.remove(5);
3837
t.remove(7);
3938

40-
BinaryTree.Node newRoot = t.getRoot();
41-
Assertions.assertNotNull(newRoot, "Root should not be null after removals.");
42-
if (newRoot != null) { // Add null check
43-
Assertions.assertEquals(9, newRoot.data);
44-
}
39+
Assertions.assertNotNull(t.getRoot(), "Root should not be null after removals.");
40+
Assertions.assertEquals(9, t.getRoot().data); // Direct access after ensuring non-null
4541
}
4642

4743
// Test for attempting to remove a nonexistent node

0 commit comments

Comments
 (0)