コード例 #1
0
 def test_board_5x5(self):
     tt = TicTacToe()
     tt._init_board(5)
     self.assertEqual(tt.size, 5)
     self.assertEqual(tt.board,
                      [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0],
                       [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]])
コード例 #2
0
 def test_display_new_game(self):
     tt = TicTacToe()
     tt._init_board(3)
     expected = "  |   |  \n" \
          "---------\n" \
          "  |   |  \n" \
          "---------\n" \
          "  |   |  \n"
     with patch('sys.stdout', new=StringIO()) as mock_out:
         tt._display_board()
         self.assertEqual(mock_out.getvalue(), expected)
コード例 #3
0
 def test_out_of_bounds(self):
     tt = TicTacToe()
     tt._init_board(3)
     self.assertFalse(tt._out_of_bounds((0, 2)))
コード例 #4
0
 def test_board_3x3(self):
     tt = TicTacToe()
     tt._init_board(3)
     self.assertEqual(tt.size, 3)
     self.assertEqual(tt.board, [[0, 0, 0], [0, 0, 0], [0, 0, 0]])
コード例 #5
0
 def test_board_2x2(self):
     tt = TicTacToe()
     with self.assertRaises(ValueError, msg='Board size 2x2 is invalid.'):
         tt._init_board(2)
コード例 #6
0
 def test_board_neg(self):
     tt = TicTacToe()
     with self.assertRaises(ValueError, msg='Board size -1x-1 is invalid.'):
         tt._init_board(-1)
コード例 #7
0
 def test_out_of_bounds_upper(self):
     tt = TicTacToe()
     tt._init_board(3)
     self.assertTrue(tt._out_of_bounds((0, 3)))
コード例 #8
0
 def test_out_of_bounds_lower(self):
     tt = TicTacToe()
     tt._init_board(3)
     self.assertTrue(tt._out_of_bounds((-1, 0)))