fix(curriculum): test removing non-existing element from empty and non-empty tree (#43885)

* fix: test removing element not in a tree

* fix: test removing from empty tree
This commit is contained in:
Krzysztof
2021-10-26 06:07:12 +02:00
committed by GitHub
parent 866c9ee9d9
commit e3822b9cac

View File

@ -46,6 +46,25 @@ assert(
);
```
Trying to remove an element from an empty tree should return `null`.
```js
assert(
(function () {
var test = false;
if (typeof BinarySearchTree !== 'undefined') {
test = new BinarySearchTree();
} else {
return false;
}
if (typeof test.remove !== 'function') {
return false;
}
return test.remove(100) == null;
})()
);
```
Trying to remove an element that does not exist should return `null`.
```js
@ -60,6 +79,8 @@ assert(
if (typeof test.remove !== 'function') {
return false;
}
test.add(15);
test.add(30);
return test.remove(100) == null;
})()
);