Exemplo n.º 1
0
 def test_empty_in_hallway_left_from(self):
     diagram1 = Diagram(Room('.', 11, ['.'] * 11), None, None, None, None)
     self.assertEqual(diagram1.empty_in_hallway_left_from("room_a"), {0, 1})
     self.assertEqual(diagram1.empty_in_hallway_left_from("room_b"),
                      {0, 1, 3})
     self.assertEqual(diagram1.empty_in_hallway_left_from("room_c"),
                      {0, 1, 3, 5})
     self.assertEqual(diagram1.empty_in_hallway_left_from("room_d"),
                      {0, 1, 3, 5, 7})
     diagram2 = Diagram(
         Room('.', 11,
              ['.', '.', '.', 'A', '.', '.', '.', '.', '.', '.', '.']),
         None, None, None, None)
     self.assertEqual(diagram2.empty_in_hallway_left_from("room_a"), {0, 1})
     self.assertEqual(len(diagram2.empty_in_hallway_left_from("room_b")), 0)
     self.assertEqual(diagram2.empty_in_hallway_left_from("room_c"), {5})
     self.assertEqual(diagram2.empty_in_hallway_left_from("room_d"), {5, 7})
     diagram3 = Diagram(
         Room('.', 11,
              ['.', '.', '.', '.', '.', 'A', '.', '.', '.', '.', '.']),
         None, None, None, None)
     self.assertEqual(diagram3.empty_in_hallway_left_from("room_a"), {0, 1})
     self.assertEqual(diagram3.empty_in_hallway_left_from("room_b"),
                      {0, 1, 3})
     self.assertEqual(len(diagram3.empty_in_hallway_left_from("room_c")), 0)
     self.assertEqual(diagram3.empty_in_hallway_left_from("room_d"), {7})
Exemplo n.º 2
0
 def test_vacancy_for(self):
     self.assertIsNone(Room('A', 3, ['A', 'A', 'A']).vacancy_for('A'))
     self.assertIsNone(Room('A', 3, ['A', 'A', 'B']).vacancy_for('A'))
     self.assertIsNone(Room('A', 3, ['A', 'B', '.']).vacancy_for('A'))
     self.assertIsNone(Room('B', 3, ['A', 'B', '.']).vacancy_for('A'))
     self.assertIsNone(Room('B', 3, ['A', 'B', '.']).vacancy_for('B'))
     self.assertIsNone(Room('B', 3, ['.', '.', '.']).vacancy_for('A'))
     self.assertEqual(Room('A', 3, ['.', '.', '.']).vacancy_for('A'), 0)
     self.assertEqual(Room('A', 3, ['A', '.', '.']).vacancy_for('A'), 1)
     self.assertEqual(Room('A', 3, ['A', 'A', '.']).vacancy_for('A'), 2)
Exemplo n.º 3
0
 def test_available_for_move(self):
     self.assertIsNone(Room('A', 3, ['A', 'A', 'A']).available_for_move())
     self.assertIsNone(Room('A', 3, ['A', 'A', '.']).available_for_move())
     self.assertIsNone(Room('A', 3, ['A', '.', '.']).available_for_move())
     self.assertIsNone(Room('A', 3, ['.', '.', '.']).available_for_move())
     self.assertEqual(Room('A', 3, ['B', 'B', 'B']).available_for_move(), 2)
     self.assertEqual(Room('A', 3, ['B', 'B', '.']).available_for_move(), 1)
     self.assertEqual(Room('A', 3, ['B', '.', '.']).available_for_move(), 0)
     self.assertEqual(Room('A', 3, ['B', 'A', '.']).available_for_move(), 1)
     self.assertEqual(Room('A', 3, ['B', 'A', 'A']).available_for_move(), 2)
Exemplo n.º 4
0
 def test_empty_in_hallway_rightleft_from(self):
     diagram1 = Diagram(Room('.', 11, ['.'] * 11), None, None, None, None)
     self.assertEqual(diagram1.empty_in_hallway_right_from("room_a"),
                      {3, 5, 7, 9, 10})
     self.assertEqual(diagram1.empty_in_hallway_right_from("room_b"),
                      {5, 7, 9, 10})
     self.assertEqual(diagram1.empty_in_hallway_right_from("room_c"),
                      {7, 9, 10})
     self.assertEqual(diagram1.empty_in_hallway_right_from("room_d"),
                      {9, 10})
     diagram2 = Diagram(
         Room('.', 11,
              ['.', '.', '.', '.', '.', 'A', '.', '.', '.', '.', '.']),
         None, None, None, None)
     self.assertEqual(diagram2.empty_in_hallway_right_from("room_a"),
                      {3})
     self.assertEqual(len(diagram2.empty_in_hallway_right_from("room_b")),
                      0)
     self.assertEqual(diagram2.empty_in_hallway_right_from("room_c"),
                      {7, 9, 10})
     self.assertEqual(diagram2.empty_in_hallway_right_from("room_d"),
                      {9, 10})
Exemplo n.º 5
0
 def test_complete(self):
     self.assertTrue(Room('A', 4, ['A', 'A', 'A', 'A']).is_complete())
     self.assertFalse(Room('A', 4, ['A', 'A', 'A', '.']).is_complete())
     self.assertFalse(Room('B', 4, ['A', 'A', 'A', 'A']).is_complete())
Exemplo n.º 6
0
 def test_completeness(self):
     self.assertEqual(Room('A', 4, ['A', 'A', 'A', 'A']).completeness(), 4)
     self.assertEqual(Room('A', 4, ['A', 'A', 'A', '.']).completeness(), 3)
     self.assertEqual(Room('B', 4, ['A', 'A', 'A', 'A']).completeness(), 0)
Exemplo n.º 7
0
 def test_empty_count(self):
     self.assertEqual(Room('A', 4, ['A', 'A', 'A', 'A']).empty_count(), 0)
     self.assertEqual(Room('A', 4, ['A', 'A', 'A', '.']).empty_count(), 1)
     self.assertEqual(Room('B', 4, ['A', 'A', 'A', 'A']).empty_count(), 0)