Example #1
0
    def test_build_heap(self):
        l = range(10, -1, -1)
        MaxHeap.build_heap(l)
        assert l == range(10, -1, -1)

        l = range(11)
        MaxHeap.build_heap(l)
        assert l == [10, 9, 6, 8, 4, 5, 2, 7, 3, 1, 0]
Example #2
0
    def test_sorted(self):
        l = range(10, -1, -1)
        MaxHeap.build_heap(l)
        h = MaxHeap()
        h.items = l

        new_l = []
        h.sorted(lambda i, l: l.append(i), new_l)

        assert new_l == range(10, -1, -1)