-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreeLongestPathTest.java
42 lines (37 loc) · 1.24 KB
/
TreeLongestPathTest.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
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TreeLongestPathTest {
@Test
public void visibleTest1() {
Tree t =
new Tree(
1,
Arrays.asList(
new Tree(2, Collections.singletonList(new Tree(4, Collections.emptyList()))),
new Tree(4, Collections.emptyList())));
assertEquals(2, t.longestPath());
}
@Test
public void visibleTest2() {
Tree t =
new Tree(
5,
Arrays.asList(
new Tree(6, Collections.emptyList()),
new Tree(
7,
Arrays.asList(
new Tree(
8,
Collections.singletonList(
new Tree(
9,
Arrays.asList(
new Tree(15, Collections.emptyList()),
new Tree(10, Collections.emptyList()))))),
new Tree(12, Collections.emptyList())))));
assertEquals(4, t.longestPath());
}
}