Skip to content

Commit 55da7a1

Browse files
authored
merge: Add test case to HeapSort Algorithm (#947)
1 parent 73efc89 commit 55da7a1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Sorts/test/HeapSort.test.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { heapSort } from '../HeapSort'
2+
3+
test('The HeapSort of the array [5, 4, 3, 2, 1] is [1, 2, 3, 4, 5]', () => {
4+
const array = [5, 4, 3, 2, 1]
5+
const res = heapSort(array)
6+
expect(res).toEqual([1, 2, 3, 4, 5])
7+
})
8+
9+
test('The HeapSort of the array [-5, -4, -3, -2, -1] is [-5, -4, -3, -2, -1]', () => {
10+
const array = [-5, -4, -3, -2, -1]
11+
const res = heapSort(array)
12+
expect(res).toEqual([-5, -4, -3, -2, -1])
13+
})
14+
15+
test('The HeapSort of the array [50, 43, 31, 52, 91] is [31, 43, 50, 52, 91]', () => {
16+
const array = [50, 43, 31, 52, 91]
17+
const res = heapSort(array)
18+
expect(res).toEqual([31, 43, 50, 52, 91])
19+
})
20+
21+
test('The HeapSort of the array [] is []', () => {
22+
const array = []
23+
const res = heapSort(array)
24+
expect(res).toEqual([])
25+
})

0 commit comments

Comments
 (0)