Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2fd85e2

Browse files
Merge pull request knaxus#86 from iamshadmirza/bst-delete-unit-test
BST unit test for delete()
2 parents 41fef14 + c601e25 commit 2fd85e2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const BST = require('.');
2+
3+
describe('Data Structure : Binary Search Tree', () => {
4+
it('Should be class', () => {
5+
expect(typeof BST.prototype.constructor).toEqual('function');
6+
});
7+
8+
describe('Binary Search Tree API', () => {
9+
let bst = null;
10+
11+
beforeEach(() => {
12+
bst = new BST(5);
13+
});
14+
15+
it('Should delete() an element from Binary Search Tree', () => {
16+
bst.add(4);
17+
bst.add(9);
18+
bst.add(2);
19+
bst.delete(bst.root, 4);
20+
expect(bst.traverseInorder()).toEqual([2, 5, 9]);
21+
bst.delete(bst.root, 2);
22+
expect(bst.traverseInorder()).toEqual([5, 9]);
23+
});
24+
});
25+
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /