Example #1
0
 def test_merge_empty_heap_with_non_empty_heap(self):
     a = MaxHeap()
     ls = [-3, 5, 7, 9, 1, 5, 2]
     b = MaxHeap(ls)
     self.assertIsNone(a.merge(b))
     self.assertEqual(a.size, len(ls))
     self.assertEqual(b.size, len(ls))
Example #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 = MaxHeap(ls)
     b = MaxHeap(sample(ls, size))
     self.assertIsNone(a.merge(b))
     self.assertEqual(a.size, size * 2)
     self.assertEqual(b.size, size)
Example #3
0
 def test_merge_non_empty_heap_with_empty_heap(self):
     ls = [-3, 5, 7, 9, 1, 5, 2]
     a = MaxHeap(ls)
     b = MaxHeap()
     self.assertIsNone(a.merge(b))
     self.assertEqual(a.size, len(ls))
     self.assertEqual(b.size, 0)
     self.assertTrue(b.is_empty())
Example #4
0
 def test_merge_empty_heap_with_empty_heap(self):
     a = MaxHeap()
     b = MaxHeap()
     self.assertIsNone(a.merge(b))