summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorHaidong Ji2019-06-12 20:06:47 -0500
committerHaidong Ji2019-06-12 20:06:47 -0500
commit18ae1ea81ee05c62b325bf91813f7d293228df45 (patch)
tree73b478ddbe97463c2b3a8957ddd19a70b0f160fd /src/test
parent578980d5ff80f94c9748d806879b7b707eec441e (diff)
"is it binary search tree hard" done!
not too bad, just allowing the right node being equal or greater. Two modifications to the code was needed.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/TreeBstCheckTest.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/TreeBstCheckTest.java b/src/test/TreeBstCheckTest.java
index 7002d3e..35b66b4 100644
--- a/src/test/TreeBstCheckTest.java
+++ b/src/test/TreeBstCheckTest.java
@@ -57,4 +57,31 @@ class TreeBstCheckTest {
assertFalse(tt.isBst());
}
+ @Test
+ void test6() {
+ TreeBstCheck.TreeOrders tt = new TreeBstCheck.TreeOrders();
+ tt.key = new int[]{2, 1, 2};
+ tt.left = new int[]{1, -1, -1};
+ tt.right = new int[]{2, -1, -1};
+
+ assertTrue(tt.isBst());
+ }
+ @Test
+ void test7() {
+ TreeBstCheck.TreeOrders tt = new TreeBstCheck.TreeOrders();
+ tt.key = new int[]{2, 2, 3};
+ tt.left = new int[]{1, -1, -1};
+ tt.right = new int[]{2, -1, -1};
+
+ assertFalse(tt.isBst());
+ }
+ @Test
+ void test8() {
+ TreeBstCheck.TreeOrders tt = new TreeBstCheck.TreeOrders();
+ tt.key = new int[]{2147483647};
+ tt.left = new int[]{-1};
+ tt.right = new int[]{-1};
+
+ assertTrue(tt.isBst());
+ }
}