Attacks: add unit tests for near edge of board

This commit is contained in:
Sampo Silvennoinen
2024-03-28 19:01:32 +02:00
committed by Sampo Silvennoinen
parent 394b21b842
commit 3198d75c80
+56
View File
@@ -16,6 +16,20 @@ void main() {
expect(kingAttacks(21), attacks);
});
test('King attacks in near edges', () {
final attacks = makeSquareSet('''
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . 1 1
. . . . . . 1 .
''');
expect(kingAttacks(7), attacks);
});
test('Knight attacks', () {
final attacks = makeSquareSet('''
. . . . . . . .
@@ -30,6 +44,20 @@ void main() {
expect(knightAttacks(35), attacks);
});
test('Knight attacks near edges', () {
final attacks = makeSquareSet('''
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . 1 . 1
. . . . 1 . . .
. . . . . . . .
. . . . 1 . . .
''');
expect(knightAttacks(14), attacks);
});
test('White pawn attacks', () {
final attacks = makeSquareSet('''
. . . . . . . .
@@ -44,6 +72,20 @@ void main() {
expect(pawnAttacks(Side.white, 11), attacks);
});
test('White pawn attacks near edges', () {
final attacks = makeSquareSet('''
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. 1 . . . . . .
. . . . . . . .
. . . . . . . .
''');
expect(pawnAttacks(Side.white, 8), attacks);
});
test('Black pawn attacks', () {
final attacks = makeSquareSet('''
. . . . . . . .
@@ -58,6 +100,20 @@ void main() {
expect(pawnAttacks(Side.black, 36), attacks);
});
test('Black pawn attacks near edges', () {
final attacks = makeSquareSet('''
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . 1 .
. . . . . . . .
. . . . . . . .
. . . . . . . .
''');
expect(pawnAttacks(Side.black, 39), attacks);
});
test('bishop attacks, empty board', () {
expect(bishopAttacks(27, SquareSet.empty), makeSquareSet('''
. . . . . . . 1