def test_remove_min_when_heap_has_random_size(self): size = randint(3, 100) a = [randint(-100, 100) for _ in range(size)] h = MinHeap(a) m = min(a) self.assertEqual(h.remove_min(), m) self.assertFalse(h.is_empty()) self.assertEqual(h.size, size - 1)
def test_remove_min_when_heap_has_size_1(self): h = MinHeap([13]) self.assertEqual(h.remove_min(), 13) self.assertTrue(h.is_empty()) self.assertEqual(h.size, 0)
def test_remove_min_when_heap_has_size_2(self): h = MinHeap([11, 13]) self.assertEqual(h.remove_min(), 11) self.assertFalse(h.is_empty()) self.assertEqual(h.size, 1)
def test_remove_min_when_empty_heap(self): h = MinHeap() self.assertIsNone(h.remove_min())