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