-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckSubTreeTest.java
More file actions
executable file
·55 lines (44 loc) · 1.54 KB
/
Copy pathCheckSubTreeTest.java
File metadata and controls
executable file
·55 lines (44 loc) · 1.54 KB
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
package algorithm.graph;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class CheckSubTreeTest {
@Test
void checkSubTree_TestA() {
BinaryTreeNode node1 = null;
int[] values2 = {10, 11, 50, 70, 6, 5, 80, 30, 20, 90, 12, 15, 40, 95};
for (int value : values2) {
node1 = TreeOperation.insert(node1, value);
}
BinaryTreeNode node2 = null;
int[] values = {50, 70, 80, 30, 20, 90, 12, 15, 40, 95};
for (int value : values) {
node2 = TreeOperation.insert(node2, value);
}
boolean result = CheckSubTree.check(node1, node2);
Assertions.assertTrue(result);
}
@Test
void checkSubTree_TestB() {
BinaryTreeNode node1 = null;
int[] values2 = {10, 11, 50, 70, 6, 5, 81};
for (int value : values2) {
node1 = TreeOperation.insert(node1, value);
}
BinaryTreeNode node2 = null;
int[] values = {50, 70, 80};
for (int value : values) {
node2 = TreeOperation.insert(node2, value);
}
boolean result = CheckSubTree.check(node1, node2);
Assertions.assertFalse(result);
}
@Test
void checkSubTree_TestC() {
BinaryTreeNode node1 = null;
int[] values2 = {10, 11, 50, 70, 6, 5, 81};
for (int value : values2) {
node1 = TreeOperation.insert(node1, value);
}
Assertions.assertTrue(CheckSubTree.check(node1, null));
}
}