Skip to content

Commit 583deec

Browse files
committed
Make heapsort test more robust
1 parent 61d3486 commit 583deec

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

data_structures/tests/heap.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ const isSorted = (arr) => {
1717

1818
describe('heapsort', () => {
1919
test('heapsort correctly sorts an array of integers', () => {
20-
const input = generateRandomInput(20, 100);
21-
expect(isSorted(heapsort(input))).toBe(true);
20+
const len = Math.round(Math.random() * 100);
21+
const input = generateRandomInput(len, 1000);
22+
const output = heapsort(input);
23+
24+
expect(output.length).toEqual(len);
25+
expect(isSorted(output)).toBe(true);
2226
});
2327
});

0 commit comments

Comments
 (0)