-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_100Test.java
49 lines (41 loc) · 1.46 KB
/
_100Test.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
package com.fishercoder.firstthousand;
import com.fishercoder.common.classes.TreeNode;
import com.fishercoder.common.utils.TreeUtils;
import com.fishercoder.solutions.firstthousand._100;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class _100Test {
private _100.Solution1 solution1;
private static TreeNode p;
private static TreeNode q;
@BeforeEach
public void setup() {
solution1 = new _100.Solution1();
}
@Test
public void test1() {
p = TreeUtils.constructBinaryTree(Arrays.asList(1, 2, 3));
TreeUtils.printBinaryTree(p);
q = TreeUtils.constructBinaryTree(Arrays.asList(1, 2, 3));
TreeUtils.printBinaryTree(p);
assertEquals(true, solution1.isSameTree(p, q));
}
@Test
public void test2() {
p = TreeUtils.constructBinaryTree(Arrays.asList(1, 2));
TreeUtils.printBinaryTree(p);
q = TreeUtils.constructBinaryTree(Arrays.asList(1, null, 2));
TreeUtils.printBinaryTree(p);
assertEquals(false, solution1.isSameTree(p, q));
}
@Test
public void test3() {
p = TreeUtils.constructBinaryTree(Arrays.asList(1, 2, 1));
TreeUtils.printBinaryTree(p);
q = TreeUtils.constructBinaryTree(Arrays.asList(1, 1, 2));
TreeUtils.printBinaryTree(p);
assertEquals(false, solution1.isSameTree(p, q));
}
}