aboutsummaryrefslogtreecommitdiff
path: root/tests/rbtree.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rbtree.test.ts')
-rw-r--r--tests/rbtree.test.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/rbtree.test.ts b/tests/rbtree.test.ts
index 5b2bc34..edb3135 100644
--- a/tests/rbtree.test.ts
+++ b/tests/rbtree.test.ts
@@ -3,6 +3,7 @@ import {RBTree, Iterator, rbtree_shallow_copy} from '/src/rbtree.ts'
function cmpInt(a: int, b: int){
return a - b;
}
+
function getIteratorEls<T>(itr: Iterator<T>): T[]{
let els: T[] = [];
if (itr.data() != null){
@@ -14,6 +15,7 @@ function getIteratorEls<T>(itr: Iterator<T>): T[]{
}
return els;
}
+
function getIteratorElsRev<T>(itr: Iterator<T>): T[]{
let els: T[] = [];
if (itr.data() != null){
@@ -40,6 +42,7 @@ test('insert and remove', () => {
expect(tree.min()).toBe(-1);
expect(tree.max()).toBe(20);
});
+
test('iteration', () => {
let vals = [10, 10, 20, 5, -1];
let tree = new RBTree(cmpInt);
@@ -51,6 +54,7 @@ test('iteration', () => {
sorted.reverse()
expect(getIteratorElsRev(tree.iterator())).toEqual(sorted);
});
+
test('find', () => {
let tree = new RBTree(cmpInt);
tree.insert(1);