1
1
package com .fishercoder ;
2
2
3
3
import com .fishercoder .common .classes .TreeNode ;
4
- import com .fishercoder .common .utils .CommonUtils ;
5
4
import com .fishercoder .common .utils .TreeUtils ;
6
5
import com .fishercoder .solutions ._144 ;
7
6
import org .junit .BeforeClass ;
10
9
import java .util .Arrays ;
11
10
import java .util .List ;
12
11
12
+ import static org .junit .Assert .assertEquals ;
13
+
13
14
public class _144Test {
14
15
private static _144 .Solution1 solution1 ;
15
16
private static _144 .Solution2 solution2 ;
@@ -26,15 +27,30 @@ public static void setup() {
26
27
public void test1 () {
27
28
root = TreeUtils .constructBinaryTree (Arrays .asList (3 , 1 , null , null , 5 , 2 , null , null , 4 ));
28
29
inorder = solution1 .preorderTraversal (root );
29
- CommonUtils . printList ( inorder );
30
+ assertEquals ( Arrays . asList ( 3 , 1 , 5 , 2 , 4 ), inorder );
30
31
}
31
32
32
33
@ Test
33
34
public void test2 () {
34
35
root = TreeUtils .constructBinaryTree (Arrays .asList (1 , 2 , 3 , 4 , null , 5 , 6 , null , 7 , null , null , null , null , 8 , 9 ));
35
36
TreeUtils .printBinaryTree (root );
36
37
inorder = solution1 .preorderTraversal (root );
37
- CommonUtils .printList (inorder );
38
+ assertEquals (Arrays .asList (1 , 2 , 4 , 7 , 8 , 9 , 3 , 5 , 6 ), inorder );
39
+ }
40
+
41
+ @ Test
42
+ public void test3 () {
43
+ root = TreeUtils .constructBinaryTree (Arrays .asList (3 , 1 , null , null , 5 , 2 , null , null , 4 ));
44
+ inorder = solution2 .preorderTraversal (root );
45
+ assertEquals (Arrays .asList (3 , 1 , 5 , 2 , 4 ), inorder );
46
+ }
47
+
48
+ @ Test
49
+ public void test4 () {
50
+ root = TreeUtils .constructBinaryTree (Arrays .asList (1 , 2 , 3 , 4 , null , 5 , 6 , null , 7 , null , null , null , null , 8 , 9 ));
51
+ TreeUtils .printBinaryTree (root );
52
+ inorder = solution2 .preorderTraversal (root );
53
+ assertEquals (Arrays .asList (1 , 2 , 4 , 7 , 8 , 9 , 3 , 5 , 6 ), inorder );
38
54
}
39
55
40
56
}
0 commit comments