def test_win_eq(self): """ test win eq """ game = Pentago() for pos in winpos[0]: game.setpoint(*pos, game.BLACK) for pos in winpos[1]: game.setpoint(*pos, game.WHITE) game.check_win() self.assertEqual(game.winner, game.VOID)
def test_win_all_combinations(self): """ test win """ for color in (Pentago.BLACK, Pentago.WHITE): for poss in winpos: game = Pentago() for pos in poss: game.setpoint(*pos, color) game.check_win() self.assertEqual(game.winner, color)
def test_rotate(self): """ test rotate """ game = Pentago() # init game.setpoint(0, 0, 1) self.assertEqual(game.getpoint(0, 0), 1) # rotate game.rotate(0, 1) # trigo self.assertEqual(game.getpoint(0, 2), 1) self.assertEqual(game.getpoint(0, 0), game.VOID) # rotate game.rotate(0, 0) # anti trigo self.assertEqual(game.getpoint(0, 0), 1) self.assertEqual(game.getpoint(0, 2), game.VOID)
def test_set_get(self): """ test set get """ mat = [[1, 2, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 1, 1, 0, 2, 0], [0, 1, 1, 0, 2, 0], [0, 1, 1, 0, 2, 0]] game = Pentago() # set for y, line in enumerate(mat): for x, value in enumerate(line): if value != game.VOID: game.setpoint(x, y, value) # get for y, line in enumerate(mat): for x, value in enumerate(line): self.assertEqual(game.getpoint(x, y), value)