From be56abc7509a3f6617843b5abd9556863ba4c4f0 Mon Sep 17 00:00:00 2001 From: Baptiste Penot Date: Sat, 24 Oct 2026 14:47:23 +0200 Subject: [PATCH 1/3] created bitbishop:: root namespace for library code and bitbishop::testing:: for testing code --- include/bitbishop/attacks/bishop_attacks.hpp | 4 ++++ include/bitbishop/attacks/checkers.hpp | 4 ++++ include/bitbishop/attacks/generate_attacks.hpp | 4 ++++ include/bitbishop/attacks/queen_attacks.hpp | 4 ++++ include/bitbishop/attacks/rook_attacks.hpp | 4 ++++ include/bitbishop/bitboard.hpp | 4 ++++ include/bitbishop/bitmasks.hpp | 4 ++++ include/bitbishop/board.hpp | 4 ++++ include/bitbishop/color.hpp | 12 ++++++++---- include/bitbishop/constants.hpp | 4 ++++ include/bitbishop/engine/evaluation.hpp | 4 ++++ include/bitbishop/engine/search.hpp | 4 ++++ include/bitbishop/interface/search_reporter.hpp | 4 ++++ include/bitbishop/interface/search_session.hpp | 4 ++++ include/bitbishop/interface/search_worker.hpp | 4 ++++ include/bitbishop/interface/uci_command_channel.hpp | 4 ++++ include/bitbishop/interface/uci_command_registry.hpp | 4 ++++ include/bitbishop/interface/uci_engine.hpp | 4 ++++ include/bitbishop/lookups/attackers.hpp | 4 ++++ include/bitbishop/lookups/between_squares.hpp | 4 ++++ include/bitbishop/lookups/bishop_rays.hpp | 4 ++++ include/bitbishop/lookups/king_attacks.hpp | 6 +++++- include/bitbishop/lookups/knight_attacks.hpp | 6 +++++- include/bitbishop/lookups/pawn_attacks.hpp | 4 ++++ include/bitbishop/lookups/queen_rays.hpp | 4 ++++ include/bitbishop/lookups/rook_rays.hpp | 4 ++++ include/bitbishop/move.hpp | 4 ++++ include/bitbishop/movegen/bishop_moves.hpp | 4 ++++ include/bitbishop/movegen/castling_moves.hpp | 4 ++++ include/bitbishop/movegen/check_mask.hpp | 4 ++++ include/bitbishop/movegen/king_moves.hpp | 4 ++++ include/bitbishop/movegen/knight_moves.hpp | 4 ++++ include/bitbishop/movegen/legal_moves.hpp | 4 ++++ include/bitbishop/movegen/pawn_moves.hpp | 4 ++++ include/bitbishop/movegen/pins.hpp | 4 ++++ include/bitbishop/movegen/queen_moves.hpp | 4 ++++ include/bitbishop/movegen/rook_moves.hpp | 4 ++++ include/bitbishop/moves/move_builder.hpp | 4 ++++ include/bitbishop/moves/move_effect.hpp | 4 ++++ include/bitbishop/moves/move_execution.hpp | 4 ++++ include/bitbishop/moves/position.hpp | 4 ++++ include/bitbishop/piece.hpp | 4 ++++ include/bitbishop/random.hpp | 4 ++++ include/bitbishop/square.hpp | 4 ++++ include/bitbishop/tools/perft.hpp | 4 ++++ include/bitbishop/tools/time_guard.hpp | 4 ++++ include/bitbishop/zobrist.hpp | 4 ++++ main/bitbishop.cpp | 2 +- src/bitbishop/attacks/bishop_attacks.cpp | 4 ++++ src/bitbishop/attacks/checkers.cpp | 4 ++++ src/bitbishop/attacks/queen_attacks.cpp | 4 ++++ src/bitbishop/attacks/rook_attacks.cpp | 4 ++++ src/bitbishop/bitboard.cpp | 4 ++++ src/bitbishop/board.cpp | 4 ++++ src/bitbishop/engine/evaluation.cpp | 4 ++++ src/bitbishop/engine/search.cpp | 4 ++++ src/bitbishop/interface/search_reporter.cpp | 4 ++++ src/bitbishop/interface/search_session.cpp | 4 ++++ src/bitbishop/interface/search_worker.cpp | 4 ++++ src/bitbishop/interface/uci_command_channel.cpp | 4 ++++ src/bitbishop/interface/uci_command_registry.cpp | 4 ++++ src/bitbishop/interface/uci_engine.cpp | 4 ++++ src/bitbishop/move.cpp | 6 +++++- src/bitbishop/movegen/check_mask.cpp | 4 ++++ src/bitbishop/movegen/pins.cpp | 4 ++++ src/bitbishop/moves/move_builder.cpp | 4 ++++ src/bitbishop/moves/move_effect.cpp | 4 ++++ src/bitbishop/moves/move_execution.cpp | 4 ++++ src/bitbishop/moves/position.cpp | 4 ++++ src/bitbishop/tools/perft.cpp | 12 ++++++++++-- src/bitbishop/tools/time_guard.cpp | 4 ++++ src/bitbishop/zobrist.cpp | 4 ++++ .../attacks/checkers/test_compute_checkers.cpp | 4 ++++ .../attacks/test_bishop_north_east_attacks.cpp | 4 ++++ .../attacks/test_bishop_north_west_attacks.cpp | 4 ++++ .../attacks/test_bishop_south_east_attacks.cpp | 4 ++++ .../attacks/test_bishop_south_west_attacks.cpp | 4 ++++ tests/bitbishop/attacks/test_generate_attacks.cpp | 4 ++++ tests/bitbishop/attacks/test_rook_east_attacks.cpp | 6 +++++- tests/bitbishop/attacks/test_rook_north_attacks.cpp | 6 +++++- tests/bitbishop/attacks/test_rook_south_attacks.cpp | 4 ++++ tests/bitbishop/attacks/test_rook_west_attacks.cpp | 4 ++++ tests/bitbishop/bitboard/test_bb_any.cpp | 4 ++++ tests/bitbishop/bitboard/test_bb_bitshifts_ops.cpp | 4 ++++ tests/bitbishop/bitboard/test_bb_bitwise_ops.cpp | 4 ++++ tests/bitbishop/bitboard/test_bb_bool_op.cpp | 6 +++++- tests/bitbishop/bitboard/test_bb_constructors.cpp | 4 ++++ tests/bitbishop/bitboard/test_bb_count.cpp | 4 ++++ tests/bitbishop/bitboard/test_bb_equality_ops.cpp | 4 ++++ tests/bitbishop/bitboard/test_bb_iterator.cpp | 4 ++++ tests/bitbishop/bitboard/test_bb_lsb.cpp | 4 ++++ tests/bitbishop/bitboard/test_bb_msb.cpp | 4 ++++ tests/bitbishop/bitboard/test_bb_pop_lsb.cpp | 4 ++++ tests/bitbishop/bitboard/test_bb_pop_msb.cpp | 4 ++++ tests/bitbishop/bitboard/test_bb_print.cpp | 4 ++++ .../bitboard/test_bb_set_test_clear_reset.cpp | 4 ++++ tests/bitbishop/board/test_b_black_pieces.cpp | 4 ++++ tests/bitbishop/board/test_b_board_state.cpp | 4 ++++ tests/bitbishop/board/test_b_can_castle_kingside.cpp | 4 ++++ .../bitbishop/board/test_b_can_castle_queenside.cpp | 4 ++++ tests/bitbishop/board/test_b_constructors.cpp | 4 ++++ tests/bitbishop/board/test_b_en_passant_square.cpp | 4 ++++ tests/bitbishop/board/test_b_enemy.cpp | 4 ++++ tests/bitbishop/board/test_b_equality_operators.cpp | 4 ++++ tests/bitbishop/board/test_b_friendly.cpp | 6 +++++- tests/bitbishop/board/test_b_get_fen.cpp | 6 +++++- tests/bitbishop/board/test_b_get_piece_bitboard.cpp | 4 ++++ .../board/test_b_has_insufficient_material.cpp | 4 ++++ tests/bitbishop/board/test_b_king_square.cpp | 4 ++++ tests/bitbishop/board/test_b_move_piece.cpp | 4 ++++ tests/bitbishop/board/test_b_occupied.cpp | 6 +++++- tests/bitbishop/board/test_b_print.cpp | 6 +++++- .../bitbishop/board/test_b_set_get_remove_piece.cpp | 4 ++++ tests/bitbishop/board/test_b_stream_ops.cpp | 4 ++++ tests/bitbishop/board/test_b_unoccupied.cpp | 4 ++++ tests/bitbishop/board/test_b_white_pieces.cpp | 4 ++++ tests/bitbishop/board/test_b_zobrist_hash.cpp | 4 ++++ .../evaluation/test_compute_score_from_psqt.cpp | 5 +++++ tests/bitbishop/engine/evaluation/test_evaluate.cpp | 4 ++++ .../engine/evaluation/test_evaluate_material.cpp | 4 ++++ .../engine/evaluation/test_evaluate_psqt.cpp | 4 ++++ .../bitbishop/engine/evaluation/test_flip_index.cpp | 6 +++++- tests/bitbishop/engine/evaluation/test_flip_psqt.cpp | 4 ++++ tests/bitbishop/engine/search/test_negamax.cpp | 4 ++++ tests/bitbishop/helpers/async.hpp | 4 ++++ tests/bitbishop/helpers/blocking_stream.hpp | 4 ++++ tests/bitbishop/helpers/moves.hpp | 4 ++++ tests/bitbishop/helpers/repetition.hpp | 4 ++++ tests/bitbishop/interface/test_search_limits.cpp | 6 +++++- tests/bitbishop/interface/test_search_reporter.cpp | 4 ++++ tests/bitbishop/interface/test_search_session.cpp | 4 ++++ tests/bitbishop/interface/test_search_worker.cpp | 4 ++++ tests/bitbishop/interface/test_split.cpp | 4 ++++ .../bitbishop/interface/test_uci_command_channel.cpp | 4 ++++ .../interface/test_uci_command_registry.cpp | 4 ++++ tests/bitbishop/interface/test_uci_engine.cpp | 4 ++++ tests/bitbishop/lookups/test_attackers.cpp | 4 ++++ .../test_between_squares/test_between_lookup.cpp | 4 ++++ .../lookups/test_between_squares/test_direction.cpp | 4 ++++ .../test_between_squares/test_ray_between.cpp | 4 ++++ tests/bitbishop/lookups/test_bishop_rays.cpp | 4 ++++ tests/bitbishop/lookups/test_king_attacks.cpp | 4 ++++ tests/bitbishop/lookups/test_knight_attacks.cpp | 6 +++++- tests/bitbishop/lookups/test_pawn_attacks.cpp | 4 ++++ tests/bitbishop/lookups/test_queen_rays.cpp | 4 ++++ tests/bitbishop/lookups/test_rook_rays.cpp | 4 ++++ tests/bitbishop/movegen/test_bishop_moves.cpp | 4 ++++ tests/bitbishop/movegen/test_castling_moves.cpp | 4 ++++ tests/bitbishop/movegen/test_check_mask.cpp | 4 ++++ tests/bitbishop/movegen/test_king_moves.cpp | 4 ++++ tests/bitbishop/movegen/test_knight_moves.cpp | 4 ++++ tests/bitbishop/movegen/test_legal_capture_moves.cpp | 4 ++++ tests/bitbishop/movegen/test_legal_moves.cpp | 4 ++++ .../test_pawn_moves/test_add_pawn_promotions.cpp | 4 ++++ .../test_pawn_moves/test_can_capture_en_passant.cpp | 4 ++++ .../test_generate_pawn_legal_moves.cpp | 4 ++++ .../test_pawn_moves/test_is_promotion_rank.cpp | 4 ++++ .../test_pawn_moves/test_is_starting_rank.cpp | 6 +++++- .../movegen/test_pins/test_compute_pins.cpp | 4 ++++ .../test_pins/test_pin_ray/test_first_blocker.cpp | 4 ++++ .../test_pins/test_pin_ray/test_matches_slider.cpp | 4 ++++ .../movegen/test_pins/test_scan_pin_ray.cpp | 4 ++++ tests/bitbishop/movegen/test_queen_moves.cpp | 4 ++++ tests/bitbishop/movegen/test_rook_moves.cpp | 4 ++++ tests/bitbishop/moves/test_move_builder.cpp | 4 ++++ tests/bitbishop/moves/test_move_effect.cpp | 4 ++++ tests/bitbishop/moves/test_move_execution.cpp | 3 +++ tests/bitbishop/moves/test_position.cpp | 4 ++++ tests/bitbishop/piece/test_piece_color.cpp | 4 ++++ tests/bitbishop/piece/test_piece_comparison_op.cpp | 4 ++++ tests/bitbishop/piece/test_piece_constructors.cpp | 4 ++++ tests/bitbishop/piece/test_piece_is_promotion.cpp | 4 ++++ tests/bitbishop/piece/test_piece_name.cpp | 4 +++- tests/bitbishop/piece/test_piece_to_char.cpp | 4 ++++ tests/bitbishop/piece/test_piece_type.cpp | 4 ++++ .../piece/test_pieces_namespace_constants.cpp | 4 ++++ tests/bitbishop/test_color.cpp | 4 ++++ tests/bitbishop/test_move.cpp | 6 ++++++ tests/bitbishop/test_random.cpp | 6 ++++++ tests/bitbishop/test_square.cpp | 4 ++++ tests/bitbishop/test_zobrist.cpp | 4 ++++ tests/bitbishop/tools/test_perft.cpp | 6 +++++- tests/bitbishop/tools/test_perft_divide.cpp | 6 +++++- tests/bitbishop/tools/test_time_guard.cpp | 6 +++++- 184 files changed, 763 insertions(+), 25 deletions(-) diff --git a/include/bitbishop/attacks/bishop_attacks.hpp b/include/bitbishop/attacks/bishop_attacks.hpp index 2996893d..438c9a8c 100644 --- a/include/bitbishop/attacks/bishop_attacks.hpp +++ b/include/bitbishop/attacks/bishop_attacks.hpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop { + /** * @brief Computes bishop attacks along the northeast diagonal. * @@ -67,3 +69,5 @@ Bitboard bishop_south_west_attacks(Square from, const Bitboard& occupied); * @return Bitboard of all squares attacked by the bishop */ Bitboard bishop_attacks(Square from, const Bitboard& occupied); + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/attacks/checkers.hpp b/include/bitbishop/attacks/checkers.hpp index 66913cac..1090ec0c 100644 --- a/include/bitbishop/attacks/checkers.hpp +++ b/include/bitbishop/attacks/checkers.hpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop { + /** * @brief Computes the set of enemy pieces currently giving check to a king. * @@ -21,3 +23,5 @@ * @return Bitboard of checking piece squares */ Bitboard compute_checkers(const Board& board, Square king_sq, Color attacker); + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/attacks/generate_attacks.hpp b/include/bitbishop/attacks/generate_attacks.hpp index 1baac20d..50c117db 100644 --- a/include/bitbishop/attacks/generate_attacks.hpp +++ b/include/bitbishop/attacks/generate_attacks.hpp @@ -11,6 +11,8 @@ #include #include +namespace bitbishop { + /** * @brief Computes the set of squares attacked by all pieces of a given side, * assuming the opposing king is not present on the board. @@ -76,3 +78,5 @@ inline Bitboard generate_attacks(const Board& board, Color enemy) { return attacks; } + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/attacks/queen_attacks.hpp b/include/bitbishop/attacks/queen_attacks.hpp index 2eeaa8c9..56e03797 100644 --- a/include/bitbishop/attacks/queen_attacks.hpp +++ b/include/bitbishop/attacks/queen_attacks.hpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop { + /** * @brief Computes all queen attacks from a square, given board occupancy. * @@ -24,3 +26,5 @@ * @return Bitboard of all squares attacked by the queen */ Bitboard queen_attacks(Square from, const Bitboard& occupied); + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/attacks/rook_attacks.hpp b/include/bitbishop/attacks/rook_attacks.hpp index 0f642670..d1ce461d 100644 --- a/include/bitbishop/attacks/rook_attacks.hpp +++ b/include/bitbishop/attacks/rook_attacks.hpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop { + /** * @brief Computes rook attacks along the north direction. * @@ -73,3 +75,5 @@ Bitboard rook_west_attacks(Square from, const Bitboard& occupied); * @return Bitboard of all squares attacked by the rook */ Bitboard rook_attacks(Square from, const Bitboard& occupied); + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/bitboard.hpp b/include/bitbishop/bitboard.hpp index f8654d25..443e1445 100644 --- a/include/bitbishop/bitboard.hpp +++ b/include/bitbishop/bitboard.hpp @@ -7,6 +7,8 @@ #include #include +namespace bitbishop { + /** * @class Bitboard * @brief Wrapper around a 64-bit unsigned integer to represent a bitboard. @@ -438,3 +440,5 @@ class Bitboard { */ [[nodiscard]] static CX_FN Iterator end() noexcept { return Iterator(0ULL); } }; + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/bitmasks.hpp b/include/bitbishop/bitmasks.hpp index bfde9780..a0407567 100644 --- a/include/bitbishop/bitmasks.hpp +++ b/include/bitbishop/bitmasks.hpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop { + /** * @namespace Bitmasks * @brief Defines precomputed bitmasks that can be applied during move generation. @@ -118,3 +120,5 @@ CX_INLINE uint64_t RANK_7 = 0x00FF000000000000ULL; CX_INLINE uint64_t RANK_8 = 0xFF00000000000000ULL; } // namespace Bitmasks + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/board.hpp b/include/bitbishop/board.hpp index a7d9aa1d..5252f671 100644 --- a/include/bitbishop/board.hpp +++ b/include/bitbishop/board.hpp @@ -9,6 +9,8 @@ #include #include +namespace bitbishop { + struct BoardState { bool m_is_white_turn; ///< True if it is White's turn std::optional m_en_passant_sq; ///< En passant target square, or nullopt if none @@ -368,3 +370,5 @@ class Board { */ [[nodiscard]] bool operator!=(const Board& other) const noexcept; }; + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/color.hpp b/include/bitbishop/color.hpp index 0e28049d..36d6b373 100644 --- a/include/bitbishop/color.hpp +++ b/include/bitbishop/color.hpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop { + /** * @brief Depicts possible piece colors in the chess game. * @@ -59,6 +61,8 @@ CX_VALUE static std::size_t SIZE = 2; } // namespace ColorUtil +} // namespace bitbishop + /** * @brief Custom formatter for Color enum to enable std::format support. * @@ -74,7 +78,7 @@ CX_VALUE static std::size_t SIZE = 2; * @endcode */ template <> -struct std::formatter { +struct std::formatter { /** * @brief Parses the format specification (currently no custom format options). * @@ -94,12 +98,12 @@ struct std::formatter { * @param ctx The format context * @return Iterator to the end of the formatted output */ - auto static format(Color color, format_context& ctx) { + auto static format(bitbishop::Color color, format_context& ctx) { string_view name = "unknown"; switch (color) { // clang-format off - case Color::BLACK: name = "black"; break; - case Color::WHITE: name = "white"; break; + case bitbishop::Color::BLACK: name = "black"; break; + case bitbishop::Color::WHITE: name = "white"; break; // clang-format on } return std::format_to(ctx.out(), "{}", name); diff --git a/include/bitbishop/constants.hpp b/include/bitbishop/constants.hpp index 65768de6..1f24efde 100644 --- a/include/bitbishop/constants.hpp +++ b/include/bitbishop/constants.hpp @@ -2,6 +2,8 @@ #include +namespace bitbishop { + /** * @namespace Const * @brief Core chess board constants for indexing and dimensions. @@ -99,3 +101,5 @@ CX_INLINE int FEN_NOTATION_MAX_CHAR_COUNT = BOARD_SIZE // 64 chessboard squares ; } // namespace Const + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/engine/evaluation.hpp b/include/bitbishop/engine/evaluation.hpp index 08265b7b..0ae0ce55 100644 --- a/include/bitbishop/engine/evaluation.hpp +++ b/include/bitbishop/engine/evaluation.hpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop { + namespace Eval { using PieceSquareTable = std::array; @@ -208,3 +210,5 @@ CX_INLINE PieceSquareTable KING_MIDGAME_PSQT_BLACK = flip_psqt(KING_MIDGAME_PSQT [[nodiscard]] int evaluate(const Board& board) noexcept; } // namespace Eval + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/engine/search.hpp b/include/bitbishop/engine/search.hpp index 82d23400..acbb3872 100644 --- a/include/bitbishop/engine/search.hpp +++ b/include/bitbishop/engine/search.hpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop { + class Position; namespace Search { @@ -96,3 +98,5 @@ struct BestMove { std::atomic* stop_flag = nullptr); } // namespace Search + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/interface/search_reporter.hpp b/include/bitbishop/interface/search_reporter.hpp index 6f0c41e6..a7f2e5e3 100644 --- a/include/bitbishop/interface/search_reporter.hpp +++ b/include/bitbishop/interface/search_reporter.hpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop { + /** * @brief Interface for reporting progress and results of a search. * @@ -110,3 +112,5 @@ struct BenchReporter : SearchReporter { */ void on_finish(const Search::BestMove& best, const Search::SearchStats& stats) override; }; + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/interface/search_session.hpp b/include/bitbishop/interface/search_session.hpp index 961d40a9..7920fa62 100644 --- a/include/bitbishop/interface/search_session.hpp +++ b/include/bitbishop/interface/search_session.hpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop { + namespace Uci { /** @@ -67,3 +69,5 @@ class SearchSession { }; } // namespace Uci + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/interface/search_worker.hpp b/include/bitbishop/interface/search_worker.hpp index ab2d5048..567b31f6 100644 --- a/include/bitbishop/interface/search_worker.hpp +++ b/include/bitbishop/interface/search_worker.hpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop { + namespace Uci { /** @@ -142,3 +144,5 @@ class SearchWorker { }; } // namespace Uci + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/interface/uci_command_channel.hpp b/include/bitbishop/interface/uci_command_channel.hpp index 913e1106..bd968c45 100644 --- a/include/bitbishop/interface/uci_command_channel.hpp +++ b/include/bitbishop/interface/uci_command_channel.hpp @@ -10,6 +10,8 @@ #include #include +namespace bitbishop { + namespace Uci { /** @@ -72,3 +74,5 @@ class UciCommandChannel { }; } // namespace Uci + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/interface/uci_command_registry.hpp b/include/bitbishop/interface/uci_command_registry.hpp index 757403e5..456dd147 100644 --- a/include/bitbishop/interface/uci_command_registry.hpp +++ b/include/bitbishop/interface/uci_command_registry.hpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop { + namespace Uci { /** @@ -39,3 +41,5 @@ class UciCommandRegistry { }; } // namespace Uci + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/interface/uci_engine.hpp b/include/bitbishop/interface/uci_engine.hpp index 7df3fc07..aef6632f 100644 --- a/include/bitbishop/interface/uci_engine.hpp +++ b/include/bitbishop/interface/uci_engine.hpp @@ -11,6 +11,8 @@ #include #include +namespace bitbishop { + namespace Uci { /** @@ -169,3 +171,5 @@ class UciEngine { }; } // namespace Uci + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/lookups/attackers.hpp b/include/bitbishop/lookups/attackers.hpp index 880204a4..f1394bcc 100644 --- a/include/bitbishop/lookups/attackers.hpp +++ b/include/bitbishop/lookups/attackers.hpp @@ -12,6 +12,8 @@ #include #include +namespace bitbishop { + /** * @brief Computes the geometric attackers to a target square for a given color. * @@ -98,3 +100,5 @@ CX_INLINE std::array, ColorUtil::SIZE> A return table; }(); + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/lookups/between_squares.hpp b/include/bitbishop/lookups/between_squares.hpp index 4c08b10c..733a2884 100644 --- a/include/bitbishop/lookups/between_squares.hpp +++ b/include/bitbishop/lookups/between_squares.hpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop { + namespace Lookups { /** @@ -117,3 +119,5 @@ CX_INLINE std::array, Const::BOARD_SIZE> }(); } // namespace Lookups + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/lookups/bishop_rays.hpp b/include/bitbishop/lookups/bishop_rays.hpp index 8ba125c2..5a4d4ede 100644 --- a/include/bitbishop/lookups/bishop_rays.hpp +++ b/include/bitbishop/lookups/bishop_rays.hpp @@ -7,6 +7,8 @@ #include #include +namespace bitbishop { + namespace Lookups { /** @@ -223,3 +225,5 @@ CX_INLINE std::array BISHOP_SOUTHWEST_RAYS = [] CX_ CX_INLINE std::array BISHOP_ATTACKER_RAYS = BISHOP_RAYS; } // namespace Lookups + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/lookups/king_attacks.hpp b/include/bitbishop/lookups/king_attacks.hpp index d19d3ce7..da044a77 100644 --- a/include/bitbishop/lookups/king_attacks.hpp +++ b/include/bitbishop/lookups/king_attacks.hpp @@ -6,6 +6,8 @@ #include #include +namespace bitbishop { + namespace Lookups { /** @@ -77,4 +79,6 @@ CX_INLINE std::array KING_ATTACKS = [] CX_EXEC { */ CX_INLINE std::array KING_ATTACKERS = KING_ATTACKS; -} // namespace Lookups \ No newline at end of file +} // namespace Lookups + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/lookups/knight_attacks.hpp b/include/bitbishop/lookups/knight_attacks.hpp index f607a390..a7aca15c 100644 --- a/include/bitbishop/lookups/knight_attacks.hpp +++ b/include/bitbishop/lookups/knight_attacks.hpp @@ -6,6 +6,8 @@ #include #include +namespace bitbishop { + namespace Lookups { /** @@ -70,4 +72,6 @@ CX_INLINE std::array KNIGHT_ATTACKS = [] CX_EXEC { */ CX_INLINE std::array KNIGHT_ATTACKERS = KNIGHT_ATTACKS; -} // namespace Lookups \ No newline at end of file +} // namespace Lookups + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/lookups/pawn_attacks.hpp b/include/bitbishop/lookups/pawn_attacks.hpp index 96a053b9..cc0ac81e 100644 --- a/include/bitbishop/lookups/pawn_attacks.hpp +++ b/include/bitbishop/lookups/pawn_attacks.hpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop { + namespace Lookups { /** @@ -297,3 +299,5 @@ CX_INLINE std::array, ColorUtil::SIZE> P }(); } // namespace Lookups + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/lookups/queen_rays.hpp b/include/bitbishop/lookups/queen_rays.hpp index c1a959cc..cc54a880 100644 --- a/include/bitbishop/lookups/queen_rays.hpp +++ b/include/bitbishop/lookups/queen_rays.hpp @@ -9,6 +9,8 @@ #include #include +namespace bitbishop { + namespace Lookups { /** @@ -61,3 +63,5 @@ CX_INLINE std::array QUEEN_RAYS = [] CX_EXEC { CX_INLINE std::array QUEEN_ATTACKER_RAYS = QUEEN_RAYS; } // namespace Lookups + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/lookups/rook_rays.hpp b/include/bitbishop/lookups/rook_rays.hpp index 637194f0..729f0274 100644 --- a/include/bitbishop/lookups/rook_rays.hpp +++ b/include/bitbishop/lookups/rook_rays.hpp @@ -7,6 +7,8 @@ #include #include +namespace bitbishop { + namespace Lookups { /** @@ -210,3 +212,5 @@ CX_INLINE std::array ROOK_WEST_RAYS = [] CX_EXEC { CX_INLINE std::array ROOK_ATTACKER_RAYS = ROOK_RAYS; } // namespace Lookups + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/move.hpp b/include/bitbishop/move.hpp index 011e708d..0677dd22 100644 --- a/include/bitbishop/move.hpp +++ b/include/bitbishop/move.hpp @@ -10,6 +10,8 @@ #include #include +namespace bitbishop { + /** * @struct Move * @brief Represents a chess move, including metadata about its properties. @@ -88,3 +90,5 @@ struct Move { */ [[nodiscard]] static Move make_castling(Square from, Square to) noexcept; }; + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/movegen/bishop_moves.hpp b/include/bitbishop/movegen/bishop_moves.hpp index b00ae732..3859d10d 100644 --- a/include/bitbishop/movegen/bishop_moves.hpp +++ b/include/bitbishop/movegen/bishop_moves.hpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop { + /** * @brief Generate all legal bishop moves for the side to move. * @@ -70,3 +72,5 @@ inline void generate_bishop_legal_moves(std::vector& moves, const Board& b } } } + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/movegen/castling_moves.hpp b/include/bitbishop/movegen/castling_moves.hpp index e5c79a41..cdb3e451 100644 --- a/include/bitbishop/movegen/castling_moves.hpp +++ b/include/bitbishop/movegen/castling_moves.hpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop { + /** * @brief Generates all legal castling moves for the given side. * @@ -55,3 +57,5 @@ inline void generate_castling_moves(std::vector& moves, const Board& board } } } + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/movegen/check_mask.hpp b/include/bitbishop/movegen/check_mask.hpp index b260ac59..6b9097d0 100644 --- a/include/bitbishop/movegen/check_mask.hpp +++ b/include/bitbishop/movegen/check_mask.hpp @@ -4,4 +4,8 @@ #include #include +namespace bitbishop { + Bitboard compute_check_mask(Square king_sq, const Bitboard& checkers, const Board& board); + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/movegen/king_moves.hpp b/include/bitbishop/movegen/king_moves.hpp index 3c5bb0b8..90ab840a 100644 --- a/include/bitbishop/movegen/king_moves.hpp +++ b/include/bitbishop/movegen/king_moves.hpp @@ -7,6 +7,8 @@ #include #include +namespace bitbishop { + inline void generate_legal_king_moves(std::vector& moves, const Board& board, Color us, Square king_sq, const Bitboard& enemy_attacks, const Bitboard& allowed_targets = Bitboard::Ones()) { @@ -24,3 +26,5 @@ inline void generate_legal_king_moves(std::vector& moves, const Board& boa moves.emplace_back(Move::make(king_sq, to, is_capture)); } } + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/movegen/knight_moves.hpp b/include/bitbishop/movegen/knight_moves.hpp index 4fa1d7e4..d269d6ec 100644 --- a/include/bitbishop/movegen/knight_moves.hpp +++ b/include/bitbishop/movegen/knight_moves.hpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop { + // pinned knights cannot move at all due to knight's l-shaped move geometry inline void generate_knight_legal_moves(std::vector& moves, const Board& board, Color us, const Bitboard& check_mask, const PinResult& pins, @@ -32,3 +34,5 @@ inline void generate_knight_legal_moves(std::vector& moves, const Board& b } } } + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/movegen/legal_moves.hpp b/include/bitbishop/movegen/legal_moves.hpp index 62c10aaa..c8e89610 100644 --- a/include/bitbishop/movegen/legal_moves.hpp +++ b/include/bitbishop/movegen/legal_moves.hpp @@ -18,6 +18,8 @@ #include #include +namespace bitbishop { + namespace MoveGen { enum class Scope : std::uint8_t { AllMoves, @@ -73,3 +75,5 @@ inline void generate_legal_moves(std::vector& moves, const Board& board) { inline void generate_legal_capture_moves(std::vector& moves, const Board& board) { generate_legal_moves_with_scope(moves, board, MoveGen::Scope::CapturesOnly); } + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/movegen/pawn_moves.hpp b/include/bitbishop/movegen/pawn_moves.hpp index a00ef2e7..6b374385 100644 --- a/include/bitbishop/movegen/pawn_moves.hpp +++ b/include/bitbishop/movegen/pawn_moves.hpp @@ -10,6 +10,8 @@ #include #include +namespace bitbishop { + CX_INLINE std::array WHITE_PROMOTIONS = { Pieces::WHITE_QUEEN, Pieces::WHITE_ROOK, @@ -280,3 +282,5 @@ inline void generate_pawn_legal_moves(std::vector& moves, const Board& boa generate_en_passant(moves, from, us, board, king_sq, check_mask, pin_mask); } } + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/movegen/pins.hpp b/include/bitbishop/movegen/pins.hpp index 9f42fbe0..9c50ff18 100644 --- a/include/bitbishop/movegen/pins.hpp +++ b/include/bitbishop/movegen/pins.hpp @@ -7,6 +7,8 @@ #include #include +namespace bitbishop { + /** * @brief Enumeration of sliding ray types used for pin detection. * @@ -131,3 +133,5 @@ void scan_pin_ray(Square king_sq, const PinRay& ray_info, const Board& board, Co * @return PinResult containing pinned pieces and their pin rays */ PinResult compute_pins(Square king_sq, const Board& board, Color us); + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/movegen/queen_moves.hpp b/include/bitbishop/movegen/queen_moves.hpp index 275ff778..b5be2d3a 100644 --- a/include/bitbishop/movegen/queen_moves.hpp +++ b/include/bitbishop/movegen/queen_moves.hpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop { + /** * @brief Generate all legal queen moves for the side to move. * @@ -71,3 +73,5 @@ inline void generate_queen_legal_moves(std::vector& moves, const Board& bo } } } + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/movegen/rook_moves.hpp b/include/bitbishop/movegen/rook_moves.hpp index c1c70cef..de2f52a9 100644 --- a/include/bitbishop/movegen/rook_moves.hpp +++ b/include/bitbishop/movegen/rook_moves.hpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop { + /** * @brief Generate all legal rook moves for the side to move. * @@ -71,3 +73,5 @@ inline void generate_rook_legal_moves(std::vector& moves, const Board& boa } } } + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/moves/move_builder.hpp b/include/bitbishop/moves/move_builder.hpp index 6a0b880f..7eab6f61 100644 --- a/include/bitbishop/moves/move_builder.hpp +++ b/include/bitbishop/moves/move_builder.hpp @@ -2,6 +2,8 @@ #include +namespace bitbishop { + /** * @brief Constructs a sequence of low-level effects for a move. * @@ -65,3 +67,5 @@ class MoveBuilder { void flip_side_to_move(); ///< Flips active player void reset_en_passant_square(); ///< Clears en passant square if move doesn't set one }; + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/moves/move_effect.hpp b/include/bitbishop/moves/move_effect.hpp index 648babd7..0bcc37c6 100644 --- a/include/bitbishop/moves/move_effect.hpp +++ b/include/bitbishop/moves/move_effect.hpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop { + /** * @brief Represents a single low-level board modification. * @@ -60,3 +62,5 @@ struct MoveEffect { */ void revert(Board& board) const; }; + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/moves/move_execution.hpp b/include/bitbishop/moves/move_execution.hpp index d753bef2..8a2dc3d0 100644 --- a/include/bitbishop/moves/move_execution.hpp +++ b/include/bitbishop/moves/move_execution.hpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop { + /** * @brief Aggregates the individual effects of a single move. * @@ -36,3 +38,5 @@ struct MoveExecution { */ void revert(Board& board) const; }; + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/moves/position.hpp b/include/bitbishop/moves/position.hpp index 52ad82a9..de12ce4c 100644 --- a/include/bitbishop/moves/position.hpp +++ b/include/bitbishop/moves/position.hpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop { + /** * @brief Represents a chess position and move history. * @@ -97,3 +99,5 @@ class Position { */ [[nodiscard]] bool is_in_check() const; }; + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/piece.hpp b/include/bitbishop/piece.hpp index 9515ab48..31696f40 100644 --- a/include/bitbishop/piece.hpp +++ b/include/bitbishop/piece.hpp @@ -6,6 +6,8 @@ #include #include +namespace bitbishop { + /** * @brief Represents a chess piece. * @@ -250,3 +252,5 @@ DEFINE_PIECE(BLACK_KING, 'k'); #undef DEFINE_PIECE } // namespace Pieces + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/random.hpp b/include/bitbishop/random.hpp index ea8b7f1e..790e386d 100644 --- a/include/bitbishop/random.hpp +++ b/include/bitbishop/random.hpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop { + namespace Random { /** * @brief Generates a pseudo-random 64-bit integer using the SplitMix64 algorithm. @@ -35,3 +37,5 @@ namespace Random { } } // namespace Random + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/square.hpp b/include/bitbishop/square.hpp index b07649ea..fe41640d 100644 --- a/include/bitbishop/square.hpp +++ b/include/bitbishop/square.hpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop { + /** * @brief Represents a square on the chess board. * @@ -304,3 +306,5 @@ DEFINE_SQUARE(E8); DEFINE_SQUARE(F8); DEFINE_SQUARE(G8); DEFINE_SQUARE(H8); #undef DEFINE_SQUARE } // namespace Squares + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/tools/perft.hpp b/include/bitbishop/tools/perft.hpp index 55c91c27..e3beb1d5 100644 --- a/include/bitbishop/tools/perft.hpp +++ b/include/bitbishop/tools/perft.hpp @@ -2,6 +2,8 @@ #include +namespace bitbishop { + namespace Tools { /** @@ -27,3 +29,5 @@ uint64_t perft(Board& board, std::size_t depth); void perft_divide(Board& board, std::size_t depth); } // namespace Tools + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/tools/time_guard.hpp b/include/bitbishop/tools/time_guard.hpp index 49148322..bd1b0465 100644 --- a/include/bitbishop/tools/time_guard.hpp +++ b/include/bitbishop/tools/time_guard.hpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop { + namespace Tools { /** @@ -76,3 +78,5 @@ class TimeGuard { }; } // namespace Tools + +} // namespace bitbishop \ No newline at end of file diff --git a/include/bitbishop/zobrist.hpp b/include/bitbishop/zobrist.hpp index 44e8405c..35dc4810 100644 --- a/include/bitbishop/zobrist.hpp +++ b/include/bitbishop/zobrist.hpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop { + // bitbishop/board.hpp uses Zobrist features and the current Zobrist implementation also uses Board & BoardState. // Forward declaration below and include inside bitbishop/zobrist.cpp solves this circular dependency. struct BoardState; @@ -275,3 +277,5 @@ void mutate_en_passant_square(Square epsq, Zobrist::Key& key) noexcept; [[nodiscard]] Zobrist::Key compute_hash(const Board& board) noexcept; } // namespace Zobrist + +} // namespace bitbishop \ No newline at end of file diff --git a/main/bitbishop.cpp b/main/bitbishop.cpp index a284c44d..95b324e3 100644 --- a/main/bitbishop.cpp +++ b/main/bitbishop.cpp @@ -10,7 +10,7 @@ * @return Exit code (0 on normal termination). */ int main() { - Uci::UciEngine engine(std::cin, std::cout); + bitbishop::Uci::UciEngine engine(std::cin, std::cout); engine.loop(); return 0; } diff --git a/src/bitbishop/attacks/bishop_attacks.cpp b/src/bitbishop/attacks/bishop_attacks.cpp index c6ac7557..cd443ab1 100644 --- a/src/bitbishop/attacks/bishop_attacks.cpp +++ b/src/bitbishop/attacks/bishop_attacks.cpp @@ -1,6 +1,8 @@ #include #include +namespace bitbishop { + Bitboard bishop_north_east_attacks(Square from, const Bitboard& occupied) { Bitboard ne_ray = Lookups::BISHOP_NORTHEAST_RAYS[from.value()]; Bitboard blockers = ne_ray & occupied; @@ -73,3 +75,5 @@ Bitboard bishop_attacks(Square from, const Bitboard& occupied) { attacks |= bishop_north_west_attacks(from, occupied); return attacks; } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/attacks/checkers.cpp b/src/bitbishop/attacks/checkers.cpp index 2d972370..50b6cc5b 100644 --- a/src/bitbishop/attacks/checkers.cpp +++ b/src/bitbishop/attacks/checkers.cpp @@ -10,6 +10,8 @@ #include #include +namespace bitbishop { + Bitboard compute_checkers(const Board& board, Square king_sq, Color attacker) { using namespace Lookups; @@ -44,3 +46,5 @@ Bitboard compute_checkers(const Board& board, Square king_sq, Color attacker) { return checkers; } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/attacks/queen_attacks.cpp b/src/bitbishop/attacks/queen_attacks.cpp index 003878ae..215c11f0 100644 --- a/src/bitbishop/attacks/queen_attacks.cpp +++ b/src/bitbishop/attacks/queen_attacks.cpp @@ -2,9 +2,13 @@ #include #include +namespace bitbishop { + Bitboard queen_attacks(Square from, const Bitboard& occupied) { Bitboard attacks; attacks |= rook_attacks(from, occupied); attacks |= bishop_attacks(from, occupied); return attacks; } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/attacks/rook_attacks.cpp b/src/bitbishop/attacks/rook_attacks.cpp index 4a6f82f2..b4144dd4 100644 --- a/src/bitbishop/attacks/rook_attacks.cpp +++ b/src/bitbishop/attacks/rook_attacks.cpp @@ -1,6 +1,8 @@ #include #include +namespace bitbishop { + Bitboard rook_north_attacks(Square from, const Bitboard& occupied) { Bitboard n_ray = Lookups::ROOK_NORTH_RAYS[from.value()]; Bitboard blockers = n_ray & occupied; @@ -73,3 +75,5 @@ Bitboard rook_attacks(Square from, const Bitboard& occupied) { attacks |= rook_west_attacks(from, occupied); return attacks; } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/bitboard.cpp b/src/bitbishop/bitboard.cpp index adf98372..979119ca 100644 --- a/src/bitbishop/bitboard.cpp +++ b/src/bitbishop/bitboard.cpp @@ -1,5 +1,7 @@ #include +namespace bitbishop { + void Bitboard::print() const noexcept { // defined in cpp to allow usage inside debugger @@ -13,3 +15,5 @@ void Bitboard::print() const noexcept { std::cout << "\n"; } } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/board.cpp b/src/bitbishop/board.cpp index 977e8e73..aa80d42d 100644 --- a/src/bitbishop/board.cpp +++ b/src/bitbishop/board.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop { + Board::Board() : Board("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1") {} Board::Board(const std::string& fen) { @@ -410,3 +412,5 @@ bool Board::operator==(const Board& other) const noexcept { } bool Board::operator!=(const Board& other) const noexcept { return !this->operator==(other); } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/engine/evaluation.cpp b/src/bitbishop/engine/evaluation.cpp index edc6b993..b8b5fdf6 100644 --- a/src/bitbishop/engine/evaluation.cpp +++ b/src/bitbishop/engine/evaluation.cpp @@ -1,5 +1,7 @@ #include +namespace bitbishop { + int Eval::evaluate_material(const Board& board, Color side) noexcept { int score = 0; score += board.pawns(side).count() * MaterialValue::PAWN; @@ -47,3 +49,5 @@ int Eval::evaluate(const Board& board) noexcept { return white_score - black_score; } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/engine/search.cpp b/src/bitbishop/engine/search.cpp index edd6408c..ed66dc5f 100644 --- a/src/bitbishop/engine/search.cpp +++ b/src/bitbishop/engine/search.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop { + // https://www.chessprogramming.org/Quiescence_Search int Search::quiesce(Position& position, int alpha, int beta, SearchStats& stats, std::atomic* stop_flag) { stats.quiescence_nodes++; @@ -138,3 +140,5 @@ Search::BestMove Search::negamax(Position& position, std::size_t depth, int alph best.score = bestScore; return best; } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/interface/search_reporter.cpp b/src/bitbishop/interface/search_reporter.cpp index aa3ac2fe..d439a731 100644 --- a/src/bitbishop/interface/search_reporter.cpp +++ b/src/bitbishop/interface/search_reporter.cpp @@ -1,6 +1,8 @@ #include #include +namespace bitbishop { + UciReporter::UciReporter(std::ostream& out) : out_stream(out) {} void UciReporter::on_finish(const Search::BestMove& best, const Search::SearchStats& stats) { @@ -27,3 +29,5 @@ void BenchReporter::on_finish(const Search::BestMove& best, const Search::Search << stats.quiescence_nodes << " time(s) " << seconds << "s" << " nps " << nps << "\n" << std::flush; } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/interface/search_session.cpp b/src/bitbishop/interface/search_session.cpp index 472e3786..8c4846bf 100644 --- a/src/bitbishop/interface/search_session.cpp +++ b/src/bitbishop/interface/search_session.cpp @@ -1,6 +1,8 @@ #include #include +namespace bitbishop { + Uci::SearchSession::SearchSession(std::ostream& out_stream) : out_stream(out_stream), worker(nullptr), reporter(nullptr) {} @@ -74,3 +76,5 @@ void Uci::SearchSession::stop_and_join() { } reporter.reset(); } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/interface/search_worker.cpp b/src/bitbishop/interface/search_worker.cpp index 0d5a12e5..5ca80ba6 100644 --- a/src/bitbishop/interface/search_worker.cpp +++ b/src/bitbishop/interface/search_worker.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop { + namespace { constexpr int DEFAULT_MOVES_TO_GO = 20; @@ -172,3 +174,5 @@ std::vector Uci::SearchWorker::drain_reports() { drained.swap(reports); return drained; } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/interface/uci_command_channel.cpp b/src/bitbishop/interface/uci_command_channel.cpp index 69ca2d30..6e027292 100644 --- a/src/bitbishop/interface/uci_command_channel.cpp +++ b/src/bitbishop/interface/uci_command_channel.cpp @@ -1,6 +1,8 @@ #include #include +namespace bitbishop { + Uci::UciCommandChannel::UciCommandChannel(std::istream& input_stream) : input_stream(input_stream), state(nullptr) {} Uci::UciCommandChannel::~UciCommandChannel() { stop(); } @@ -72,3 +74,5 @@ bool Uci::UciCommandChannel::wait_and_pop_line(std::string& line, std::chrono::m } bool Uci::UciCommandChannel::eof() const { return state && state->eof_reached.load(); } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/interface/uci_command_registry.cpp b/src/bitbishop/interface/uci_command_registry.cpp index 26a0b95d..dcc5faa9 100644 --- a/src/bitbishop/interface/uci_command_registry.cpp +++ b/src/bitbishop/interface/uci_command_registry.cpp @@ -1,5 +1,7 @@ #include +namespace bitbishop { + void Uci::UciCommandRegistry::register_handler(std::string command, Handler handler) { handlers.insert_or_assign(std::move(command), std::move(handler)); } @@ -17,3 +19,5 @@ bool Uci::UciCommandRegistry::dispatch(const std::vector& line) con it->second(line); return true; } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/interface/uci_engine.cpp b/src/bitbishop/interface/uci_engine.cpp index b1c5c191..c16efa6f 100644 --- a/src/bitbishop/interface/uci_engine.cpp +++ b/src/bitbishop/interface/uci_engine.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop { + [[nodiscard]] std::vector Uci::split(const std::string& str) { std::vector tokens; std::istringstream token_stream{str}; @@ -190,3 +192,5 @@ void Uci::UciEngine::handle_bench(const std::vector& line) { SearchLimits limits = SearchLimits::from_uci_cmd(line); search_session.start_bench(board, limits); } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/move.cpp b/src/bitbishop/move.cpp index 953b7f21..c0d16c67 100644 --- a/src/bitbishop/move.cpp +++ b/src/bitbishop/move.cpp @@ -1,5 +1,7 @@ #include +namespace bitbishop { + [[nodiscard]] std::string Move::to_uci() const { std::string uci; uci.reserve(UCI_MOVE_PROMOTION_CHAR_REPR_SIZE); @@ -96,4 +98,6 @@ Move Move::make_castling(Square from, Square to) noexcept { .is_en_passant = false, .is_castling = true, }; -} \ No newline at end of file +} + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/movegen/check_mask.cpp b/src/bitbishop/movegen/check_mask.cpp index 3448cc6d..1f6b971c 100644 --- a/src/bitbishop/movegen/check_mask.cpp +++ b/src/bitbishop/movegen/check_mask.cpp @@ -1,6 +1,8 @@ #include #include +namespace bitbishop { + Bitboard compute_check_mask(Square king_sq, const Bitboard& checkers, const Board& board) { if (!checkers) { return Bitboard::Ones(); @@ -21,3 +23,5 @@ Bitboard compute_check_mask(Square king_sq, const Bitboard& checkers, const Boar return Lookups::ray_between(checker_sq, king_sq) | checkers; } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/movegen/pins.cpp b/src/bitbishop/movegen/pins.cpp index 5696b479..7f3f7fe5 100644 --- a/src/bitbishop/movegen/pins.cpp +++ b/src/bitbishop/movegen/pins.cpp @@ -1,6 +1,8 @@ #include +namespace bitbishop { + void scan_pin_ray(Square king_sq, const PinRay& ray_info, const Board& board, Color us, PinResult& result) { const Bitboard occupied = board.occupied(); const Bitboard own = board.friendly(us); @@ -56,3 +58,5 @@ PinResult compute_pins(Square king_sq, const Board& board, Color us) { return result; } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/moves/move_builder.cpp b/src/bitbishop/moves/move_builder.cpp index 90c59c9f..774d5c78 100644 --- a/src/bitbishop/moves/move_builder.cpp +++ b/src/bitbishop/moves/move_builder.cpp @@ -1,6 +1,8 @@ #include #include +namespace bitbishop { + MoveBuilder::MoveBuilder(const Board& board, const Move& move) : board(board), move(move) { moving_piece = *board.get_piece(move.from); opt_captured_piece = board.get_piece(move.to); @@ -170,3 +172,5 @@ void MoveBuilder::update_full_move_number() { void MoveBuilder::flip_side_to_move() { next_state.m_is_white_turn = !prev_state.m_is_white_turn; } void MoveBuilder::reset_en_passant_square() { next_state.m_en_passant_sq = std::nullopt; } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/moves/move_effect.cpp b/src/bitbishop/moves/move_effect.cpp index 5923eb81..a031a744 100644 --- a/src/bitbishop/moves/move_effect.cpp +++ b/src/bitbishop/moves/move_effect.cpp @@ -1,6 +1,8 @@ #include #include +namespace bitbishop { + MoveEffect MoveEffect::place(Square sq, Piece piece) { MoveEffect effect{.type = Type::Place, .square = sq, .piece = piece, .prev_state = {}, .next_state = {}}; return effect; @@ -43,3 +45,5 @@ void MoveEffect::revert(Board& board) const { break; } } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/moves/move_execution.cpp b/src/bitbishop/moves/move_execution.cpp index 8db3f6cb..095d8538 100644 --- a/src/bitbishop/moves/move_execution.cpp +++ b/src/bitbishop/moves/move_execution.cpp @@ -1,5 +1,7 @@ #include +namespace bitbishop { + void MoveExecution::add(const MoveEffect& effect) { effects[count++] = effect; } void MoveExecution::apply(Board& board) const { @@ -13,3 +15,5 @@ void MoveExecution::revert(Board& board) const { effects[i].revert(board); } } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/moves/position.cpp b/src/bitbishop/moves/position.cpp index aed0c2f9..210400f3 100644 --- a/src/bitbishop/moves/position.cpp +++ b/src/bitbishop/moves/position.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop { + void Position::apply_move(const Move& move) { MoveBuilder builder(board, move); MoveExecution exec = builder.build(); @@ -80,3 +82,5 @@ void Position::reset() { const Bitboard checkers = compute_checkers(board, king_square, them); return checkers.any(); } + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/tools/perft.cpp b/src/bitbishop/tools/perft.cpp index 32a91de1..a5afefb9 100644 --- a/src/bitbishop/tools/perft.cpp +++ b/src/bitbishop/tools/perft.cpp @@ -4,7 +4,11 @@ #include #include -uint64_t Tools::perft(Board& board, std::size_t depth) { +namespace bitbishop { + +namespace Tools { + +uint64_t perft(Board& board, std::size_t depth) { uint64_t nodes = 0; if (depth == 0) { @@ -23,7 +27,7 @@ uint64_t Tools::perft(Board& board, std::size_t depth) { return nodes; } -void Tools::perft_divide(Board& board, std::size_t depth) { +void perft_divide(Board& board, std::size_t depth) { uint64_t total_nodes = 0; std::vector moves; @@ -41,3 +45,7 @@ void Tools::perft_divide(Board& board, std::size_t depth) { std::cout << "\nNodes searched: " << total_nodes << "\n"; } + +} // namespace Tools + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/tools/time_guard.cpp b/src/bitbishop/tools/time_guard.cpp index 91a95814..89889751 100644 --- a/src/bitbishop/tools/time_guard.cpp +++ b/src/bitbishop/tools/time_guard.cpp @@ -1,5 +1,7 @@ #include +namespace bitbishop { + namespace Tools { TimeGuard::TimeGuard(std::atomic& stop_flag, std::chrono::steady_clock::duration timeout) @@ -34,3 +36,5 @@ void TimeGuard::cancel() { } } // namespace Tools + +} // namespace bitbishop \ No newline at end of file diff --git a/src/bitbishop/zobrist.cpp b/src/bitbishop/zobrist.cpp index 06f40066..907790fb 100644 --- a/src/bitbishop/zobrist.cpp +++ b/src/bitbishop/zobrist.cpp @@ -1,6 +1,8 @@ #include #include +namespace bitbishop { + void Zobrist::mutate_piece(Square square, Piece piece, Zobrist::Key& key) noexcept { const int sq_ind = square.flat_index(); const int p_ind = piece_index(piece); @@ -87,3 +89,5 @@ Zobrist::Key Zobrist::compute_hash(const Board& board) noexcept { return key; } + +} // namespace bitbishop \ No newline at end of file diff --git a/tests/bitbishop/attacks/checkers/test_compute_checkers.cpp b/tests/bitbishop/attacks/checkers/test_compute_checkers.cpp index 24f24349..ce85a4c6 100644 --- a/tests/bitbishop/attacks/checkers/test_compute_checkers.cpp +++ b/tests/bitbishop/attacks/checkers/test_compute_checkers.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -508,3 +510,5 @@ TEST(ComputeCheckersTest, AllPieceTypesAsCheckers) { EXPECT_TRUE(checkers.test(H7)); EXPECT_TRUE(checkers.test(H4)); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/attacks/test_bishop_north_east_attacks.cpp b/tests/bitbishop/attacks/test_bishop_north_east_attacks.cpp index 67adcf69..3b1f4ec1 100644 --- a/tests/bitbishop/attacks/test_bishop_north_east_attacks.cpp +++ b/tests/bitbishop/attacks/test_bishop_north_east_attacks.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test bishop_north_east_attacks() with no blockers * @brief Verifies that bishop_north_east_attacks returns all squares in the NE diagonal when unobstructed. @@ -114,3 +116,5 @@ TEST(BishopMoveGeneratorTest, NorthEastRayFromEdgeSquares) { Bitboard ne_result = bishop_north_east_attacks(Squares::H8, occupied); EXPECT_EQ(ne_result.count(), 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/attacks/test_bishop_north_west_attacks.cpp b/tests/bitbishop/attacks/test_bishop_north_west_attacks.cpp index d2e23e3a..137c1d49 100644 --- a/tests/bitbishop/attacks/test_bishop_north_west_attacks.cpp +++ b/tests/bitbishop/attacks/test_bishop_north_west_attacks.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test bishop_north_west_attacks() with no blockers * @brief Verifies that bishop_north_west_attacks returns all squares in the NW diagonal when unobstructed. @@ -96,3 +98,5 @@ TEST(BishopMoveGeneratorTest, NorthWestRayFromEdgeSquares) { Bitboard nw_result = bishop_north_west_attacks(Squares::A8, occupied); EXPECT_EQ(nw_result.count(), 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/attacks/test_bishop_south_east_attacks.cpp b/tests/bitbishop/attacks/test_bishop_south_east_attacks.cpp index 07288075..8a9c68ea 100644 --- a/tests/bitbishop/attacks/test_bishop_south_east_attacks.cpp +++ b/tests/bitbishop/attacks/test_bishop_south_east_attacks.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + /** * @test bishop_south_east_attacks() with no blockers * @brief Verifies that bishop_south_east_attacks returns all squares in the SE diagonal when unobstructed. @@ -97,3 +99,5 @@ TEST(BishopMoveGeneratorTest, SouthEastRayFromEdgeSquares) { Bitboard se_result = bishop_south_east_attacks(Squares::H1, occupied); EXPECT_EQ(se_result.count(), 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/attacks/test_bishop_south_west_attacks.cpp b/tests/bitbishop/attacks/test_bishop_south_west_attacks.cpp index d7863c34..3ca45060 100644 --- a/tests/bitbishop/attacks/test_bishop_south_west_attacks.cpp +++ b/tests/bitbishop/attacks/test_bishop_south_west_attacks.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test bishop_south_west_attacks() with no blockers * @brief Verifies that bishop_south_west_attacks returns all squares in the SW diagonal when unobstructed. @@ -96,3 +98,5 @@ TEST(BishopMoveGeneratorTest, SouthWestRayFromEdgeSquares) { Bitboard sw_result = bishop_south_west_attacks(Squares::A1, occupied); EXPECT_EQ(sw_result.count(), 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/attacks/test_generate_attacks.cpp b/tests/bitbishop/attacks/test_generate_attacks.cpp index ca507bf6..cbc241aa 100644 --- a/tests/bitbishop/attacks/test_generate_attacks.cpp +++ b/tests/bitbishop/attacks/test_generate_attacks.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -497,3 +499,5 @@ TEST(GenerateAttacksTest, NoKingOnBoard) { EXPECT_TRUE(attacks.test(E1)); EXPECT_TRUE(attacks.test(A4)); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/attacks/test_rook_east_attacks.cpp b/tests/bitbishop/attacks/test_rook_east_attacks.cpp index edf44173..0550a405 100644 --- a/tests/bitbishop/attacks/test_rook_east_attacks.cpp +++ b/tests/bitbishop/attacks/test_rook_east_attacks.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test rook_east_attacks() with no blockers * @brief Verifies that rook_east_attacks returns all squares to the east when unobstructed. @@ -157,4 +159,6 @@ TEST(RookMoveGeneratorTest, EastRayFromNearEdgePositions) { EXPECT_TRUE(result.test(Square::G3)); EXPECT_TRUE(result.test(Square::H3)); EXPECT_EQ(result.count(), 2); -} \ No newline at end of file +} + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/attacks/test_rook_north_attacks.cpp b/tests/bitbishop/attacks/test_rook_north_attacks.cpp index a885287a..372c9ec8 100644 --- a/tests/bitbishop/attacks/test_rook_north_attacks.cpp +++ b/tests/bitbishop/attacks/test_rook_north_attacks.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test rook_north_attacks() with no blockers * @brief Verifies that rook_north_attacks returns all squares to the north when unobstructed. @@ -157,4 +159,6 @@ TEST(RookMoveGeneratorTest, NorthRayFromNearEdgePositions) { EXPECT_TRUE(result.test(Square::C7)); EXPECT_TRUE(result.test(Square::C8)); EXPECT_EQ(result.count(), 2); -} \ No newline at end of file +} + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/attacks/test_rook_south_attacks.cpp b/tests/bitbishop/attacks/test_rook_south_attacks.cpp index ec95444f..b3159695 100644 --- a/tests/bitbishop/attacks/test_rook_south_attacks.cpp +++ b/tests/bitbishop/attacks/test_rook_south_attacks.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test rook_south_attacks() with no blockers * @brief Verifies that rook_south_attacks returns all squares to the south when unobstructed. @@ -158,3 +160,5 @@ TEST(RookMoveGeneratorTest, SouthRayFromNearEdgePositions) { EXPECT_TRUE(result.test(Square::C1)); EXPECT_EQ(result.count(), 2); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/attacks/test_rook_west_attacks.cpp b/tests/bitbishop/attacks/test_rook_west_attacks.cpp index 61659581..61e5404b 100644 --- a/tests/bitbishop/attacks/test_rook_west_attacks.cpp +++ b/tests/bitbishop/attacks/test_rook_west_attacks.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test rook_west_attacks() with no blockers * @brief Verifies that rook_west_attacks returns all squares to the west when unobstructed. @@ -156,3 +158,5 @@ TEST(RookMoveGeneratorTest, WestRayFromNearEdgePositions) { EXPECT_TRUE(result.test(Square::A3)); EXPECT_EQ(result.count(), 2); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_any.cpp b/tests/bitbishop/bitboard/test_bb_any.cpp index 3b73fa43..0e4e330f 100644 --- a/tests/bitbishop/bitboard/test_bb_any.cpp +++ b/tests/bitbishop/bitboard/test_bb_any.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test any() method * @brief Confirms any() returns false for an empty bitboard. @@ -72,3 +74,5 @@ TEST(BitboardTest, AnyEquivalentToCountGtZero) { bb_set.set(Square::C3); EXPECT_EQ(bb_set.count() > 0, static_cast(bb_set)); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_bitshifts_ops.cpp b/tests/bitbishop/bitboard/test_bb_bitshifts_ops.cpp index 3caa6df6..e426014e 100644 --- a/tests/bitbishop/bitboard/test_bb_bitshifts_ops.cpp +++ b/tests/bitbishop/bitboard/test_bb_bitshifts_ops.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Left bitshift operator. * @brief Confirms left bitshift operator works as intended. @@ -27,3 +29,5 @@ TEST(BitboardTest, ShiftRight) { Bitboard b2(0x1000); // binary: ...0001 0000 0000 0000 (only bit 12 set -> square E2) EXPECT_EQ((b2 >> 4).value(), 0x100ULL); // binary: ...0000 0001 0000 0000 (only bit 8 set -> square A2) } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_bitwise_ops.cpp b/tests/bitbishop/bitboard/test_bb_bitwise_ops.cpp index 11ef2d37..83d5b97e 100644 --- a/tests/bitbishop/bitboard/test_bb_bitwise_ops.cpp +++ b/tests/bitbishop/bitboard/test_bb_bitwise_ops.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Bitwise OR operator. * @brief Combines two bitboards, keeping all occupied squares. @@ -110,3 +112,5 @@ TEST(BitboardTest, NotOperatorInvertsBits) { EXPECT_FALSE(b.test(Square::A1)); EXPECT_TRUE(b.test(Square::B1)); // square that wasn’t set } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_bool_op.cpp b/tests/bitbishop/bitboard/test_bb_bool_op.cpp index 625fa1db..f12794d7 100644 --- a/tests/bitbishop/bitboard/test_bb_bool_op.cpp +++ b/tests/bitbishop/bitboard/test_bb_bool_op.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test bool operator * @brief Confirms boolean works as intended when no square is populated. @@ -35,4 +37,6 @@ TEST(BitboardTest, BoolOperatorTrueWhenMultipleBits) { bb.set(Square::A1); EXPECT_TRUE(static_cast(bb)); -} \ No newline at end of file +} + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_constructors.cpp b/tests/bitbishop/bitboard/test_bb_constructors.cpp index dc06b0f7..412a34b3 100644 --- a/tests/bitbishop/bitboard/test_bb_constructors.cpp +++ b/tests/bitbishop/bitboard/test_bb_constructors.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Verify default constructor. * @brief Ensures a new Bitboard starts empty (all bits = 0). @@ -106,3 +108,5 @@ TEST(BitboardConstructorsTest, SquareConstructorIsConstexpr) { EXPECT_TRUE(bb.test(Squares::A4)); EXPECT_EQ(bb.count(), 1); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_count.cpp b/tests/bitbishop/bitboard/test_bb_count.cpp index ee295572..a65e4619 100644 --- a/tests/bitbishop/bitboard/test_bb_count.cpp +++ b/tests/bitbishop/bitboard/test_bb_count.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Count operator for bits set to one * @brief Confirms count works as intended on an empty bitboard. @@ -37,3 +39,5 @@ TEST(BitboardTest, CountMultipleBits) { EXPECT_EQ(bb.count(), 3); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_equality_ops.cpp b/tests/bitbishop/bitboard/test_bb_equality_ops.cpp index 000ac57b..524d9929 100644 --- a/tests/bitbishop/bitboard/test_bb_equality_ops.cpp +++ b/tests/bitbishop/bitboard/test_bb_equality_ops.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Equality and inequality operators. * @brief Confirms bitboards compare equal only when they have identical bits. @@ -19,3 +21,5 @@ TEST(BitboardTest, EqualityOperators) { EXPECT_FALSE(a == b); EXPECT_TRUE(a != b); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_iterator.cpp b/tests/bitbishop/bitboard/test_bb_iterator.cpp index 77376014..06b2e94f 100644 --- a/tests/bitbishop/bitboard/test_bb_iterator.cpp +++ b/tests/bitbishop/bitboard/test_bb_iterator.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Bitboard iterator iterates over all set bits in order * @brief Verifies that iterating over a bitboard with multiple set bits @@ -79,3 +81,5 @@ TEST(BitboardIteratorTest, IteratorDereferenceIsConstexprCompatible) { ASSERT_EQ(indices.size(), 2); EXPECT_LT(indices[0], indices[1]); // Should iterate in ascending order } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_lsb.cpp b/tests/bitbishop/bitboard/test_bb_lsb.cpp index a6d3222a..4f960058 100644 --- a/tests/bitbishop/bitboard/test_bb_lsb.cpp +++ b/tests/bitbishop/bitboard/test_bb_lsb.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Bitboard::lsb() on an empty bitboard * @brief Ensures lsb() returns std::nullopt when called on an empty bitboard. @@ -42,3 +44,5 @@ TEST(BitboardTest, LsbDoesNotModifyBitboard) { auto _ = bb.lsb(); EXPECT_EQ(bb.count(), before); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_msb.cpp b/tests/bitbishop/bitboard/test_bb_msb.cpp index 31968877..455a3d13 100644 --- a/tests/bitbishop/bitboard/test_bb_msb.cpp +++ b/tests/bitbishop/bitboard/test_bb_msb.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Bitboard::msb() on an empty bitboard * @brief Ensures msb() returns std::nullopt when called on an empty bitboard. @@ -86,3 +88,5 @@ TEST(BitboardTest, MsbAndLsbReturnSameOnSingleBit) { EXPECT_EQ(lowest->value(), highest->value()); EXPECT_EQ(lowest->value(), Square::D4); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_pop_lsb.cpp b/tests/bitbishop/bitboard/test_bb_pop_lsb.cpp index 88cbe18a..afe3dca1 100644 --- a/tests/bitbishop/bitboard/test_bb_pop_lsb.cpp +++ b/tests/bitbishop/bitboard/test_bb_pop_lsb.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Bitboard::pop_lsb() on an empty bitboard * @brief Ensures pop_lsb() returns std::nullopt when called on an empty bitboard. @@ -68,3 +70,5 @@ TEST(BitboardTest, PopLsbEventuallyEmptiesBoard) { EXPECT_TRUE(second.has_value()); EXPECT_FALSE(third.has_value()); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_pop_msb.cpp b/tests/bitbishop/bitboard/test_bb_pop_msb.cpp index f0d8bce5..d6e382b7 100644 --- a/tests/bitbishop/bitboard/test_bb_pop_msb.cpp +++ b/tests/bitbishop/bitboard/test_bb_pop_msb.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Bitboard::pop_msb() on an empty bitboard * @brief Ensures pop_msb() returns std::nullopt when called on an empty bitboard. @@ -106,3 +108,5 @@ TEST(BitboardTest, PopMsbAndPopLsbWorkInOppositeOrder) { EXPECT_EQ(msb2->value(), Square::D4); EXPECT_EQ(msb3->value(), Square::A1); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_print.cpp b/tests/bitbishop/bitboard/test_bb_print.cpp index 46604593..cfaeac05 100644 --- a/tests/bitbishop/bitboard/test_bb_print.cpp +++ b/tests/bitbishop/bitboard/test_bb_print.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Print function. * @brief Verifies that the bitboard prints as an 8×8 grid with correct layout. @@ -51,3 +53,5 @@ TEST(BitboardTest, PrintOutputsCorrectBoard) { } EXPECT_EQ(line_count, 8); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/bitboard/test_bb_set_test_clear_reset.cpp b/tests/bitbishop/bitboard/test_bb_set_test_clear_reset.cpp index b361607e..d3f7fe22 100644 --- a/tests/bitbishop/bitboard/test_bb_set_test_clear_reset.cpp +++ b/tests/bitbishop/bitboard/test_bb_set_test_clear_reset.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Set and test a square. * @brief After setting E2, it should be occupied, and E4 should remain empty. @@ -83,3 +85,5 @@ TEST(BitboardTest, ResetClearsAllSquares) { } EXPECT_EQ(bb.value(), 0ULL); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_black_pieces.cpp b/tests/bitbishop/board/test_b_black_pieces.cpp index 1d024b70..c2fa9600 100644 --- a/tests/bitbishop/board/test_b_black_pieces.cpp +++ b/tests/bitbishop/board/test_b_black_pieces.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test BoardTest.GetBlackPieces * @brief Confirms that black_pieces() returns the right squares using the standard fen opening. @@ -18,3 +20,5 @@ TEST(BoardTest, GetBlackPieces) { EXPECT_TRUE(black_pieces.test(Square(sq_index))); } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_board_state.cpp b/tests/bitbishop/board/test_b_board_state.cpp index ea1eadfb..fe1be605 100644 --- a/tests/bitbishop/board/test_b_board_state.cpp +++ b/tests/bitbishop/board/test_b_board_state.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; /** @@ -326,3 +328,5 @@ TEST(BoardStateTest, CopyProducesEqualState) { EXPECT_TRUE(state1 == state2); EXPECT_FALSE(state1 != state2); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_can_castle_kingside.cpp b/tests/bitbishop/board/test_b_can_castle_kingside.cpp index 9edf1d96..f4480896 100644 --- a/tests/bitbishop/board/test_b_can_castle_kingside.cpp +++ b/tests/bitbishop/board/test_b_can_castle_kingside.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test BoardTest.CanCastleKingsideWhiteSuccess * @brief Validates that White can castle kingside when all conditions are met. @@ -215,3 +217,5 @@ TEST(BoardTest, CanCastleKingsideRookReplacedByQueen) { Board board("r3k2r/8/8/8/8/8/8/R3K2Q w KQkq - 0 1"); EXPECT_FALSE(board.can_castle_kingside(Color::WHITE)); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_can_castle_queenside.cpp b/tests/bitbishop/board/test_b_can_castle_queenside.cpp index d03d3dc2..3a05f4f1 100644 --- a/tests/bitbishop/board/test_b_can_castle_queenside.cpp +++ b/tests/bitbishop/board/test_b_can_castle_queenside.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test BoardTest.CanCastleQueensideWhiteSuccess * @brief Validates that White can castle queenside when all conditions are met. @@ -185,3 +187,5 @@ TEST(BoardTest, CanCastleQueensideWrongRookPosition) { Board board("r3k2r/8/8/8/8/8/8/1R2K2R w KQkq - 0 1"); EXPECT_FALSE(board.can_castle_queenside(Color::WHITE)); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_constructors.cpp b/tests/bitbishop/board/test_b_constructors.cpp index 112f1c07..5b75935d 100644 --- a/tests/bitbishop/board/test_b_constructors.cpp +++ b/tests/bitbishop/board/test_b_constructors.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -132,3 +134,5 @@ TEST(BoardCopyTest, IndependenceAfterCopy) { EXPECT_EQ(original.get_piece(E2), std::nullopt); EXPECT_EQ(copy.get_piece(E2), WHITE_PAWN); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_en_passant_square.cpp b/tests/bitbishop/board/test_b_en_passant_square.cpp index e0af0c7d..81fdbae1 100644 --- a/tests/bitbishop/board/test_b_en_passant_square.cpp +++ b/tests/bitbishop/board/test_b_en_passant_square.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test BoardTest.EnPassantSquare * @brief Ensures en_passant_square() works as intented when en passant square is set. @@ -26,3 +28,5 @@ TEST(BoardTest, EnPassantSquareNotAvailable) { Board board2("8/8/8/8/8/8/8/8 w - - 0 1"); EXPECT_FALSE(board2.en_passant_square().has_value()); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_enemy.cpp b/tests/bitbishop/board/test_b_enemy.cpp index 3bc5c4ee..876449e2 100644 --- a/tests/bitbishop/board/test_b_enemy.cpp +++ b/tests/bitbishop/board/test_b_enemy.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test BoardTest.EnemyBitboard * @brief Confirms that enemy() returns the opposing side’s occupied squares. @@ -24,3 +26,5 @@ TEST(BoardTest, EnemyBitboard) { EXPECT_TRUE(white_enemy.test(Square(sq_index))); } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_equality_operators.cpp b/tests/bitbishop/board/test_b_equality_operators.cpp index 704d6ba5..a4f8bca8 100644 --- a/tests/bitbishop/board/test_b_equality_operators.cpp +++ b/tests/bitbishop/board/test_b_equality_operators.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -268,3 +270,5 @@ TEST(BoardEqualityTest, AllSquaresChecked) { EXPECT_FALSE(board1 == board2); EXPECT_TRUE(board1 != board2); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_friendly.cpp b/tests/bitbishop/board/test_b_friendly.cpp index 2d9327a9..2f7cdf2d 100644 --- a/tests/bitbishop/board/test_b_friendly.cpp +++ b/tests/bitbishop/board/test_b_friendly.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test BoardTest.FriendlyBitboard * @brief Confirms that friendly() returns the current side’s occupied squares. @@ -23,4 +25,6 @@ TEST(BoardTest, FriendlyBitboard) { for (int sq_index = Square::A7; sq_index <= Square::H8; sq_index++) { EXPECT_TRUE(black_friends.test(Square(sq_index))); } -} \ No newline at end of file +} + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_get_fen.cpp b/tests/bitbishop/board/test_b_get_fen.cpp index a5982896..675e1fd9 100644 --- a/tests/bitbishop/board/test_b_get_fen.cpp +++ b/tests/bitbishop/board/test_b_get_fen.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + struct FenTestCase { std::string name; std::string fen; @@ -54,8 +56,10 @@ INSTANTIATE_TEST_SUITE_P( "8/8/3p4/8/8/4P3/8/8 w - - 0 1" } ), - [](const testing::TestParamInfo& info) { + [](const ::testing::TestParamInfo& info) { return info.param.name; } ); // clang-format on + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_get_piece_bitboard.cpp b/tests/bitbishop/board/test_b_get_piece_bitboard.cpp index 30ee5e5e..d65b23e7 100644 --- a/tests/bitbishop/board/test_b_get_piece_bitboard.cpp +++ b/tests/bitbishop/board/test_b_get_piece_bitboard.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test BoardTest.PawnsBitboard * @brief Ensures that pawns() correctly returns the bitboard for each side. @@ -107,3 +109,5 @@ TEST(BoardTest, QueensBitboard) { EXPECT_TRUE(white_queens.test(Squares::D1)); EXPECT_TRUE(black_queens.test(Square::D8)); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_has_insufficient_material.cpp b/tests/bitbishop/board/test_b_has_insufficient_material.cpp index f817de76..3e71c9b5 100644 --- a/tests/bitbishop/board/test_b_has_insufficient_material.cpp +++ b/tests/bitbishop/board/test_b_has_insufficient_material.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + TEST(BoardTest, TwoKingsIsInsufficientMaterial) { Board board("8/8/8/8/4k3/8/8/2K5 w KQkq - 0 1"); EXPECT_TRUE(board.has_insufficient_material()); @@ -44,3 +46,5 @@ TEST(BoardTest, StartingPosIsNotInsufficientMaterial) { Board board = Board::StartingPosition(); EXPECT_FALSE(board.has_insufficient_material()); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_king_square.cpp b/tests/bitbishop/board/test_b_king_square.cpp index b754748d..aec1a39b 100644 --- a/tests/bitbishop/board/test_b_king_square.cpp +++ b/tests/bitbishop/board/test_b_king_square.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -83,3 +85,5 @@ TEST(BoardKingSquareTest, KingMoved) { EXPECT_TRUE(white_king_sq.has_value()); EXPECT_EQ(white_king_sq.value(), G1); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_move_piece.cpp b/tests/bitbishop/board/test_b_move_piece.cpp index ae2cddfe..235e8a29 100644 --- a/tests/bitbishop/board/test_b_move_piece.cpp +++ b/tests/bitbishop/board/test_b_move_piece.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -437,3 +439,5 @@ TEST(BoardMovePieceTest, CaptureUpdatesBothColors) { EXPECT_EQ(white_rooks_after.count(), 1); EXPECT_EQ(black_rooks_after.count(), 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_occupied.cpp b/tests/bitbishop/board/test_b_occupied.cpp index acaaf865..67b183c7 100644 --- a/tests/bitbishop/board/test_b_occupied.cpp +++ b/tests/bitbishop/board/test_b_occupied.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test BoardTest.Occupied * @brief Validates that occupied() returns all populated squares. @@ -20,4 +22,6 @@ TEST(BoardTest, OccupiedBoardSquares) { for (int sq_index = Square::A7; sq_index <= Square::H8; sq_index++) { EXPECT_TRUE(populated.test(Square(sq_index))); } -} \ No newline at end of file +} + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_print.cpp b/tests/bitbishop/board/test_b_print.cpp index 27a7f9db..f8988aac 100644 --- a/tests/bitbishop/board/test_b_print.cpp +++ b/tests/bitbishop/board/test_b_print.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + /** * @test BoardTest.PrintBoard * @brief Verifies that the board prints to std::cout correctly when called from a starting position. @@ -44,4 +46,6 @@ TEST(BoardTest, PrintBoardStartingPos) { " a b c d e f g h \n"; EXPECT_EQ(output, expected); -} \ No newline at end of file +} + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_set_get_remove_piece.cpp b/tests/bitbishop/board/test_b_set_get_remove_piece.cpp index 4b7b57a3..7f891b3b 100644 --- a/tests/bitbishop/board/test_b_set_get_remove_piece.cpp +++ b/tests/bitbishop/board/test_b_set_get_remove_piece.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test BoardTest.SetAndGetPiece * @brief Verifies placing and retrieving pieces. @@ -65,3 +67,5 @@ TEST(BoardTest, ReplacePiece) { EXPECT_TRUE(board.black_pieces().test(Square(0, 0))); EXPECT_FALSE(board.white_pieces().test(Square(0, 0))); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_stream_ops.cpp b/tests/bitbishop/board/test_b_stream_ops.cpp index 287f3880..97c1f945 100644 --- a/tests/bitbishop/board/test_b_stream_ops.cpp +++ b/tests/bitbishop/board/test_b_stream_ops.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + TEST(BoardTestOStreamOverload, EmptyBoardProvidesCorrectFormatting) { std::ostringstream oss; @@ -94,3 +96,5 @@ TEST(BoardTestOStreamOverload, RandomPositionBoardProvidesCorrectFormatting) { ASSERT_EQ(oss.str(), expected); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_unoccupied.cpp b/tests/bitbishop/board/test_b_unoccupied.cpp index e7e84e1e..4303cc6e 100644 --- a/tests/bitbishop/board/test_b_unoccupied.cpp +++ b/tests/bitbishop/board/test_b_unoccupied.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test BoardTest.Unoccupied * @brief Validates that unoccupied() returns all unoccupied squares. @@ -19,3 +21,5 @@ TEST(BoardTest, UnoccupiedBoardSquares) { EXPECT_TRUE(empty.test(Square(sq_index))); } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_white_pieces.cpp b/tests/bitbishop/board/test_b_white_pieces.cpp index 8a0a4f8a..5b927bf4 100644 --- a/tests/bitbishop/board/test_b_white_pieces.cpp +++ b/tests/bitbishop/board/test_b_white_pieces.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @test BoardTest.GetWhitePieces * @brief Confirms that white_pieces() returns the right squares using the standard fen opening. @@ -18,3 +20,5 @@ TEST(BoardTest, GetWhitePieces) { EXPECT_TRUE(white_pieces.test(Square(sq_index))); } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/board/test_b_zobrist_hash.cpp b/tests/bitbishop/board/test_b_zobrist_hash.cpp index a417d0f1..50c98a75 100644 --- a/tests/bitbishop/board/test_b_zobrist_hash.cpp +++ b/tests/bitbishop/board/test_b_zobrist_hash.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -218,3 +220,5 @@ TEST(BoardZobristTest, SetSideToMoveTogglesHash) { EXPECT_EQ(board.get_zobrist_hash(), reference_hash ^ expected_delta); EXPECT_EQ(board.get_zobrist_hash(), Zobrist::compute_hash(board)); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/engine/evaluation/test_compute_score_from_psqt.cpp b/tests/bitbishop/engine/evaluation/test_compute_score_from_psqt.cpp index 68a4a320..eb770ab8 100644 --- a/tests/bitbishop/engine/evaluation/test_compute_score_from_psqt.cpp +++ b/tests/bitbishop/engine/evaluation/test_compute_score_from_psqt.cpp @@ -2,8 +2,11 @@ #include +namespace bitbishop::testing { + using namespace Eval; using namespace Squares; +using namespace Pieces; class TestComputeScoreFromPSqT : public ::testing::Test { protected: @@ -98,3 +101,5 @@ TEST_F(TestComputeScoreFromPSqT, FullFileFlip) { EXPECT_EQ(score, expected); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/engine/evaluation/test_evaluate.cpp b/tests/bitbishop/engine/evaluation/test_evaluate.cpp index 9051ac68..bc101929 100644 --- a/tests/bitbishop/engine/evaluation/test_evaluate.cpp +++ b/tests/bitbishop/engine/evaluation/test_evaluate.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + using namespace Eval; using namespace Squares; using namespace Pieces; @@ -38,3 +40,5 @@ TEST(TestScoreEvaluation, EmptyBoardEvaluatesToZero) { EXPECT_EQ(white_score, 0); EXPECT_EQ(black_score, 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/engine/evaluation/test_evaluate_material.cpp b/tests/bitbishop/engine/evaluation/test_evaluate_material.cpp index b5c487de..f852c15c 100644 --- a/tests/bitbishop/engine/evaluation/test_evaluate_material.cpp +++ b/tests/bitbishop/engine/evaluation/test_evaluate_material.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + using namespace Eval; using namespace Squares; using namespace Pieces; @@ -129,3 +131,5 @@ TEST(MaterialEvaluationTest, SymmetricColorSetupProvidesSameScore) { EXPECT_EQ(score_white, score_black); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/engine/evaluation/test_evaluate_psqt.cpp b/tests/bitbishop/engine/evaluation/test_evaluate_psqt.cpp index 39ecff86..84315b6a 100644 --- a/tests/bitbishop/engine/evaluation/test_evaluate_psqt.cpp +++ b/tests/bitbishop/engine/evaluation/test_evaluate_psqt.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + using namespace Eval; using namespace Squares; using namespace Pieces; @@ -32,3 +34,5 @@ TEST(PSqTEvaluationTest, EmptyBoardEvaluatesToZero) { EXPECT_EQ(white_score, 0); EXPECT_EQ(black_score, 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/engine/evaluation/test_flip_index.cpp b/tests/bitbishop/engine/evaluation/test_flip_index.cpp index b9c9a20f..8455c8f0 100644 --- a/tests/bitbishop/engine/evaluation/test_flip_index.cpp +++ b/tests/bitbishop/engine/evaluation/test_flip_index.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + using namespace Eval; TEST(FlipIndex, IsInvolution) { @@ -30,4 +32,6 @@ TEST(FlipIndex, FlipsCornersCorrectly) { EXPECT_EQ(flip_index_vertically(7), 63); // H8 -> H1 EXPECT_EQ(flip_index_vertically(56), 0); // A1 -> A8 EXPECT_EQ(flip_index_vertically(63), 7); // H1 -> H8 -} \ No newline at end of file +} + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/engine/evaluation/test_flip_psqt.cpp b/tests/bitbishop/engine/evaluation/test_flip_psqt.cpp index a910e928..0e0aeb88 100644 --- a/tests/bitbishop/engine/evaluation/test_flip_psqt.cpp +++ b/tests/bitbishop/engine/evaluation/test_flip_psqt.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + using namespace Eval; class TestFlipPSqT : public ::testing::Test { @@ -29,3 +31,5 @@ TEST_F(TestFlipPSqT, UsesFlipIndexMapping) { EXPECT_EQ(psqt[i], psqt_flipped[flip_index_vertically(i)]) << "at index " << i; } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/engine/search/test_negamax.cpp b/tests/bitbishop/engine/search/test_negamax.cpp index 59c4456f..fe7801cf 100644 --- a/tests/bitbishop/engine/search/test_negamax.cpp +++ b/tests/bitbishop/engine/search/test_negamax.cpp @@ -6,6 +6,8 @@ #include #include +namespace bitbishop::testing { + using namespace Search; using namespace Pieces; using namespace Squares; @@ -178,3 +180,5 @@ TEST(NegaMaxTest, FiftyMoveRuleIsDraw) { EXPECT_EQ(quiesce(pos, ALPHA_INIT, BETA_INIT, stats), 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/helpers/async.hpp b/tests/bitbishop/helpers/async.hpp index 2d1b073b..aaf5ecdf 100644 --- a/tests/bitbishop/helpers/async.hpp +++ b/tests/bitbishop/helpers/async.hpp @@ -6,6 +6,8 @@ #include #include +namespace bitbishop::testing { + /** * @brief Wait until a condition becomes true or timeout expires. * @@ -44,3 +46,5 @@ void assert_output_not_contains(const std::stringstream& output, const std::stri << "Expected output not to contain: " << token << "\nActual output:\n" << output.str(); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/helpers/blocking_stream.hpp b/tests/bitbishop/helpers/blocking_stream.hpp index c9bd471f..e198f669 100644 --- a/tests/bitbishop/helpers/blocking_stream.hpp +++ b/tests/bitbishop/helpers/blocking_stream.hpp @@ -2,6 +2,8 @@ #include #include +namespace bitbishop::testing { + /** * @brief Thread-safe blocking stream buffer. * @@ -101,3 +103,5 @@ class BlockingIStream : public std::istream { private: BlockingStreamBuf buf_; ///< Underlying buffer }; + +} // namespace bitbishop \ No newline at end of file diff --git a/tests/bitbishop/helpers/moves.hpp b/tests/bitbishop/helpers/moves.hpp index bb19b8d9..5e8e5ff8 100644 --- a/tests/bitbishop/helpers/moves.hpp +++ b/tests/bitbishop/helpers/moves.hpp @@ -14,6 +14,8 @@ #include #include +namespace bitbishop::testing { + /** * @brief Counts moves that satisfy a predicate. * @param moves Vector of moves to analyze. @@ -217,3 +219,5 @@ std::size_t count_rook_queenside_castling(const std::vector& moves, Color std::vector find_moves_between(const std::vector& moves, Square from, Square to) { return filter_moves(moves, [&](const Move& m) { return m.from == from && m.to == to; }); } + +} // namespace bitbishop \ No newline at end of file diff --git a/tests/bitbishop/helpers/repetition.hpp b/tests/bitbishop/helpers/repetition.hpp index 6a2ef97d..1ad4bbcd 100644 --- a/tests/bitbishop/helpers/repetition.hpp +++ b/tests/bitbishop/helpers/repetition.hpp @@ -9,6 +9,8 @@ #include #include +namespace bitbishop::testing { + /** * @brief Reaches the same position again after 4 plies from the starting position. * @@ -22,3 +24,5 @@ inline void apply_knight_repetition_cycle(Position& pos) { pos.apply_move(Move::make(Squares::F3, Squares::G1)); pos.apply_move(Move::make(Squares::F6, Squares::G8)); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/interface/test_search_limits.cpp b/tests/bitbishop/interface/test_search_limits.cpp index 01b3d1f8..a68f1d84 100644 --- a/tests/bitbishop/interface/test_search_limits.cpp +++ b/tests/bitbishop/interface/test_search_limits.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + TEST(SearchLimitsTest, DefaultsAreEmptyAndNotInfinite) { Uci::SearchLimits limits; @@ -65,7 +67,7 @@ struct SearchLimitsFromUciTestCase { struct SearchLimitsParamName { template - std::string operator()(const testing::TestParamInfo& info) const { + std::string operator()(const ::testing::TestParamInfo& info) const { return info.param.test_name; } }; @@ -228,3 +230,5 @@ INSTANTIATE_TEST_SUITE_P( SearchLimitsParamName{} ); // clang-format on + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/interface/test_search_reporter.cpp b/tests/bitbishop/interface/test_search_reporter.cpp index 92612131..712ebd87 100644 --- a/tests/bitbishop/interface/test_search_reporter.cpp +++ b/tests/bitbishop/interface/test_search_reporter.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + using namespace Search; class SearchReporterTest : public ::testing::Test { @@ -64,3 +66,5 @@ TEST_F(SearchReporterTest, BenchHandlesZeroTimeGracefully) { EXPECT_NE(result.find("bench nodes "), std::string::npos); EXPECT_NE(result.find("nps "), std::string::npos); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/interface/test_search_session.cpp b/tests/bitbishop/interface/test_search_session.cpp index a88aa4b9..d08ff855 100644 --- a/tests/bitbishop/interface/test_search_session.cpp +++ b/tests/bitbishop/interface/test_search_session.cpp @@ -7,6 +7,8 @@ #include #include +namespace bitbishop::testing { + using namespace std::chrono_literals; bool wait_until_idle(Uci::SearchSession& session, std::chrono::milliseconds timeout = 1000ms) { @@ -87,3 +89,5 @@ TEST(SearchSessionTest, StartBenchWithInfiniteLimitCompletesWithoutManualStop) { ASSERT_TRUE(wait_until_idle(session, 1500ms)); EXPECT_NE(output.str().find("bench nodes "), std::string::npos); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/interface/test_search_worker.cpp b/tests/bitbishop/interface/test_search_worker.cpp index 1303b6a5..f1e839d1 100644 --- a/tests/bitbishop/interface/test_search_worker.cpp +++ b/tests/bitbishop/interface/test_search_worker.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + TEST(SearchControllerTest, StartPublishesFinishReportWithDepth1) { Board board = Board::StartingPosition(); Uci::SearchLimits limits; @@ -63,3 +65,5 @@ TEST(SearchControllerTest, MovetimeStopsSearchAutomatically) { return report.kind == Uci::SearchReportKind::Iteration; })); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/interface/test_split.cpp b/tests/bitbishop/interface/test_split.cpp index 8935a618..9b6e9c3c 100644 --- a/tests/bitbishop/interface/test_split.cpp +++ b/tests/bitbishop/interface/test_split.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + TEST(UciSplitTest, BasicTokens) { const auto tokens = Uci::split("position startpos moves e2e4 e7e5"); @@ -21,3 +23,5 @@ TEST(UciSplitTest, CollapsesWhitespace) { EXPECT_EQ(tokens[1], "depth"); EXPECT_EQ(tokens[2], "3"); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/interface/test_uci_command_channel.cpp b/tests/bitbishop/interface/test_uci_command_channel.cpp index 49ce10bc..7e80980d 100644 --- a/tests/bitbishop/interface/test_uci_command_channel.cpp +++ b/tests/bitbishop/interface/test_uci_command_channel.cpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop::testing { + using namespace std::chrono_literals; TEST(UciCommandChannelTest, WaitAndPopReturnsFalseWhenNotStarted) { @@ -94,3 +96,5 @@ TEST(UciCommandChannelTest, StopDoesNotHangWhenReaderIsBlockedByInputStream) { // If it took 0ms, it means we successfully detached instead of joining a hung thread. EXPECT_EQ(duration.count(), 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/interface/test_uci_command_registry.cpp b/tests/bitbishop/interface/test_uci_command_registry.cpp index 9a17563b..132dbf1a 100644 --- a/tests/bitbishop/interface/test_uci_command_registry.cpp +++ b/tests/bitbishop/interface/test_uci_command_registry.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + using namespace Uci; TEST(UciCommandRegistryTest, RegistersCorreclyHandlerFunction) { @@ -73,3 +75,5 @@ TEST(UciCommandRegistryTest, DispatchesDoesNothingWithNonExistingCommand) { EXPECT_FALSE(dispatch_result); EXPECT_EQ(counter, 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/interface/test_uci_engine.cpp b/tests/bitbishop/interface/test_uci_engine.cpp index 5dd7924b..f5154ffa 100644 --- a/tests/bitbishop/interface/test_uci_engine.cpp +++ b/tests/bitbishop/interface/test_uci_engine.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace std::chrono; @@ -623,3 +625,5 @@ TEST_F(UciEngineTest, GoBtimeBincGoesInfiniteWhenItsWhiteTurn) { assert_output_not_contains(output, "bestmove ", milliseconds(*budget * 2)); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/lookups/test_attackers.cpp b/tests/bitbishop/lookups/test_attackers.cpp index 4a502c1f..b202df2d 100644 --- a/tests/bitbishop/lookups/test_attackers.cpp +++ b/tests/bitbishop/lookups/test_attackers.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; /** @@ -302,3 +304,5 @@ TEST(AttackersTest, GeometricIgnoresBoardState) { EXPECT_EQ(call1, call2); EXPECT_EQ(call2, call3); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/lookups/test_between_squares/test_between_lookup.cpp b/tests/bitbishop/lookups/test_between_squares/test_between_lookup.cpp index bc0f91c0..71d5e3d0 100644 --- a/tests/bitbishop/lookups/test_between_squares/test_between_lookup.cpp +++ b/tests/bitbishop/lookups/test_between_squares/test_between_lookup.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Lookups; @@ -71,3 +73,5 @@ TEST(BetweenLookupTest, BetweenTableDiagonalSameSquare) { EXPECT_EQ(BETWEEN[i][i], Bitboard::Zeros()); } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/lookups/test_between_squares/test_direction.cpp b/tests/bitbishop/lookups/test_between_squares/test_direction.cpp index 3c73a5c4..41bebcc4 100644 --- a/tests/bitbishop/lookups/test_between_squares/test_direction.cpp +++ b/tests/bitbishop/lookups/test_between_squares/test_direction.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Lookups; @@ -64,3 +66,5 @@ TEST(LookupsTest, DirectionWithInvalidFromAndToSquares) { EXPECT_EQ(direction(A1, B6), 0); EXPECT_EQ(direction(F4, H8), 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/lookups/test_between_squares/test_ray_between.cpp b/tests/bitbishop/lookups/test_between_squares/test_ray_between.cpp index 2dec7e4c..a503c61d 100644 --- a/tests/bitbishop/lookups/test_between_squares/test_ray_between.cpp +++ b/tests/bitbishop/lookups/test_between_squares/test_ray_between.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Lookups; @@ -146,3 +148,5 @@ TEST(RayBetweenTest, RayBetweenNonAlignedSquareReturnsZeroBitboard) { EXPECT_EQ(ray_between(A1, B6).count(), 0); EXPECT_EQ(ray_between(A7, H3).count(), 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/lookups/test_bishop_rays.cpp b/tests/bitbishop/lookups/test_bishop_rays.cpp index 3b25a6de..cea98d4c 100644 --- a/tests/bitbishop/lookups/test_bishop_rays.cpp +++ b/tests/bitbishop/lookups/test_bishop_rays.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + TEST(BishopAttacksTest, CornerA1) { Bitboard bb = Lookups::BISHOP_RAYS[Square::A1]; @@ -76,3 +78,5 @@ TEST(BishopAttacksTest, CenterD4) { EXPECT_TRUE(bb.test(Square::B2)); EXPECT_TRUE(bb.test(Square::A1)); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/lookups/test_king_attacks.cpp b/tests/bitbishop/lookups/test_king_attacks.cpp index 75032a50..4bc153ce 100644 --- a/tests/bitbishop/lookups/test_king_attacks.cpp +++ b/tests/bitbishop/lookups/test_king_attacks.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + using namespace Lookups; /** @@ -85,3 +87,5 @@ TEST(KingAttackTest, CenterD4) { EXPECT_EQ(KING_ATTACKS[Square::D4], expected); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/lookups/test_knight_attacks.cpp b/tests/bitbishop/lookups/test_knight_attacks.cpp index 713f4ae9..d945bc56 100644 --- a/tests/bitbishop/lookups/test_knight_attacks.cpp +++ b/tests/bitbishop/lookups/test_knight_attacks.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + using namespace Lookups; TEST(KnightAttackTest, CornerA1) { @@ -51,4 +53,6 @@ TEST(KnightAttackTest, CenterD4) { expected.set(Square::B5); EXPECT_EQ(KNIGHT_ATTACKS[Square::D4], expected); -} \ No newline at end of file +} + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/lookups/test_pawn_attacks.cpp b/tests/bitbishop/lookups/test_pawn_attacks.cpp index 6b4d8282..692906f9 100644 --- a/tests/bitbishop/lookups/test_pawn_attacks.cpp +++ b/tests/bitbishop/lookups/test_pawn_attacks.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + using namespace Lookups; /** @@ -117,3 +119,5 @@ TEST(PawnAttackTest, BlackPawnAttacksFromA5) { EXPECT_EQ(BLACK_PAWN_ATTACKS[Square::A5], expected); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/lookups/test_queen_rays.cpp b/tests/bitbishop/lookups/test_queen_rays.cpp index 8b377e68..f2e1f233 100644 --- a/tests/bitbishop/lookups/test_queen_rays.cpp +++ b/tests/bitbishop/lookups/test_queen_rays.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + TEST(QueenAttacksTest, CornerA1) { Bitboard bb = Lookups::QUEEN_RAYS[Square::A1]; @@ -101,3 +103,5 @@ TEST(QueenAttacksTest, CenterD4) { EXPECT_TRUE(bb.test(Square::B2)); EXPECT_TRUE(bb.test(Square::A1)); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/lookups/test_rook_rays.cpp b/tests/bitbishop/lookups/test_rook_rays.cpp index 9a320155..2f50f48f 100644 --- a/tests/bitbishop/lookups/test_rook_rays.cpp +++ b/tests/bitbishop/lookups/test_rook_rays.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + TEST(RookAttacksTest, CornerA1) { Bitboard bb = Lookups::ROOK_RAYS[Square::A1]; @@ -53,3 +55,5 @@ TEST(RookAttacksTest, CenterD4) { EXPECT_EQ(bb, expected); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_bishop_moves.cpp b/tests/bitbishop/movegen/test_bishop_moves.cpp index 5309e7fa..74e044da 100644 --- a/tests/bitbishop/movegen/test_bishop_moves.cpp +++ b/tests/bitbishop/movegen/test_bishop_moves.cpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -537,3 +539,5 @@ TEST(GenerateBishopLegalMovesTest, BishopOnEdge) { EXPECT_TRUE(contains_move(moves, {A4, C2, std::nullopt, false, false, false})); EXPECT_TRUE(contains_move(moves, {A4, D1, std::nullopt, false, false, false})); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_castling_moves.cpp b/tests/bitbishop/movegen/test_castling_moves.cpp index 59f12c84..3c13482a 100644 --- a/tests/bitbishop/movegen/test_castling_moves.cpp +++ b/tests/bitbishop/movegen/test_castling_moves.cpp @@ -7,6 +7,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -484,3 +486,5 @@ TEST(GenerateCastlingMovesTest, CastlingRightsButEmptyBoard) { // Should generate no moves because can_castle_kingside/queenside will fail EXPECT_EQ(moves.size(), 0); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_check_mask.cpp b/tests/bitbishop/movegen/test_check_mask.cpp index fb4b6f57..6cf9fcf6 100644 --- a/tests/bitbishop/movegen/test_check_mask.cpp +++ b/tests/bitbishop/movegen/test_check_mask.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -412,3 +414,5 @@ TEST(CheckMaskTest, CheckerSquareAlwaysIncluded) { EXPECT_TRUE(mask.test(checker_squares[i])) << "Checker square not included for piece type " << i; } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_king_moves.cpp b/tests/bitbishop/movegen/test_king_moves.cpp index 8855d640..f78b3789 100644 --- a/tests/bitbishop/movegen/test_king_moves.cpp +++ b/tests/bitbishop/movegen/test_king_moves.cpp @@ -7,6 +7,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -387,3 +389,5 @@ TEST(GenerateLegalKingMovesTest, CaptureUndefendedOnly) { // E5 should not be in moves EXPECT_FALSE(contains_move(moves, {E4, E5, std::nullopt, true, false, false})); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_knight_moves.cpp b/tests/bitbishop/movegen/test_knight_moves.cpp index 88658b03..cf1b37ed 100644 --- a/tests/bitbishop/movegen/test_knight_moves.cpp +++ b/tests/bitbishop/movegen/test_knight_moves.cpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -468,3 +470,5 @@ TEST(GenerateKnightLegalMovesTest, KnightNearEdge) { EXPECT_TRUE(contains_move(moves, {B2, D3, std::nullopt, false, false, false})); EXPECT_TRUE(contains_move(moves, {B2, D1, std::nullopt, false, false, false})); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_legal_capture_moves.cpp b/tests/bitbishop/movegen/test_legal_capture_moves.cpp index 964cd06c..b430e3b4 100644 --- a/tests/bitbishop/movegen/test_legal_capture_moves.cpp +++ b/tests/bitbishop/movegen/test_legal_capture_moves.cpp @@ -6,6 +6,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -110,3 +112,5 @@ TEST(GenerateLegalCaptureMovesTest, MovesVectorIsAppendedNotCleared) { EXPECT_EQ(moves.size(), 1); EXPECT_TRUE(contains_move(moves, Move::make(A1, A2))); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_legal_moves.cpp b/tests/bitbishop/movegen/test_legal_moves.cpp index 1e67f0f8..5922d037 100644 --- a/tests/bitbishop/movegen/test_legal_moves.cpp +++ b/tests/bitbishop/movegen/test_legal_moves.cpp @@ -7,6 +7,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -572,3 +574,5 @@ TEST(GenerateLegalMovesTest, PinnedKnightNoMoves) { EXPECT_NE(move.from, E3); } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_pawn_moves/test_add_pawn_promotions.cpp b/tests/bitbishop/movegen/test_pawn_moves/test_add_pawn_promotions.cpp index f7372dec..637bc3ef 100644 --- a/tests/bitbishop/movegen/test_pawn_moves/test_add_pawn_promotions.cpp +++ b/tests/bitbishop/movegen/test_pawn_moves/test_add_pawn_promotions.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @brief Test fixture for pawn promotion move generation. * @@ -403,3 +405,5 @@ TEST_F(PawnPromotionTest, AllPromotionMovesHavePromotionPiece) { EXPECT_TRUE(move.promotion.has_value()) << "All promotion moves must have a promotion piece"; } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_pawn_moves/test_can_capture_en_passant.cpp b/tests/bitbishop/movegen/test_pawn_moves/test_can_capture_en_passant.cpp index 0b2accd3..9d04e96c 100644 --- a/tests/bitbishop/movegen/test_pawn_moves/test_can_capture_en_passant.cpp +++ b/tests/bitbishop/movegen/test_pawn_moves/test_can_capture_en_passant.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + /** * @brief Test case structure for en passant validation. */ @@ -99,3 +101,5 @@ TEST(PawnMoveGeneratorTest, BlackCannotCaptureEnPassant_InvalidCombinations) { << "from=" << c.from.to_string() << " en_passant=" << c.en_passant.to_string() << " color=BLACK"; } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_pawn_moves/test_generate_pawn_legal_moves.cpp b/tests/bitbishop/movegen/test_pawn_moves/test_generate_pawn_legal_moves.cpp index f41cf00d..c84a5273 100644 --- a/tests/bitbishop/movegen/test_pawn_moves/test_generate_pawn_legal_moves.cpp +++ b/tests/bitbishop/movegen/test_pawn_moves/test_generate_pawn_legal_moves.cpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -758,3 +760,5 @@ TEST(GeneratePawnLegalMovesTest, EnPassantMoveProperties) { } EXPECT_TRUE(found); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_pawn_moves/test_is_promotion_rank.cpp b/tests/bitbishop/movegen/test_pawn_moves/test_is_promotion_rank.cpp index e783e4de..660fc947 100644 --- a/tests/bitbishop/movegen/test_pawn_moves/test_is_promotion_rank.cpp +++ b/tests/bitbishop/movegen/test_pawn_moves/test_is_promotion_rank.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + /** * @test Verifies is_promotion_rank returns true for White pawns on rank 8 (A8-H8). */ @@ -37,3 +39,5 @@ TEST(PawnMoveGeneratorTest, IsPromotionRankNotFromPromotionRankForBlack) { ASSERT_FALSE(is_promotion_rank(Square(sq), Color::BLACK)) << "for square " << Square(sq).to_string(); } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_pawn_moves/test_is_starting_rank.cpp b/tests/bitbishop/movegen/test_pawn_moves/test_is_starting_rank.cpp index 4e0a7aa9..2aa2e0e3 100644 --- a/tests/bitbishop/movegen/test_pawn_moves/test_is_starting_rank.cpp +++ b/tests/bitbishop/movegen/test_pawn_moves/test_is_starting_rank.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + /** * @test Verifies is_starting_rank returns true for White pawns on rank 2 (A2-H2). */ @@ -46,4 +48,6 @@ TEST(PawnMoveGeneratorTest, IsStartingRankFromNotSartingRankForBlack) { for (int sq = Square::A8; sq <= Square::H8; sq++) { ASSERT_FALSE(is_starting_rank(Square(sq), Color::BLACK)) << "for square " << Square(sq).to_string(); } -} \ No newline at end of file +} + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_pins/test_compute_pins.cpp b/tests/bitbishop/movegen/test_pins/test_compute_pins.cpp index 8902f713..38f6683e 100644 --- a/tests/bitbishop/movegen/test_pins/test_compute_pins.cpp +++ b/tests/bitbishop/movegen/test_pins/test_compute_pins.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -380,3 +382,5 @@ TEST(ComputePinsTest, AdjacentSliderNotPinned) { EXPECT_EQ(result.pinned, Bitboard::Zeros()); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_pins/test_pin_ray/test_first_blocker.cpp b/tests/bitbishop/movegen/test_pins/test_pin_ray/test_first_blocker.cpp index 7dd4e72f..63386f51 100644 --- a/tests/bitbishop/movegen/test_pins/test_pin_ray/test_first_blocker.cpp +++ b/tests/bitbishop/movegen/test_pins/test_pin_ray/test_first_blocker.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -151,3 +153,5 @@ TEST(PinRayTest, FirstBlockerSouthwestDirection) { EXPECT_EQ(blocker, F6); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_pins/test_pin_ray/test_matches_slider.cpp b/tests/bitbishop/movegen/test_pins/test_pin_ray/test_matches_slider.cpp index 7d34973d..1bcb4efa 100644 --- a/tests/bitbishop/movegen/test_pins/test_pin_ray/test_matches_slider.cpp +++ b/tests/bitbishop/movegen/test_pins/test_pin_ray/test_matches_slider.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -151,3 +153,5 @@ TEST(PinRayTest, MatchesSliderWhiteRookAsEnemy) { EXPECT_TRUE(ray.matches_slider(piece_bb, board, piece.color())); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_pins/test_scan_pin_ray.cpp b/tests/bitbishop/movegen/test_pins/test_scan_pin_ray.cpp index 2798586a..3013a3d4 100644 --- a/tests/bitbishop/movegen/test_pins/test_scan_pin_ray.cpp +++ b/tests/bitbishop/movegen/test_pins/test_scan_pin_ray.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -450,3 +452,5 @@ TEST(ScanPinRayTest, MultipleScansAccumulate) { EXPECT_TRUE(result.pinned.test(E6)); EXPECT_TRUE(result.pinned.test(G4)); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_queen_moves.cpp b/tests/bitbishop/movegen/test_queen_moves.cpp index c0813458..accb5ccf 100644 --- a/tests/bitbishop/movegen/test_queen_moves.cpp +++ b/tests/bitbishop/movegen/test_queen_moves.cpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -510,3 +512,5 @@ TEST(GenerateQueenLegalMovesTest, QueenOnEdge) { EXPECT_TRUE(contains_move(moves, {A4, D7, std::nullopt, false, false, false})); EXPECT_TRUE(contains_move(moves, {A4, D1, std::nullopt, false, false, false})); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/movegen/test_rook_moves.cpp b/tests/bitbishop/movegen/test_rook_moves.cpp index 75122ae6..5a6816ea 100644 --- a/tests/bitbishop/movegen/test_rook_moves.cpp +++ b/tests/bitbishop/movegen/test_rook_moves.cpp @@ -8,6 +8,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -496,3 +498,5 @@ TEST(GenerateRookLegalMovesTest, RookCompletelyBlocked) { EXPECT_EQ(moves.size(), 0); } + +} // namespace bitbishop::testing diff --git a/tests/bitbishop/moves/test_move_builder.cpp b/tests/bitbishop/moves/test_move_builder.cpp index a475e46b..59842b10 100644 --- a/tests/bitbishop/moves/test_move_builder.cpp +++ b/tests/bitbishop/moves/test_move_builder.cpp @@ -7,6 +7,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -666,3 +668,5 @@ TEST(MoveExecutionTest, FullMoveNumberRestoredOnRevert) { EXPECT_EQ(board.get_state().m_fullmove_number, before.m_fullmove_number); EXPECT_EQ(board.get_state().m_is_white_turn, before.m_is_white_turn); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/moves/test_move_effect.cpp b/tests/bitbishop/moves/test_move_effect.cpp index 44618e46..22797077 100644 --- a/tests/bitbishop/moves/test_move_effect.cpp +++ b/tests/bitbishop/moves/test_move_effect.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -405,3 +407,5 @@ TEST(MoveEffectTest, RevertRemoveDoesNotAffectOtherPieces) { EXPECT_EQ(board.get_piece(D4), WHITE_KNIGHT); EXPECT_EQ(board.get_piece(F4), WHITE_BISHOP); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/moves/test_move_execution.cpp b/tests/bitbishop/moves/test_move_execution.cpp index f4e08301..3b9bf9bb 100644 --- a/tests/bitbishop/moves/test_move_execution.cpp +++ b/tests/bitbishop/moves/test_move_execution.cpp @@ -6,6 +6,7 @@ #include #include +namespace bitbishop::testing { using namespace Squares; using namespace Pieces; @@ -113,3 +114,5 @@ TEST(MoveExecutionTest, DoubleApplyDoubleRevertRestoresBoard) { EXPECT_EQ(board, original); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/moves/test_position.cpp b/tests/bitbishop/moves/test_position.cpp index a9f507ca..cd0ff78d 100644 --- a/tests/bitbishop/moves/test_position.cpp +++ b/tests/bitbishop/moves/test_position.cpp @@ -6,6 +6,8 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; @@ -109,3 +111,5 @@ TEST(PositionTest, RepetitionCountRollsBackOnRevert) { EXPECT_EQ(pos.repetition_count(), 2); EXPECT_FALSE(pos.is_threefold_repetition()); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/piece/test_piece_color.cpp b/tests/bitbishop/piece/test_piece_color.cpp index a115b295..a558efb8 100644 --- a/tests/bitbishop/piece/test_piece_color.cpp +++ b/tests/bitbishop/piece/test_piece_color.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + /** * @test Verifies all White pieces return correct color. */ @@ -96,3 +98,5 @@ TEST(PieceTest, ColorFromImvalidCharsThrows) { EXPECT_THROW(std::ignore = Piece::color_from_char('@'), std::invalid_argument); EXPECT_THROW(std::ignore = Piece::color_from_char('.'), std::invalid_argument); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/piece/test_piece_comparison_op.cpp b/tests/bitbishop/piece/test_piece_comparison_op.cpp index 79f66627..e47f9339 100644 --- a/tests/bitbishop/piece/test_piece_comparison_op.cpp +++ b/tests/bitbishop/piece/test_piece_comparison_op.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + /** * @test Verifies equality operator for same pieces. */ @@ -38,3 +40,5 @@ TEST(PieceTest, SameTypeDifferentColorsNotEqual) { EXPECT_NE(white_pawn.color(), black_pawn.color()); EXPECT_NE(white_pawn, black_pawn); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/piece/test_piece_constructors.cpp b/tests/bitbishop/piece/test_piece_constructors.cpp index dc3edfda..efabc762 100644 --- a/tests/bitbishop/piece/test_piece_constructors.cpp +++ b/tests/bitbishop/piece/test_piece_constructors.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + /** * @test Verifies construction from Type and Color. */ @@ -195,3 +197,5 @@ TEST(PieceTest, TypeColorConstructorSetsCorrectProperties) { EXPECT_TRUE(white_queen.is_white()); EXPECT_FALSE(white_queen.is_black()); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/piece/test_piece_is_promotion.cpp b/tests/bitbishop/piece/test_piece_is_promotion.cpp index 6ac98dc1..c2798d5a 100644 --- a/tests/bitbishop/piece/test_piece_is_promotion.cpp +++ b/tests/bitbishop/piece/test_piece_is_promotion.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + TEST(PieceTest, IsPromotionReturnsTrueOnPromotionPieces) { EXPECT_TRUE(Pieces::BLACK_BISHOP.is_promotion()); EXPECT_TRUE(Pieces::BLACK_KNIGHT.is_promotion()); @@ -21,3 +23,5 @@ TEST(PieceTest, IsPromotionReturnsFalseOnNonPromotionPieces) { EXPECT_FALSE(Pieces::WHITE_KING.is_promotion()); EXPECT_FALSE(Pieces::WHITE_PAWN.is_promotion()); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/piece/test_piece_name.cpp b/tests/bitbishop/piece/test_piece_name.cpp index d80d72f8..20264012 100644 --- a/tests/bitbishop/piece/test_piece_name.cpp +++ b/tests/bitbishop/piece/test_piece_name.cpp @@ -2,7 +2,7 @@ #include -using namespace Pieces; +namespace bitbishop::testing { TEST(PieceTest, NameFromTypeHasCorrectName) { struct TestCase { @@ -21,3 +21,5 @@ TEST(PieceTest, NameFromTypeHasUnknownType) { Piece::Type invalid_type = static_cast(155); EXPECT_STREQ(Piece::name(invalid_type), "unknown"); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/piece/test_piece_to_char.cpp b/tests/bitbishop/piece/test_piece_to_char.cpp index c34d1223..395650b9 100644 --- a/tests/bitbishop/piece/test_piece_to_char.cpp +++ b/tests/bitbishop/piece/test_piece_to_char.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + /** * @test Verifies to_char() round-trips correctly. */ @@ -13,3 +15,5 @@ TEST(PieceTest, ToCharRoundTrips) { EXPECT_EQ(p.to_char(), c); } } + +} // namespace bitbishop::testing diff --git a/tests/bitbishop/piece/test_piece_type.cpp b/tests/bitbishop/piece/test_piece_type.cpp index f2170d25..2f33e8b9 100644 --- a/tests/bitbishop/piece/test_piece_type.cpp +++ b/tests/bitbishop/piece/test_piece_type.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + /** * @test Verifies same piece type for both colors. */ @@ -38,3 +40,5 @@ TEST(PieceTest, GetAllPieceTypes) { EXPECT_EQ(types, expected); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/piece/test_pieces_namespace_constants.cpp b/tests/bitbishop/piece/test_pieces_namespace_constants.cpp index 0a1a7149..54ebc218 100644 --- a/tests/bitbishop/piece/test_pieces_namespace_constants.cpp +++ b/tests/bitbishop/piece/test_pieces_namespace_constants.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + /** * @test Verifies White piece constants are correctly defined. */ @@ -63,3 +65,5 @@ TEST(PieceTest, ConstantsCanBeUsedInComparisons) { EXPECT_NE(p, BLACK_PAWN); EXPECT_NE(p, WHITE_KNIGHT); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/test_color.cpp b/tests/bitbishop/test_color.cpp index 5e7562eb..908d341e 100644 --- a/tests/bitbishop/test_color.cpp +++ b/tests/bitbishop/test_color.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + /** * @brief Test fixture for Color enum formatting tests. */ @@ -61,3 +63,5 @@ TEST(ColorUtilsTest, HasCorrectNumberOfColors) { EXPECT_EQ(nb_colors, 2); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/test_move.cpp b/tests/bitbishop/test_move.cpp index cc2d5f73..f3a0eb6a 100644 --- a/tests/bitbishop/test_move.cpp +++ b/tests/bitbishop/test_move.cpp @@ -3,10 +3,14 @@ #include #include +namespace bitbishop::testing { + using namespace Squares; using namespace Pieces; +namespace { static const std::regex uci_move_regex("^[a-z1-8]{4,5}$"); +} TEST(MoveTest, NormalMove_NoCapture) { Square from = E2; @@ -212,3 +216,5 @@ TEST(MoveTest, FromUciInvalidPromotionPieceThrows) { TEST(MoveTest, FromUciInvalidPromotionRankThrows) { EXPECT_THROW(std::ignore = Move::from_uci("e2e4q"), std::runtime_error); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/test_random.cpp b/tests/bitbishop/test_random.cpp index 47767d69..5e4c3823 100644 --- a/tests/bitbishop/test_random.cpp +++ b/tests/bitbishop/test_random.cpp @@ -3,11 +3,15 @@ #include #include +namespace bitbishop::testing { + +namespace { static constexpr uint64_t INITIAL_SEED = 0xdd40af6e35fd248ULL; // Known-good values generated from the SplitMix64 reference implementation static constexpr uint64_t KNOWN_SEED_SEQUENCE[] = {0xbd9e4ea9d61be97bULL, 0x17da6008d8998017ULL, 0x4a5427b076bdfcb1ULL, 0x5df4deae0f2ad481ULL}; +} // namespace TEST(SplitMix64Test, SameSeedProducesSameFirstValue) { uint64_t seed1 = INITIAL_SEED; @@ -58,3 +62,5 @@ TEST(SplitMix64Test, MatchesReferenceSequence) { EXPECT_EQ(Random::splitmix64(seed), expected); } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/test_square.cpp b/tests/bitbishop/test_square.cpp index 065a266b..c0f963b7 100644 --- a/tests/bitbishop/test_square.cpp +++ b/tests/bitbishop/test_square.cpp @@ -2,6 +2,8 @@ #include +namespace bitbishop::testing { + using namespace Squares; // --- Construction Tests --- @@ -328,3 +330,5 @@ TEST(SquareTest, DiagonalSquaresHaveSameColors) { EXPECT_TRUE(a.same_color(b)); } } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/test_zobrist.cpp b/tests/bitbishop/test_zobrist.cpp index 0009941b..03a2661a 100644 --- a/tests/bitbishop/test_zobrist.cpp +++ b/tests/bitbishop/test_zobrist.cpp @@ -5,6 +5,8 @@ #include #include +namespace bitbishop::testing { + using namespace Zobrist; TEST(ZobristTest, MutatePieceIsReversible) { @@ -281,3 +283,5 @@ TEST(ZobristTest, IncrementalHashMatchesFullRecompute) { EXPECT_EQ(incremental, recomputed); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/tools/test_perft.cpp b/tests/bitbishop/tools/test_perft.cpp index 14f6f084..dc3c915b 100644 --- a/tests/bitbishop/tools/test_perft.cpp +++ b/tests/bitbishop/tools/test_perft.cpp @@ -3,6 +3,8 @@ #include #include +namespace bitbishop::testing { + struct PerftTestCase { std::string test_name; std::string fen; @@ -12,7 +14,7 @@ struct PerftTestCase { struct PerftParamName { template - std::string operator()(const testing::TestParamInfo& info) const { + std::string operator()(const ::testing::TestParamInfo& info) const { return info.param.test_name; } }; @@ -314,3 +316,5 @@ TEST(PerftTest, SymmetricPositionsEqual) { EXPECT_EQ(white_nodes, black_nodes); } + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/tools/test_perft_divide.cpp b/tests/bitbishop/tools/test_perft_divide.cpp index a111c505..1753fda9 100644 --- a/tests/bitbishop/tools/test_perft_divide.cpp +++ b/tests/bitbishop/tools/test_perft_divide.cpp @@ -4,6 +4,8 @@ #include #include +namespace bitbishop::testing { + using PerftDivideMap = std::unordered_map; /** @@ -48,7 +50,7 @@ struct PerftDivideTestCase { struct PerftDivideParamName { template - std::string operator()(const testing::TestParamInfo& info) const { + std::string operator()(const ::testing::TestParamInfo& info) const { return info.param.test_name; } }; @@ -198,3 +200,5 @@ INSTANTIATE_TEST_SUITE_P( ) ); // clang-format on + +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/tools/test_time_guard.cpp b/tests/bitbishop/tools/test_time_guard.cpp index 45f8ba99..1dae035d 100644 --- a/tests/bitbishop/tools/test_time_guard.cpp +++ b/tests/bitbishop/tools/test_time_guard.cpp @@ -3,7 +3,9 @@ #include #include -using namespace Tools; +namespace bitbishop::testing { + +using Tools::TimeGuard; /** * @brief Repeatedly evaluates the predicate until it returns true or timeout is reached. @@ -53,3 +55,5 @@ TEST(TimeGuardTest, StopFlagIsNotSetWhenTimeGuardIsDestroyedEarly) { } EXPECT_FALSE(should_stop.load()); } + +} // namespace bitbishop::testing \ No newline at end of file From 9762efd4b26dc469ed376fae24f0089ab679cdd9 Mon Sep 17 00:00:00 2001 From: Baptiste Penot Date: Sat, 24 Oct 2026 17:11:44 +0200 Subject: [PATCH 2/3] ran clang-format --- tests/bitbishop/helpers/blocking_stream.hpp | 2 +- tests/bitbishop/helpers/moves.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/bitbishop/helpers/blocking_stream.hpp b/tests/bitbishop/helpers/blocking_stream.hpp index e198f669..5fae80e5 100644 --- a/tests/bitbishop/helpers/blocking_stream.hpp +++ b/tests/bitbishop/helpers/blocking_stream.hpp @@ -104,4 +104,4 @@ class BlockingIStream : public std::istream { BlockingStreamBuf buf_; ///< Underlying buffer }; -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::testing \ No newline at end of file diff --git a/tests/bitbishop/helpers/moves.hpp b/tests/bitbishop/helpers/moves.hpp index 5e8e5ff8..dd6a7d59 100644 --- a/tests/bitbishop/helpers/moves.hpp +++ b/tests/bitbishop/helpers/moves.hpp @@ -220,4 +220,4 @@ std::vector find_moves_between(const std::vector& moves, Square from return filter_moves(moves, [&](const Move& m) { return m.from == from && m.to == to; }); } -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::testing \ No newline at end of file From 5dc63977624d711aefdf7e9d95970f85911d9ea0 Mon Sep 17 00:00:00 2001 From: Baptiste Penot Date: Sat, 24 Oct 2026 17:20:09 +0200 Subject: [PATCH 3/3] fixed clang-tidy issues --- include/bitbishop/bitmasks.hpp | 8 ++------ include/bitbishop/constants.hpp | 8 ++------ include/bitbishop/engine/evaluation.hpp | 8 ++------ include/bitbishop/interface/search_session.hpp | 8 ++------ include/bitbishop/interface/search_worker.hpp | 8 ++------ include/bitbishop/interface/uci_command_channel.hpp | 8 ++------ include/bitbishop/interface/uci_command_registry.hpp | 8 ++------ include/bitbishop/interface/uci_engine.hpp | 8 ++------ include/bitbishop/lookups/between_squares.hpp | 8 ++------ include/bitbishop/lookups/bishop_rays.hpp | 8 ++------ include/bitbishop/lookups/king_attacks.hpp | 8 ++------ include/bitbishop/lookups/knight_attacks.hpp | 8 ++------ include/bitbishop/lookups/pawn_attacks.hpp | 8 ++------ include/bitbishop/lookups/queen_rays.hpp | 8 ++------ include/bitbishop/lookups/rook_rays.hpp | 8 ++------ include/bitbishop/random.hpp | 8 ++------ include/bitbishop/tools/perft.hpp | 8 ++------ include/bitbishop/tools/time_guard.hpp | 8 ++------ src/bitbishop/tools/perft.cpp | 8 ++------ src/bitbishop/tools/time_guard.cpp | 8 ++------ 20 files changed, 40 insertions(+), 120 deletions(-) diff --git a/include/bitbishop/bitmasks.hpp b/include/bitbishop/bitmasks.hpp index a0407567..a1e7dad1 100644 --- a/include/bitbishop/bitmasks.hpp +++ b/include/bitbishop/bitmasks.hpp @@ -3,8 +3,6 @@ #include #include -namespace bitbishop { - /** * @namespace Bitmasks * @brief Defines precomputed bitmasks that can be applied during move generation. @@ -37,7 +35,7 @@ namespace bitbishop { * * Hence: 0000 0000 0000 0000 ... 0000 0000 1111 1111 = 0x00000000000000FF */ -namespace Bitmasks { +namespace bitbishop::Bitmasks { /** * uint64_t mask with ones on file A. @@ -119,6 +117,4 @@ CX_INLINE uint64_t RANK_7 = 0x00FF000000000000ULL; */ CX_INLINE uint64_t RANK_8 = 0xFF00000000000000ULL; -} // namespace Bitmasks - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Bitmasks diff --git a/include/bitbishop/constants.hpp b/include/bitbishop/constants.hpp index 1f24efde..67233211 100644 --- a/include/bitbishop/constants.hpp +++ b/include/bitbishop/constants.hpp @@ -2,8 +2,6 @@ #include -namespace bitbishop { - /** * @namespace Const * @brief Core chess board constants for indexing and dimensions. @@ -23,7 +21,7 @@ namespace bitbishop { * int file = e4.value() % Const::BOARD_WIDTH; // file = 4 (file E) * @endcode */ -namespace Const { +namespace bitbishop::Const { // Board dimensions CX_INLINE int BOARD_WIDTH = 8; // Chess board is 8x8 @@ -100,6 +98,4 @@ CX_INLINE int FEN_NOTATION_MAX_CHAR_COUNT = BOARD_SIZE // 64 chessboard squares + 1 // fullmove ; -} // namespace Const - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Const \ No newline at end of file diff --git a/include/bitbishop/engine/evaluation.hpp b/include/bitbishop/engine/evaluation.hpp index 0ae0ce55..17cceb24 100644 --- a/include/bitbishop/engine/evaluation.hpp +++ b/include/bitbishop/engine/evaluation.hpp @@ -4,9 +4,7 @@ #include #include -namespace bitbishop { - -namespace Eval { +namespace bitbishop::Eval { using PieceSquareTable = std::array; @@ -209,6 +207,4 @@ CX_INLINE PieceSquareTable KING_MIDGAME_PSQT_BLACK = flip_psqt(KING_MIDGAME_PSQT */ [[nodiscard]] int evaluate(const Board& board) noexcept; -} // namespace Eval - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Eval diff --git a/include/bitbishop/interface/search_session.hpp b/include/bitbishop/interface/search_session.hpp index 7920fa62..474ac303 100644 --- a/include/bitbishop/interface/search_session.hpp +++ b/include/bitbishop/interface/search_session.hpp @@ -5,9 +5,7 @@ #include #include -namespace bitbishop { - -namespace Uci { +namespace bitbishop::Uci { /** * @brief Owns the lifecycle of one active search and its reporter. @@ -68,6 +66,4 @@ class SearchSession { [[nodiscard]] bool is_idle() const { return worker == nullptr; } }; -} // namespace Uci - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Uci \ No newline at end of file diff --git a/include/bitbishop/interface/search_worker.hpp b/include/bitbishop/interface/search_worker.hpp index 567b31f6..41a6c8d8 100644 --- a/include/bitbishop/interface/search_worker.hpp +++ b/include/bitbishop/interface/search_worker.hpp @@ -8,9 +8,7 @@ #include #include -namespace bitbishop { - -namespace Uci { +namespace bitbishop::Uci { /** * @brief Represents search limits for the UCI interface. @@ -143,6 +141,4 @@ class SearchWorker { [[nodiscard]] std::vector drain_reports(); }; -} // namespace Uci - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Uci \ No newline at end of file diff --git a/include/bitbishop/interface/uci_command_channel.hpp b/include/bitbishop/interface/uci_command_channel.hpp index bd968c45..d55079a5 100644 --- a/include/bitbishop/interface/uci_command_channel.hpp +++ b/include/bitbishop/interface/uci_command_channel.hpp @@ -10,9 +10,7 @@ #include #include -namespace bitbishop { - -namespace Uci { +namespace bitbishop::Uci { /** * @brief Thread-safe command line channel for UCI input. @@ -73,6 +71,4 @@ class UciCommandChannel { [[nodiscard]] bool eof() const; }; -} // namespace Uci - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Uci \ No newline at end of file diff --git a/include/bitbishop/interface/uci_command_registry.hpp b/include/bitbishop/interface/uci_command_registry.hpp index 456dd147..336f06da 100644 --- a/include/bitbishop/interface/uci_command_registry.hpp +++ b/include/bitbishop/interface/uci_command_registry.hpp @@ -5,9 +5,7 @@ #include #include -namespace bitbishop { - -namespace Uci { +namespace bitbishop::Uci { /** * @brief Registry mapping UCI command names to handlers. @@ -40,6 +38,4 @@ class UciCommandRegistry { [[nodiscard]] std::size_t get_handlers_count() const noexcept { return handlers.size(); } }; -} // namespace Uci - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Uci \ No newline at end of file diff --git a/include/bitbishop/interface/uci_engine.hpp b/include/bitbishop/interface/uci_engine.hpp index aef6632f..95264f92 100644 --- a/include/bitbishop/interface/uci_engine.hpp +++ b/include/bitbishop/interface/uci_engine.hpp @@ -11,9 +11,7 @@ #include #include -namespace bitbishop { - -namespace Uci { +namespace bitbishop::Uci { /** * @brief Splits a string into a vector of tokens. @@ -170,6 +168,4 @@ class UciEngine { void handle_bench(const std::vector &line); }; -} // namespace Uci - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Uci \ No newline at end of file diff --git a/include/bitbishop/lookups/between_squares.hpp b/include/bitbishop/lookups/between_squares.hpp index 733a2884..b6f2c664 100644 --- a/include/bitbishop/lookups/between_squares.hpp +++ b/include/bitbishop/lookups/between_squares.hpp @@ -5,9 +5,7 @@ #include #include -namespace bitbishop { - -namespace Lookups { +namespace bitbishop::Lookups { /** * @brief Computes the directional step between two aligned squares. @@ -118,6 +116,4 @@ CX_INLINE std::array, Const::BOARD_SIZE> return table; }(); -} // namespace Lookups - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Lookups diff --git a/include/bitbishop/lookups/bishop_rays.hpp b/include/bitbishop/lookups/bishop_rays.hpp index 5a4d4ede..e130d073 100644 --- a/include/bitbishop/lookups/bishop_rays.hpp +++ b/include/bitbishop/lookups/bishop_rays.hpp @@ -7,9 +7,7 @@ #include #include -namespace bitbishop { - -namespace Lookups { +namespace bitbishop::Lookups { /** * @brief Returns the full northeast diagonal ray from a square. @@ -224,6 +222,4 @@ CX_INLINE std::array BISHOP_SOUTHWEST_RAYS = [] CX_ */ CX_INLINE std::array BISHOP_ATTACKER_RAYS = BISHOP_RAYS; -} // namespace Lookups - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Lookups \ No newline at end of file diff --git a/include/bitbishop/lookups/king_attacks.hpp b/include/bitbishop/lookups/king_attacks.hpp index da044a77..3c2f6a44 100644 --- a/include/bitbishop/lookups/king_attacks.hpp +++ b/include/bitbishop/lookups/king_attacks.hpp @@ -6,9 +6,7 @@ #include #include -namespace bitbishop { - -namespace Lookups { +namespace bitbishop::Lookups { /** * @brief Computes the attack bitboard for a king on a given square. @@ -79,6 +77,4 @@ CX_INLINE std::array KING_ATTACKS = [] CX_EXEC { */ CX_INLINE std::array KING_ATTACKERS = KING_ATTACKS; -} // namespace Lookups - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Lookups diff --git a/include/bitbishop/lookups/knight_attacks.hpp b/include/bitbishop/lookups/knight_attacks.hpp index a7aca15c..bd2d52ea 100644 --- a/include/bitbishop/lookups/knight_attacks.hpp +++ b/include/bitbishop/lookups/knight_attacks.hpp @@ -6,9 +6,7 @@ #include #include -namespace bitbishop { - -namespace Lookups { +namespace bitbishop::Lookups { /** * @brief Computes the attack bitboard for a knight on a given square. @@ -72,6 +70,4 @@ CX_INLINE std::array KNIGHT_ATTACKS = [] CX_EXEC { */ CX_INLINE std::array KNIGHT_ATTACKERS = KNIGHT_ATTACKS; -} // namespace Lookups - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Lookups \ No newline at end of file diff --git a/include/bitbishop/lookups/pawn_attacks.hpp b/include/bitbishop/lookups/pawn_attacks.hpp index cc0ac81e..22174519 100644 --- a/include/bitbishop/lookups/pawn_attacks.hpp +++ b/include/bitbishop/lookups/pawn_attacks.hpp @@ -8,9 +8,7 @@ #include #include -namespace bitbishop { - -namespace Lookups { +namespace bitbishop::Lookups { /** * @brief Precomputed bitboards for white pawn single pushes (1 square forward). @@ -298,6 +296,4 @@ CX_INLINE std::array, ColorUtil::SIZE> P return table; }(); -} // namespace Lookups - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Lookups \ No newline at end of file diff --git a/include/bitbishop/lookups/queen_rays.hpp b/include/bitbishop/lookups/queen_rays.hpp index cc54a880..8710f031 100644 --- a/include/bitbishop/lookups/queen_rays.hpp +++ b/include/bitbishop/lookups/queen_rays.hpp @@ -9,9 +9,7 @@ #include #include -namespace bitbishop { - -namespace Lookups { +namespace bitbishop::Lookups { /** * @brief Generates all queen rays from a given square, independent of board occupancy. @@ -62,6 +60,4 @@ CX_INLINE std::array QUEEN_RAYS = [] CX_EXEC { */ CX_INLINE std::array QUEEN_ATTACKER_RAYS = QUEEN_RAYS; -} // namespace Lookups - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Lookups \ No newline at end of file diff --git a/include/bitbishop/lookups/rook_rays.hpp b/include/bitbishop/lookups/rook_rays.hpp index 729f0274..f9afd588 100644 --- a/include/bitbishop/lookups/rook_rays.hpp +++ b/include/bitbishop/lookups/rook_rays.hpp @@ -7,9 +7,7 @@ #include #include -namespace bitbishop { - -namespace Lookups { +namespace bitbishop::Lookups { /** * @brief Generates the northward rook ray from a given square, independent of board occupancy. @@ -211,6 +209,4 @@ CX_INLINE std::array ROOK_WEST_RAYS = [] CX_EXEC { */ CX_INLINE std::array ROOK_ATTACKER_RAYS = ROOK_RAYS; -} // namespace Lookups - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Lookups \ No newline at end of file diff --git a/include/bitbishop/random.hpp b/include/bitbishop/random.hpp index 790e386d..f603b667 100644 --- a/include/bitbishop/random.hpp +++ b/include/bitbishop/random.hpp @@ -3,9 +3,7 @@ #include #include -namespace bitbishop { - -namespace Random { +namespace bitbishop::Random { /** * @brief Generates a pseudo-random 64-bit integer using the SplitMix64 algorithm. * @@ -36,6 +34,4 @@ namespace Random { // NOLINTEND(readability-magic-numbers) } -} // namespace Random - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Random \ No newline at end of file diff --git a/include/bitbishop/tools/perft.hpp b/include/bitbishop/tools/perft.hpp index e3beb1d5..5f3da33a 100644 --- a/include/bitbishop/tools/perft.hpp +++ b/include/bitbishop/tools/perft.hpp @@ -2,9 +2,7 @@ #include -namespace bitbishop { - -namespace Tools { +namespace bitbishop::Tools { /** * @brief Perft (Performance Test) debug function to walk through the move generation tree @@ -28,6 +26,4 @@ uint64_t perft(Board& board, std::size_t depth); */ void perft_divide(Board& board, std::size_t depth); -} // namespace Tools - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Tools diff --git a/include/bitbishop/tools/time_guard.hpp b/include/bitbishop/tools/time_guard.hpp index bd1b0465..89aab5e5 100644 --- a/include/bitbishop/tools/time_guard.hpp +++ b/include/bitbishop/tools/time_guard.hpp @@ -5,9 +5,7 @@ #include #include -namespace bitbishop { - -namespace Tools { +namespace bitbishop::Tools { /** * @class TimeGuard @@ -77,6 +75,4 @@ class TimeGuard { void cancel(); }; -} // namespace Tools - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Tools diff --git a/src/bitbishop/tools/perft.cpp b/src/bitbishop/tools/perft.cpp index a5afefb9..0c5b97f1 100644 --- a/src/bitbishop/tools/perft.cpp +++ b/src/bitbishop/tools/perft.cpp @@ -4,9 +4,7 @@ #include #include -namespace bitbishop { - -namespace Tools { +namespace bitbishop::Tools { uint64_t perft(Board& board, std::size_t depth) { uint64_t nodes = 0; @@ -46,6 +44,4 @@ void perft_divide(Board& board, std::size_t depth) { std::cout << "\nNodes searched: " << total_nodes << "\n"; } -} // namespace Tools - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Tools diff --git a/src/bitbishop/tools/time_guard.cpp b/src/bitbishop/tools/time_guard.cpp index 89889751..f90a34a2 100644 --- a/src/bitbishop/tools/time_guard.cpp +++ b/src/bitbishop/tools/time_guard.cpp @@ -1,8 +1,6 @@ #include -namespace bitbishop { - -namespace Tools { +namespace bitbishop::Tools { TimeGuard::TimeGuard(std::atomic& stop_flag, std::chrono::steady_clock::duration timeout) : m_stop_flag(stop_flag), m_timeout(timeout) { @@ -35,6 +33,4 @@ void TimeGuard::cancel() { } } -} // namespace Tools - -} // namespace bitbishop \ No newline at end of file +} // namespace bitbishop::Tools \ No newline at end of file