Add bitboard test
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#include "BitBoard.h"
|
#include "BitBoard.hpp"
|
||||||
|
|
||||||
BitBoard::BitBoard(uint64_t v) {
|
BitBoard::BitBoard(uint64_t v) {
|
||||||
mBoard = v;
|
mBoard = v;
|
||||||
|
@@ -31,6 +31,9 @@ public:
|
|||||||
explicit constexpr operator bool() const {
|
explicit constexpr operator bool() const {
|
||||||
return mBoard != 0;
|
return mBoard != 0;
|
||||||
}
|
}
|
||||||
|
explicit constexpr operator unsigned long() const {
|
||||||
|
return mBoard;
|
||||||
|
}
|
||||||
explicit constexpr operator unsigned long long() const {
|
explicit constexpr operator unsigned long long() const {
|
||||||
return mBoard;
|
return mBoard;
|
||||||
}
|
}
|
@@ -5,7 +5,7 @@
|
|||||||
#include "Square.hpp"
|
#include "Square.hpp"
|
||||||
#include "Move.hpp"
|
#include "Move.hpp"
|
||||||
#include "CastlingRights.hpp"
|
#include "CastlingRights.hpp"
|
||||||
#include "BitBoard.h"
|
#include "BitBoard.hpp"
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
22
Tests/BitBoardTest.cpp
Normal file
22
Tests/BitBoardTest.cpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#include "catch2/catch.hpp"
|
||||||
|
|
||||||
|
#include "TestUtils.hpp"
|
||||||
|
|
||||||
|
#include "BitBoard.hpp"
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
TEST_CASE("King attacks are correctly generated", "[Board][Fundamental]") {
|
||||||
|
auto board = BitBoard::fromIndex(G2);
|
||||||
|
board |= BitBoard::fromIndex(B7);
|
||||||
|
|
||||||
|
BitBoard ka = BitBoard::kingAttacks(board);
|
||||||
|
REQUIRE((ka == (
|
||||||
|
BitBoard::fromIndex(G1) | BitBoard::fromIndex(G3) | BitBoard::fromIndex(H1) | BitBoard::fromIndex(H2)
|
||||||
|
| BitBoard::fromIndex(H3) | BitBoard::fromIndex(F1) | BitBoard::fromIndex(F2)
|
||||||
|
| BitBoard::fromIndex(F3) |
|
||||||
|
BitBoard::fromIndex(B8) | BitBoard::fromIndex(B6) | BitBoard::fromIndex(A6)
|
||||||
|
| BitBoard::fromIndex(A7) | BitBoard::fromIndex(A8) | BitBoard::fromIndex(C6)
|
||||||
|
| BitBoard::fromIndex(C7) | BitBoard::fromIndex(C8))));
|
||||||
|
}
|
@@ -8,6 +8,7 @@ add_executable(tests
|
|||||||
BoardTests.cpp
|
BoardTests.cpp
|
||||||
FenTests.cpp
|
FenTests.cpp
|
||||||
EngineTests.cpp
|
EngineTests.cpp
|
||||||
|
BitBoardTest.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(tests cplchess_lib Catch2::Catch2)
|
target_link_libraries(tests cplchess_lib Catch2::Catch2)
|
||||||
|
Reference in New Issue
Block a user