#include "unittest.h" #include "board.h" int main() { { // Pop count unit_test(pop_count(0b01110) == 3, "Pop count of 01110 is 3"); } { // Test knight attacks Bitboard attacks[64]; precompute_knight_attack_table(attacks); int max_attacks = 0; for (int i = 0; i < 64; i++) { int attack_count = pop_count(attacks[i]); if (attack_count > max_attacks) max_attacks = attack_count; } unit_test(max_attacks == 8, "Max amount of knight attacks should be 8"); { // Knight on b7 attack table U64 bit = 1; unit_test( attacks[b7] == ((bit << d8) | (bit << d6) | (bit << c5) | (bit << a5)), "Knight on b7 attacks d8, d6, c5, a5" ); } } report(); return 0; }