Beispiel #1
0
	def test_build_heap(self):
		l = range(10, -1, -1)
		Heap.build_heap(l)
		self.assertEqual(l, [0, 1, 4, 2, 6, 5, 8, 3, 7, 9, 10])

		l = range(11)
		Heap.build_heap(l)
		assert l == range(11)
Beispiel #2
0
	def test_sorted(self):
		l = range(10, -1, -1)
		Heap.build_heap(l)
		h = Heap()
		h.items = l

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

		# TODO: Fix assert fail here owing to bug in remove()
		# when bubble_down() is incorrect due to one/both of L-R not present
		assert new_l == range(11)