-
-
Notifications
You must be signed in to change notification settings - Fork 314
/
Copy pathFirstCommonAncestorTest.java
44 lines (33 loc) · 987 Bytes
/
FirstCommonAncestorTest.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
package com.swe102x.mytest;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import com.swe102x.myclass.FirstCommonAncestor;
import com.swe102x.myclass.FirstCommonAncestor.TreeNode;
class FirstCommonAncestorTest {
@BeforeAll
static void setUpBeforeClass() throws Exception {
}
@AfterAll
static void tearDownAfterClass() throws Exception {
}
FirstCommonAncestor ancestor;
FirstCommonAncestor.TreeNode root;
@BeforeEach
void setUp() throws Exception {
ancestor = new FirstCommonAncestor();
root = ancestor.new TreeNode(4);
ancestor.addNode(root);
}
@AfterEach
void tearDown() throws Exception {
}
@Test
void testFindFCA() {
//test case
assertEquals(root, ancestor.findFCA(root, root.getLeft().getLeft().getLeft(), root.getRight().getRight()));
}
}