Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ if(BUILD_TESTING)
FetchContent_MakeAvailable(doctest)

# --- Test executable ---
add_executable(test_chess tests.cpp)
add_executable(test_normal tests.cpp)
add_executable(test_chess960 chess960_tests.cpp)
add_executable(NonImportantTests non_core_tests.cpp)

target_link_libraries(test_chess PRIVATE chesslib doctest::doctest)
target_link_libraries(test_normal PRIVATE chesslib doctest::doctest)
target_link_libraries(NonImportantTests PRIVATE chesslib doctest::doctest)
target_link_libraries(test_chess960 PRIVATE chesslib doctest::doctest)

add_test(NAME test_core COMMAND test_chess)
add_test(NAME api_tests COMMAND NonImportantTests)
add_test(NAME test_normal COMMAND test_normal)
add_test(NAME test_api COMMAND NonImportantTests)
add_test(NAME test_chess960 COMMAND test_chess960)
if (UNIX AND CMAKE_BUILD_TYPE MATCHES "Debug")
set(SANITIZERS "" CACHE STRING "sanitizers such as undefined,address")

Expand Down
5,897 changes: 5,897 additions & 0 deletions chess960_tests.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions moves_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ template <typename T, typename P> Move parseSan(const _Position<T, P> &pos, std:
// 1) Castling shortcuts
if (san == "O-O" || san == "0-0" || san == "O-O+" || san == "0-0+" || san == "O-O#" || san == "0-0#") {
const auto from = pos.kingSq(pos.side_to_move());
const auto to = pos.state().castlingMetadata[pos.side_to_move()].rook_start_ks;
const auto to = pos.getCastlingMetadata(pos.sideToMove()).rook_start_ks;
Move km = chess::Move::make<CASTLING>(from, to);

if (std::find(moves.begin(), moves.end(), km) != moves.end())
Expand All @@ -156,7 +156,7 @@ template <typename T, typename P> Move parseSan(const _Position<T, P> &pos, std:
}
if (san == "O-O-O" || san == "0-0-0" || san == "O-O-O+" || san == "0-0-0+" || san == "O-O-O#" || san == "0-0-0#") {
const auto from = pos.kingSq(pos.side_to_move());
const auto to = pos.state().castlingMetadata[pos.side_to_move()].rook_start_qs;
const auto to = pos.getCastlingMetadata(pos.sideToMove()).rook_start_qs;
Move qm = chess::Move::make<CASTLING>(from, to);

if (std::find(moves.begin(), moves.end(), qm) != moves.end())
Expand Down
29 changes: 19 additions & 10 deletions non_core_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ TEST_CASE("was_into_check") {
};
check_was_into_check<PolyglotPiece>(tests);
check_was_into_check<EnginePiece>(tests);
check_was_into_check<ContiguousMappingPiece>(tests);
}
TEST_CASE("Zobrist mapping?") {
REQUIRE(zobrist::RandomPiece[enum_idx<PolyglotPiece>()][(int)PolyglotPiece::BPAWN][0] == 0x9D39247E33776D41);
Expand All @@ -252,16 +253,24 @@ struct repetitions_t {
};
void check_repetitions(std::vector<TestEntry<repetitions_t, bool>> &tests) {
for (auto &tc : tests) {
_Position<PolyglotPiece> pos(tc.input.FEN);
for (auto &move : tc.input.moves)
pos.doMove(move);
REQUIRE(pos.is_repetition(tc.input.repetition) == tc.info);
}
for (auto &tc : tests) {
_Position<EnginePiece> pos(tc.input.FEN);
for (auto &move : tc.input.moves)
pos.doMove(move);
REQUIRE(pos.is_repetition(tc.input.repetition) == tc.info);
{
_Position<PolyglotPiece> pos(tc.input.FEN);
for (auto &move : tc.input.moves)
pos.doMove(move);
REQUIRE(pos.is_repetition(tc.input.repetition) == tc.info);
}
{
_Position<EnginePiece> pos(tc.input.FEN);
for (auto &move : tc.input.moves)
pos.doMove(move);
REQUIRE(pos.is_repetition(tc.input.repetition) == tc.info);
}
{
_Position<ContiguousMappingPiece> pos(tc.input.FEN);
for (auto &move : tc.input.moves)
pos.doMove(move);
REQUIRE(pos.is_repetition(tc.input.repetition) == tc.info);
}
}
}
TEST_CASE("is_repetition") {
Expand Down
Loading
Loading