aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-07-26 17:00:49 +0200
committerAdam <adammegarules1@gmail.com>2026-07-26 17:00:49 +0200
commit60637ce41b3f033561343c5735eb16227ef240cf (patch)
tree8a09fcedb007442890b484ccb8877123dcfaf4f5 /tests
parenta2d5bfa42379b2d8087f0910ef9b672fcf5a79f5 (diff)
adding king and formating
Diffstat (limited to 'tests')
-rw-r--r--tests/pawn_moves_test.cpp54
1 files changed, 0 insertions, 54 deletions
diff --git a/tests/pawn_moves_test.cpp b/tests/pawn_moves_test.cpp
deleted file mode 100644
index 47b8ceb..0000000
--- a/tests/pawn_moves_test.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "moves.hpp"
-#include <cassert>
-
-bool HasMove(const std::vector<Move> &moves, int from, int to) {
- Position expectedFrom = IndexToPosition(from);
- Position expectedTo = IndexToPosition(to);
- for (const Move &move : moves) {
- if (move.From.rank == expectedFrom.rank &&
- move.From.file == expectedFrom.file && move.To.rank == expectedTo.rank &&
- move.To.file == expectedTo.file) {
- return true;
- }
- }
- return false;
-}
-
-int CountMovesFrom(const std::vector<Move> &moves, int from) {
- Position expected = IndexToPosition(from);
- int count = 0;
- for (const Move &move : moves) {
- if (move.From.rank == expected.rank && move.From.file == expected.file) {
- count++;
- }
- }
- return count;
-}
-
-int main() {
- board white{};
- white.turn = true;
- white.pieces[52] = createPiece(PAWN, true); // e2
- white.pieces[43] = createPiece(ROOK, false); // d3
- white.pieces[45] = createPiece(ROOK, true); // f3
-
- std::vector<Move> whiteMoves = GetLegalMoves(&white);
- assert(CountMovesFrom(whiteMoves, 52) == 3);
- assert(HasMove(whiteMoves, 52, 44)); // e2-e3
- assert(HasMove(whiteMoves, 52, 36)); // e2-e4
- assert(HasMove(whiteMoves, 52, 43)); // e2xd3
-
- white.pieces[44] = createPiece(KING, true); // block e3 and e4
- std::vector<Move> blockedMoves = GetLegalMoves(&white);
- assert(CountMovesFrom(blockedMoves, 52) == 1);
- assert(HasMove(blockedMoves, 52, 43)); // capture remains legal
-
- board black{};
- black.turn = false;
- black.pieces[12] = createPiece(PAWN, false); // e7
-
- std::vector<Move> blackMoves = GetLegalMoves(&black);
- assert(CountMovesFrom(blackMoves, 12) == 2);
- assert(HasMove(blackMoves, 12, 20)); // e7-e6
- assert(HasMove(blackMoves, 12, 28)); // e7-e5
-}