Created
August 24, 2022 08:12
-
-
Save hawaijar/d6d4f0325b84e296bd6c764c3670341b to your computer and use it in GitHub Desktop.
MinHeap Test cases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { MinHeap } from "../MinHeap"; | |
const minHeap = new MinHeap(); | |
describe("Testing MinHeap", () => { | |
minHeap.clearHeap(); | |
let array = [30, 1, 2, 5, 7, 10, 20, 11, 1, 22, 2, 5, 17, 10, 20, -11]; | |
minHeap.buildHeapFromArray(array); | |
let sortedArray = array.sort((a, b) => a - b); | |
for (const number of sortedArray) { | |
it(`should return ${number}`, () => { | |
expect(minHeap.poll()).toBe(number); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment