Fix attack to tests
This commit is contained in:
@@ -1,13 +1,8 @@
|
||||
import ctypes
|
||||
from binding.python_c_ffi import Board
|
||||
from binding.python_c_ffi import sq
|
||||
from binding.python_c_ffi import BLACK
|
||||
from binding.python_c_ffi import WHITE
|
||||
from test.base import ChessLibTestBase
|
||||
from test.chess_ffi import get_attackers_to
|
||||
from test.chess_ffi import is_square_attacked
|
||||
from test.chess_ffi import is_in_check
|
||||
from test.chess_ffi import sq
|
||||
from test.chess_ffi import Board
|
||||
from test.chess_ffi import BLACK
|
||||
from test.chess_ffi import WHITE
|
||||
from test.chess_ffi import draw_bb
|
||||
|
||||
|
||||
class TestAttackers(ChessLibTestBase):
|
||||
@@ -50,8 +45,8 @@ class TestAttackers(ChessLibTestBase):
|
||||
for fen, sq_str, by, expected, msg in cases:
|
||||
with self.subTest(msg=msg, fen=fen, sq=sq_str, by=by):
|
||||
b = Board()
|
||||
self.load_fen(fen, board=b)
|
||||
got = bool(is_square_attacked(b, sq(sq_str), by))
|
||||
self.chess_ffi.load_fen(b, fen)
|
||||
got = self.chess_ffi.square_attacked(b, sq(sq_str), by)
|
||||
self.assertEqual(expected, got, msg)
|
||||
|
||||
|
||||
@@ -81,8 +76,8 @@ class TestAttackers(ChessLibTestBase):
|
||||
for fen, side, expected, msg in cases:
|
||||
with self.subTest(msg=msg, fen=fen, side=side):
|
||||
b = Board()
|
||||
self.load_fen(fen, board=b)
|
||||
actual = bool(is_in_check(b, side))
|
||||
self.chess_ffi.load_fen(b, fen)
|
||||
actual = self.chess_ffi.in_check(b, side)
|
||||
self.assertEqual(expected, actual, msg)
|
||||
|
||||
|
||||
@@ -132,7 +127,6 @@ class TestAttackers(ChessLibTestBase):
|
||||
for fen, sq_str, by, expected_cnt, msg in cases:
|
||||
with self.subTest(msg=msg, fen=fen, sq=sq_str, by=by):
|
||||
b = Board()
|
||||
self.load_fen(fen, board=b)
|
||||
|
||||
mask = get_attackers_to(b, sq(sq_str), by)
|
||||
self.chess_ffi.load_fen(b, fen)
|
||||
mask = self.chess_ffi.attackers_to(b, sq(sq_str), by)
|
||||
self.assertEqual(expected_cnt, int(mask).bit_count())
|
||||
Reference in New Issue
Block a user