Exemple #1
0
    def test_add_multiple_elements(self):
        a = [randint(-100, 100) for _ in range(100)]
        h = MinHeap()

        for i, elem in enumerate(a):
            self.assertIsNone(h.add(elem))
            self.assertEqual(h.size, i + 1)

        self.assertFalse(h.is_empty())
        self.assertEqual(h.find_min(), min(a))
Exemple #2
0
 def test_add_add_one(self):
     h = MinHeap()
     self.assertIsNone(h.add(2))
     self.assertEqual(h.size, 1)
     self.assertFalse(h.is_empty())
     self.assertEqual(h.find_min(), 2)