aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-09-14 04:41:50 +0300
committereug-vs <eugene@eug-vs.xyz>2022-09-14 04:41:50 +0300
commit031ccb2d9e7993ed46bd40a5c3c78af86cb46ba4 (patch)
tree6f95027d51b093f72c1e33f57da176a02d7819d4 /src/main.c
parentefa8671eecdabcdccecde87c1d05acbc89295f49 (diff)
downloadj1chess-031ccb2d9e7993ed46bd40a5c3c78af86cb46ba4.tar.gz
test: group unittests into sections
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 2e95970..97e5d14 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2,11 +2,13 @@
#include "board.h"
int main() {
- { // Pop count
+ {
+ start_test_section("Bitboards");
unit_test(pop_count(0b01110) == 3, "Pop count of 01110 is 3");
}
- { // Test knight attacks
+ {
+ start_test_section("Test knight attacks");
Bitboard attacks[64];
precompute_knight_attack_table(attacks);
@@ -17,15 +19,23 @@ int main() {
}
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"
+ "Knight on b7 attacks only d8, d6, c5, a5"
);
}
}
+ {
+ start_test_section("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, "Default position has 16 pawns total");
+ unit_test(pop_count(board.pieces[ROOK]) == 2, "Default position has 2 white rooks");
+ unit_test(board.side == WHITE, "Side to moveSide to move is white");
+ }
+
report();
return 0;
}