def test_black_corner_territory_on_5x5_board(self): board = Board([" B ", " B B ", "B W B", " W W ", " W "]) stone, territory = board.territory(x=0, y=1) self.assertEqual(stone, BLACK) self.assertSetEqual(territory, {(0, 0), (0, 1), (1, 0)})
def test_invalid_because_y_is_too_high_for_5x5_board(self): board = Board([" B ", " B B ", "B W B", " W W ", " W "]) with self.assertRaisesWithMessage(ValueError): board.territory(x=1, y=5)
def test_a_stone_and_not_a_territory_on_5x5_board(self): board = Board([" B ", " B B ", "B W B", " W W ", " W "]) stone, territory = board.territory(x=1, y=1) self.assertEqual(stone, NONE) self.assertSetEqual(territory, set())
def test_open_corner_territory_on_5x5_board(self): board = Board([" B ", " B B ", "B W B", " W W ", " W "]) stone, territory = board.territory(x=1, y=4) self.assertEqual(stone, NONE) self.assertSetEqual(territory, {(0, 3), (0, 4), (1, 4)})
def test_white_center_territory_on_5x5_board(self): board = Board([" B ", " B B ", "B W B", " W W ", " W "]) stone, territory = board.territory(x=2, y=3) self.assertEqual(stone, WHITE) self.assertSetEqual(territory, {(2, 3)})
def test_invalid_because_y_is_too_high_for_5x5_board(self): board = Board([" B ", " B B ", "B W B", " W W ", " W "]) with self.assertRaises(ValueError) as err: board.territory(x=1, y=5) self.assertEqual(type(err.exception), ValueError) self.assertEqual(err.exception.args[0], "Invalid coordinate")