def test3(self): pq = min_PQ() pq.heap = [1, 3, 5] min = pq.remove_min() self.assertEqual(min, 1) self.assertEqual(len(pq.heap), 2) self.assertEqual(pq.heap, [3, 5])
def test4(self): pq = min_PQ() pq.heap = [1, 2, 3, 4, 5, 6, 7] try: pq.check_invariant() except RuntimeError(): self.fail('Unexpected - heap invariant violated')
def test2(self): pq = min_PQ() pq.heap = [5, 10] min = pq.remove_min() self.assertEqual(min, 5) self.assertEqual(len(pq.heap), 1) self.assertEqual(pq.heap, [10])
def test2(self): pq = min_PQ() pq.heap = [68] try: pq.check_invariant() except RuntimeError: self.fail('Unexpected - heap invariant violated')
def test5(self): pq = min_PQ() pq.heap = [1, 3, 5, 10, 11, 6] min = pq.remove_min() self.assertEqual(min, 1) self.assertEqual(len(pq.heap), 5) self.assertEqual(pq.heap, [3, 6, 5, 10, 11])
def test4(self): pq = min_PQ() pq.heap = [1, 3, 5, 6, 4, 8] min = pq.remove_min() self.assertEqual(min, 1) self.assertEqual(len(pq.heap), 5) self.assertEqual(pq.heap, [3, 4, 5, 6, 8])
def test1(self): pq = min_PQ() self.assertRaises(IndexError, pq.remove_min)
def test4(self): pq = min_PQ() pq.heap = [5, 8, 11, 13, 14, 12, 17, 19] pq.insert(10) self.assertEqual(len(pq.heap), 9) self.assertEqual(pq.heap, [5, 8, 11, 10, 14, 12, 17, 19, 13])
def test3(self): pq = min_PQ() pq.heap = [2, 5, 7, 8, 9] pq.insert(1) self.assertEqual(len(pq.heap), 6) self.assertEqual(pq.heap, [1, 5, 2, 8, 9, 7])
def test2(self): pq = min_PQ() pq.heap = [5] pq.insert(7) self.assertEqual(len(pq.heap), 2) self.assertEqual(pq.heap, [5, 7])
def test1(self): pq = min_PQ() pq.insert(10) self.assertEqual(len(pq.heap), 1) self.assertEqual(pq.heap, [10])
def test3(self): pq = min_PQ() pq.heap = [2, 3, 5, 4, 1, 6] self.assertRaises(RuntimeError, pq.check_invariant)