private void testClear(BasicHeap <DSInteger> the_heap) { Assert.AreEqual(false, the_heap.isEmpty()); Assert.AreEqual(true, the_heap.size() > 0); the_heap.clear(); Assert.AreEqual(true, the_heap.isEmpty()); Assert.AreEqual(0, the_heap.size()); }
private void testDeleteMin(BasicHeap <DSInteger> the_heap) { //removing of the default items handled in testAdd() while (!the_heap.isEmpty()) { the_heap.deleteMin(); } Assert.AreEqual(null, the_heap.deleteMin()); Assert.AreEqual(true, the_heap.isEmpty()); //adding items after all are removed, then check for correct state the_heap.add(new DSInteger(5)); Assert.AreEqual(5, the_heap.deleteMin().value); Assert.AreEqual(null, the_heap.deleteMin()); Assert.AreEqual(true, the_heap.isEmpty()); Assert.AreEqual(true, the_heap.isEmpty()); }
private void testSize(BasicHeap <DSInteger> the_heap) { //check initial size Assert.AreEqual(12, the_heap.size()); //make sure the size alters when removing the_heap.deleteMin(); Assert.AreEqual(11, the_heap.size()); //make sure the size reduces itself to zero while (!the_heap.isEmpty()) { the_heap.deleteMin(); } Assert.AreEqual(0, the_heap.size()); //make sure the size does not go below 0 the_heap.deleteMin(); Assert.AreEqual(0, the_heap.size()); }
/// <summary> /// Shows whether there are elements in the heap. /// </summary> /// <returns>true if no elements exist, otherwise false.</returns> public bool isEmpty() { return(my_heap.isEmpty()); }