Exemplo n.º 1
0
 def test_get_rows_bottom_left(self):
     board = Board()
     rows = board.get_rows(0, 0)
     self.assertEqual(rows,
                      [[(0, 0), (1, 0), (2, 0),
                        (3, 0)], [(0, 0), (0, 1), (0, 2),
                                  (0, 3)], [(0, 0), (1, 1), (2, 2),
                                            (3, 3)]])
Exemplo n.º 2
0
 def test_get_rows_mid(self):
     board = Board(3)
     rows = board.get_rows(1, 1)
     self.assertEqual(rows,
                      [[(0, 1), (1, 1),
                        (2, 1)], [(1, 0), (1, 1),
                                  (1, 2)], [(0, 0), (1, 1),
                                            (2, 2)], [(0, 2), (1, 1),
                                                      (2, 0)]])
Exemplo n.º 3
0
 def test_put_simple(self):
     board = Board(2)
     piece = Piece.from_attributes(True, False)
     board.put(piece, 1, 1)
     with self.assertRaises(Exception):
         board.put(piece, 1, 1)
Exemplo n.º 4
0
 def test_get_simple_bad(self):
     board = Board(2)
     for x, y in [(1, 5), (5, 1), (-1, 2), (3, -2)]:
         with self.assertRaises(Exception):
             board.get(x, y)
Exemplo n.º 5
0
 def test_get_simple(self):
     board = Board(2)
     for x in range(2):
         for y in range(2):
             self.assertEqual(board.get(x, y), None)
Exemplo n.º 6
0
 def test_get_rows_mid_right(self):
     board = Board()
     rows = board.get_rows(3, 2)
     self.assertEqual(rows, [[(0, 2), (1, 2), (2, 2),
                              (3, 2)], [(3, 0), (3, 1), (3, 2), (3, 3)]])
Exemplo n.º 7
0
 def test_setup_specify_size(self):
     board = Board(3)
     self.assertEqual(len(board.positions), 3)
     for column in board.positions:
         self.assertEqual(len(column), 3)
Exemplo n.º 8
0
 def test_setup(self):
     board = Board()
     self.assertEqual(len(board.positions), 4)
     for column in board.positions:
         self.assertEqual(len(column), 4)