-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBalancedBinaryTreeTest.java
More file actions
69 lines (67 loc) · 2.1 KB
/
Copy pathBalancedBinaryTreeTest.java
File metadata and controls
69 lines (67 loc) · 2.1 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import org.example.helpers.TreeNode;
import org.example.problems.balanced_binary_tree.Solution;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
public class BalancedBinaryTreeTest {
private static Stream<Arguments> provideCases() {
return Stream.of(
Arguments.of(
new TreeNode(
3,
new TreeNode(9),
new TreeNode(
20,
new TreeNode(15),
new TreeNode(7)
)
), true),
Arguments.of(
new TreeNode(
1,
new TreeNode(
2,
new TreeNode(
3,
new TreeNode(4),
new TreeNode(4)
),
new TreeNode(3)
),
new TreeNode(2)
), false),
Arguments.of(
new TreeNode(
1,
new TreeNode(
2,
new TreeNode(
3,
new TreeNode(4),
null
),
null
),
new TreeNode(
2,
null,
new TreeNode(
3,
null,
new TreeNode(4)
)
)
),
false
)
);
}
@ParameterizedTest
@MethodSource("provideCases")
public void test(TreeNode root, boolean expected) {
Solution s = new Solution();
Assertions.assertSame(expected, s.isBalanced(root));
}
}