-
Notifications
You must be signed in to change notification settings - Fork 19.8k
/
Copy pathBSTRecursiveTest.java
61 lines (47 loc) · 1.39 KB
/
BSTRecursiveTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.thealgorithms.datastructures.trees;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* @author Albina Gimaletdinova on 06/05/2023
*/
public class BSTRecursiveTest {
@Test
public void testBSTIsCorrectlyConstructedFromOneNode() {
BSTRecursive tree = new BSTRecursive();
tree.add(6);
Assertions.assertTrue(CheckBinaryTreeIsValidBST.isBST(tree.getRoot()));
}
@Test
public void testBSTIsCorrectlyCleanedAndEmpty() {
BSTRecursive tree = new BSTRecursive();
tree.add(6);
tree.remove(6);
tree.add(12);
tree.add(1);
tree.add(2);
tree.remove(1);
tree.remove(2);
tree.remove(12);
Assertions.assertNull(tree.getRoot());
}
@Test
public void testBSTIsCorrectlyCleanedAndNonEmpty() {
BSTRecursive tree = new BSTRecursive();
tree.add(6);
tree.remove(6);
tree.add(12);
tree.add(1);
tree.add(2);
Assertions.assertTrue(CheckBinaryTreeIsValidBST.isBST(tree.getRoot()));
}
@Test
public void testBSTIsCorrectlyConstructedFromMultipleNodes() {
BSTRecursive tree = new BSTRecursive();
tree.add(7);
tree.add(1);
tree.add(5);
tree.add(100);
tree.add(50);
Assertions.assertTrue(CheckBinaryTreeIsValidBST.isBST(tree.getRoot()));
}
}