forked from examplehub/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSameTreeTest.java
More file actions
27 lines (21 loc) · 999 Bytes
/
SameTreeTest.java
File metadata and controls
27 lines (21 loc) · 999 Bytes
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
package com.examplehub.leetcode.easy;
import static org.junit.jupiter.api.Assertions.*;
import com.examplehub.leetcode.TreeNode;
import com.examplehub.leetcode.utils.BinaryTreeUtils;
import org.junit.jupiter.api.Test;
class SameTreeTest {
@Test
void testSolution1() {
TreeNode firstTree = BinaryTreeUtils.createTree(new int[] {1, 2, 3}, 0);
TreeNode secondTree = BinaryTreeUtils.createTree(new int[] {1, 2, 3}, 0);
assertTrue(SameTree.solution1(firstTree, secondTree));
firstTree = BinaryTreeUtils.createTree(new int[] {1, 2}, 0);
secondTree = BinaryTreeUtils.createTree(new int[] {1, -1, 2}, 0);
assertFalse(SameTree.solution1(firstTree, secondTree));
firstTree = BinaryTreeUtils.createTree(new int[] {1, 2, 1}, 0);
secondTree = BinaryTreeUtils.createTree(new int[] {1, 1, 2}, 0);
assertFalse(SameTree.solution1(firstTree, secondTree));
assertFalse(SameTree.solution1(null, firstTree));
assertFalse(SameTree.solution1(null, secondTree));
}
}