예제 #1
0
 def test_seating_arrangement__select_seat_left_even_length(self):
     sa = SeatingArrangement(first_index=1)
     length = 6
     index = 2
     sa.seats_left = [(-length, index)]
     actual = sa._select_seat(10)
     expectation = (center_left_index(length) + index, index, length)
     self.assertEqual(expectation, actual)
예제 #2
0
 def test_seating_arrangement__select_seat_left_length_longer(self):
     sa = SeatingArrangement(first_index=1)
     length = 7
     index = 4
     sa.seats_left = [(-6, 3), (-5, 2), (-length, index), (-5, 5)]
     heapq.heapify(sa.seats_left)
     actual = sa._select_seat(30)
     expectation = (center_left_index(length) + index, index, length)
     self.assertEqual(expectation, actual)
예제 #3
0
 def test_seating_arrangement__select_seat_left_putting_left_length(self):
     sa = SeatingArrangement(first_index=1)
     length = 3
     index = 2
     sa.seats_left = [(-length, 3), (-length, index), (-length, 4),
                      (-length, 5)]
     heapq.heapify(sa.seats_left)
     actual = sa._select_seat(20)
     expectation = (center_left_index(length) + index, index, length)
     self.assertEqual(expectation, actual)
예제 #4
0
 def test_center_left_index(self):
     expectations = [0, 0, 1, 1, 2, 2, 3]
     for i, expectation in enumerate(expectations):
         with self.subTest(length=i + 1):
             actual = center_left_index(i + 1)
             self.assertEqual(expectation, actual)