Exemplo n.º 1
0
 def test_merge_empty_heap_with_non_empty_heap(self):
     a = MinMaxHeap()
     ls = [-3, 5, 7, 9, 1, 5, 2]
     b = MinMaxHeap(ls)
     self.assertIsNone(a.merge(b))
     self.assertEqual(a.size, len(ls))
     self.assertEqual(b.size, len(ls))
Exemplo n.º 2
0
 def test_merge_non_empty_heap_with_non_empty_heap(self):
     ls = [-3, 5, 7, 9, 1, 5, 2]
     size = len(ls)
     a = MinMaxHeap(ls)
     b = MinMaxHeap(sample(ls, size))
     self.assertIsNone(a.merge(b))
     self.assertEqual(a.size, size * 2)
     self.assertEqual(b.size, size)
Exemplo n.º 3
0
 def test_merge_non_empty_heap_with_empty_heap(self):
     ls = [-3, 5, 7, 9, 1, 5, 2]
     a = MinMaxHeap(ls)
     b = MinMaxHeap()
     self.assertIsNone(a.merge(b))
     self.assertEqual(a.size, len(ls))
     self.assertEqual(b.size, 0)
     self.assertTrue(b.is_empty())
Exemplo n.º 4
0
 def test_merge_empty_heap_with_empty_heap(self):
     a = MinMaxHeap()
     b = MinMaxHeap()
     self.assertIsNone(a.merge(b))