def test_in_order_traversal(self): print("Running test_in_order_traversal") airport = Airport(100) a1 = airport.bounded_insert(2000, "TOP") a2 = airport.bounded_insert(1000, "TIP") a3 = airport.bounded_insert(2500, "RIC") a4 = airport.bounded_insert(500, "KRO") a5 = airport.bounded_insert(1800, "LLE") order = airport.in_order_traversal() ground_truth = [a4, a2, a5, a1, a3] for element in order: # Check if there are still elements that could be processed self.assertTrue(len(ground_truth) > 0) gt = ground_truth.pop(0) self.assertEqual(element, gt) # All elements should have been processed. self.assertTrue(len(ground_truth) == 0)
def test_airport_bounded_insert(self): print("Running test_airport_bounded_insert") airport = Airport(100) airport.bounded_insert(1080, "TOP") airport.bounded_insert(700, "TIP") airport.bounded_insert(1300, "RIC") airport.bounded_insert(500, "KRO") airport.bounded_insert(900, "LLE") airport.bounded_insert(1180, "DDD") self.assertEqual(str(airport), "500/KRO 700/TIP 900/LLE 1080/TOP 1180/DDD 1300/RIC") airport.bounded_insert(990, "THU") self.assertEqual( str(airport), "500/KRO 700/TIP 900/LLE 1080/TOP 1180/DDD 1300/RIC 1400/THU")