forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckTreeIsSymmetricTest.java
More file actions
35 lines (28 loc) · 1.02 KB
/
CheckTreeIsSymmetricTest.java
File metadata and controls
35 lines (28 loc) · 1.02 KB
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
package com.thealgorithms.datastructures.trees;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/**
* @author kumanoit on 10/10/22 IST 1:02 AM
*/
public class CheckTreeIsSymmetricTest {
@Test
public void testRootNull() {
assertTrue(CheckTreeIsSymmetric.isSymmetric(null));
}
@Test
public void testSingleNodeTree() {
final BinaryTree.Node root = TreeTestUtils.createTree(new Integer[] {100});
assertTrue(CheckTreeIsSymmetric.isSymmetric(root));
}
@Test
public void testSymmetricTree() {
final BinaryTree.Node root = TreeTestUtils.createTree(new Integer[] {1, 2, 2, 3, 4, 4, 3});
assertTrue(CheckTreeIsSymmetric.isSymmetric(root));
}
@Test
public void testNonSymmetricTree() {
final BinaryTree.Node root = TreeTestUtils.createTree(new Integer[] {1, 2, 2, 3, 5, 4, 3});
assertFalse(CheckTreeIsSymmetric.isSymmetric(root));
}
}