-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidateBinarySearchTreeTest.java
More file actions
29 lines (26 loc) · 1.03 KB
/
Copy pathValidateBinarySearchTreeTest.java
File metadata and controls
29 lines (26 loc) · 1.03 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
import org.example.helpers.TreeNode;
import org.example.problems.validate_binary_search_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 ValidateBinarySearchTreeTest {
private static Stream<Arguments> provideCases() {
return Stream.of(
Arguments.of(new TreeNode(2, new TreeNode(1), new TreeNode(3)), true),
Arguments.of(new TreeNode(
5,
new TreeNode(1),
new TreeNode(4, new TreeNode(3), new TreeNode(6))
), false),
Arguments.of(new TreeNode(2, null, new TreeNode(3, new TreeNode(1), null)), false)
);
}
@ParameterizedTest
@MethodSource("provideCases")
public void test(TreeNode root, boolean expected) {
Solution s = new Solution();
Assertions.assertSame(expected, s.isValidBST(root));
}
}