diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-09-14 17:49:07 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-09-14 17:50:55 +0300 |
commit | a881be4856c6d3dc7675059d5a635d34434b5797 (patch) | |
tree | de1551798279a2fa048e70c977b3c3f98f515d62 /src/main.c | |
parent | 71f28db1b8e26377d56f0eb0aef01f6c6c3afbd0 (diff) | |
download | j1chess-a881be4856c6d3dc7675059d5a635d34434b5797.tar.gz |
refactor: use lowerCamelCase for functions
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 56 |
1 files changed, 28 insertions, 28 deletions
@@ -3,75 +3,75 @@ #include "bitboard.h" int main() { - start_test_section("Bitboards"); { - unit_test(pop_count(0b01110) == 3, "Pop count of 01110 is 3"); + testSection("Bitboards"); { + unitTest(popCount(0b01110) == 3, "Pop count of 01110 is 3"); Bitboard bb = 0b1100; - unit_test(bitscanAndReset(&bb) == 2, "Bitscan of 0b1100 is 2"); - unit_test(bb == 0b1000, "After bitscan with reset the LS1B is flipped"); + unitTest(bitscanAndReset(&bb) == 2, "Bitscan of 0b1100 is 2"); + unitTest(bb == 0b1000, "After bitscan with reset the LS1B is flipped"); } - start_test_section("Default FEN string"); { - Board board = parse_FEN("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"); - unit_test(pop_count(board.pieces[PAWN] | board.pieces[PAWN | BLACK]) == 16, "There are 16 pawns total"); - unit_test(pop_count(board.pieces[ROOK]) == 2, "There are 2 white rooks"); + testSection("Default FEN string"); { + Board board = parseFEN("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"); + unitTest(popCount(board.pieces[PAWN] | board.pieces[PAWN | BLACK]) == 16, "There are 16 pawns total"); + unitTest(popCount(board.pieces[ROOK]) == 2, "There are 2 white rooks"); // TODO - unit_test(board.side == WHITE, "Side to move is white"); - unit_test(board.castling_rights == 0, "Both sides can castle"); - unit_test(board.en_passant_square == 0, "No en passant move is avaialble"); + unitTest(board.side == WHITE, "Side to move is white"); + unitTest(board.castlingRights == 0, "Both sides can castle"); + unitTest(board.enPassantSquare == 0, "No en passant move is avaialble"); } - start_test_section("Test knight attacks"); { + testSection("Test knight attacks"); { Bitboard attacks[64]; - precompute_knight_attack_table(attacks); + precomputeKnightAttackTable(attacks); int max_attacks = 0; for (int i = 0; i < 64; i++) { - int attack_count = pop_count(attacks[i]); + int attack_count = popCount(attacks[i]); if (attack_count > max_attacks) max_attacks = attack_count; } - unit_test(max_attacks == 8, "Max amount of knight attacks should be 8"); + unitTest(max_attacks == 8, "Max amount of knight attacks should be 8"); - unit_test( + unitTest( attacks[b7] == ((BIT << d8) | (BIT << d6) | (BIT << c5) | (BIT << a5)), "Knight on b7 attacks only d8, d6, c5, a5" ); } - start_test_section("Test king attacks"); { + testSection("Test king attacks"); { Bitboard attacks[64]; - precompute_king_attack_table(attacks); + precomputeKingAttackTable(attacks); int max_attacks = 0; for (int i = 0; i < 64; i++) { - int attack_count = pop_count(attacks[i]); + int attack_count = popCount(attacks[i]); if (attack_count > max_attacks) max_attacks = attack_count; } - unit_test(max_attacks == 8, "Max amount of king attacks should be 8"); + unitTest(max_attacks == 8, "Max amount of king attacks should be 8"); - unit_test( + unitTest( attacks[h2] == ((BIT << h1) | (BIT << g1) | (BIT << g2) | (BIT << g3) | (BIT << h3)), "King on h2 attacks only h1, g1, g2, g3, h3" ); } - start_test_section("Test pawn attacks"); { + testSection("Test pawn attacks"); { Bitboard white_attacks[64]; Bitboard black_attacks[64]; - precompute_pawn_attack_table(white_attacks, WHITE); - precompute_pawn_attack_table(black_attacks, BLACK); + precomputePawnAttackTable(white_attacks, WHITE); + precomputePawnAttackTable(black_attacks, BLACK); int is_same = 0; int max_attacks = 0; for (int i = 0; i < 64; i++) { - int attack_count = pop_count(white_attacks[i]); + int attack_count = popCount(white_attacks[i]); if (attack_count > max_attacks) max_attacks = attack_count; if (white_attacks[i] == black_attacks[i]) is_same = 1; } - unit_test(max_attacks == 2, "Max amount of pawn attacks should be 2"); - unit_test(is_same == 0, "Black and white pawns always move differently"); - unit_test(white_attacks[g2] == (BIT << h3 | BIT << f3), "White pawn on g2 attacks only h3 and f3"); + unitTest(max_attacks == 2, "Max amount of pawn attacks should be 2"); + unitTest(is_same == 0, "Black and white pawns always move differently"); + unitTest(white_attacks[g2] == (BIT << h3 | BIT << f3), "White pawn on g2 attacks only h3 and f3"); } report(); |