|
2 | 2 |
|
3 | 3 | import com.fishercoder.common.classes.TreeNode;
|
4 | 4 | import com.fishercoder.common.utils.TreeUtils;
|
5 |
| -import com.fishercoder.solutions._703; |
6 |
| -import com.fishercoder.solutions._976; |
7 | 5 | import com.fishercoder.solutions._993;
|
8 |
| -import java.util.Arrays; |
9 | 6 | import org.junit.BeforeClass;
|
10 | 7 | import org.junit.Test;
|
11 | 8 |
|
| 9 | +import java.util.Arrays; |
| 10 | + |
12 | 11 | import static junit.framework.Assert.assertEquals;
|
13 | 12 |
|
14 | 13 | public class _993Test {
|
15 |
| - private static _993.Solution1 solution1; |
16 |
| - private static TreeNode root; |
17 |
| - |
18 |
| - @BeforeClass |
19 |
| - public static void setUp() { |
20 |
| - solution1 = new _993.Solution1(); |
21 |
| - } |
22 |
| - |
23 |
| - @Test |
24 |
| - public void test1() { |
25 |
| - root = TreeUtils.constructBinaryTree(Arrays.asList(1, 2, 3, 4)); |
26 |
| - TreeUtils.printBinaryTree(root); |
27 |
| - assertEquals(false, solution1.isCousins(root, 4, 3)); |
28 |
| - } |
29 |
| - |
30 |
| - @Test |
31 |
| - public void test2() { |
32 |
| - root = TreeUtils.constructBinaryTree(Arrays.asList(1, 2, 3, null, 4, null, 5)); |
33 |
| - TreeUtils.printBinaryTree(root); |
34 |
| - assertEquals(true, solution1.isCousins(root, 5, 4)); |
35 |
| - } |
36 |
| - |
37 |
| - @Test |
38 |
| - public void test3() { |
39 |
| - root = TreeUtils.constructBinaryTree(Arrays.asList(1, 2, 3, null, 4)); |
40 |
| - TreeUtils.printBinaryTree(root); |
41 |
| - assertEquals(false, solution1.isCousins(root, 2, 3)); |
42 |
| - } |
| 14 | + private static _993.Solution1 solution1; |
| 15 | + private static _993.Solution2 solution2; |
| 16 | + private static TreeNode root; |
| 17 | + |
| 18 | + @BeforeClass |
| 19 | + public static void setUp() { |
| 20 | + solution1 = new _993.Solution1(); |
| 21 | + solution2 = new _993.Solution2(); |
| 22 | + } |
| 23 | + |
| 24 | + @Test |
| 25 | + public void test1() { |
| 26 | + root = TreeUtils.constructBinaryTree(Arrays.asList(1, 2, 3, 4)); |
| 27 | + TreeUtils.printBinaryTree(root); |
| 28 | + assertEquals(false, solution1.isCousins(root, 4, 3)); |
| 29 | + assertEquals(false, solution2.isCousins(root, 4, 3)); |
| 30 | + } |
| 31 | + |
| 32 | + @Test |
| 33 | + public void test2() { |
| 34 | + root = TreeUtils.constructBinaryTree(Arrays.asList(1, 2, 3, null, 4, null, 5)); |
| 35 | + TreeUtils.printBinaryTree(root); |
| 36 | + assertEquals(true, solution1.isCousins(root, 5, 4)); |
| 37 | + assertEquals(true, solution2.isCousins(root, 5, 4)); |
| 38 | + } |
| 39 | + |
| 40 | + @Test |
| 41 | + public void test3() { |
| 42 | + root = TreeUtils.constructBinaryTree(Arrays.asList(1, 2, 3, null, 4)); |
| 43 | + TreeUtils.printBinaryTree(root); |
| 44 | + assertEquals(false, solution1.isCousins(root, 2, 3)); |
| 45 | + assertEquals(false, solution2.isCousins(root, 2, 3)); |
| 46 | + } |
43 | 47 | }
|
0 commit comments