Add some tests for checking only valid moves

master
Tait Hoyem 5 years ago
parent 8347d83391
commit 3c45e0ad75

@ -1,6 +1,7 @@
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include "test_boards.h"
#include "valid_moves.h"
#include <sstream>
#include <functions.h>
@ -146,6 +147,7 @@ TEST_CASE("Test that invalid position ints return false", "[is_valid_position]")
TEST_CASE("Test what pieces may move where functon", "[get_possible_movers]"){
std::unordered_set<Position> H1_possible_movers = {Position::H2, Position::G1};
CHECK(get_possible_movers(BISHOP_BLOCKED1_KING_POS, BISHOP_BLOCKED1_BOARD) == BISHOP_BLOCKED1_CAN_MOVE_TO_B_KING);
CHECK(get_possible_movers(Position::H3, DEFAULT_BOARD) == H1_possible_movers);
}
@ -154,6 +156,8 @@ TEST_CASE("Test where this piece may move to", "[get_possible_moves]"){
std::unordered_set<Position> black_A_pawn_possible_moves = {Position::A6,Position::A5};
CHECK(get_possible_moves(Position::G1, DEFAULT_BOARD) == white_right_knight_possible_moves);
CHECK(get_possible_moves(Position::A7, DEFAULT_BOARD) == black_A_pawn_possible_moves);
CHECK(get_possible_moves(KNIGHT_BLOCKED1_POS, KNIGHT_BLOCKED1_BOARD) == KNIGHT_BLOCKED1_MOVES);
CHECK(get_possible_moves(BISHOP_BLOCKED1_POS, BISHOP_BLOCKED1_BOARD) == BISHOP_BLOCKED1_MOVES);
}
TEST_CASE("Test all possible and impossible moves for black pieces", "[get_all_moves][black]"){

@ -0,0 +1,43 @@
#include <unordered_set>
#include <constants.h>
const Position KNIGHT_BLOCKED1_POS = B8;
const std::array<PieceType, 64> KNIGHT_BLOCKED1_BOARD = {
NONE, B_KNIGHT, NONE, NONE, NONE, NONE, NONE, NONE,
NONE, NONE, NONE, B_PAWN, NONE, NONE, NONE, NONE,
NONE, NONE, W_PAWN, NONE, NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE
};
// Should NOT inclde D7
const std::unordered_set<Position> KNIGHT_BLOCKED1_MOVES = {
A6, C6
};
const Position BISHOP_BLOCKED1_POS = D5;
const std::array<PieceType, 64> BISHOP_BLOCKED1_BOARD = {
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
NONE, B_QUEEN, NONE , B_PAWN , NONE, W_KING, NONE, NONE,
NONE, NONE , NONE , NONE , NONE, NONE, NONE, NONE,
NONE, NONE , W_ROOK, W_BISHOP, NONE, NONE, NONE, NONE,
NONE, NONE , NONE , NONE , NONE, NONE, NONE, NONE,
NONE, NONE , NONE , NONE , NONE, B_KING, NONE, NONE,
NONE, NONE , NONE , NONE , NONE, NONE, NONE, NONE,
NONE, NONE , NONE , NONE , NONE, NONE, NONE, NONE
};
// Should NOT include A8, H8, G2, or H1
const std::unordered_set<Position> BISHOP_BLOCKED1_MOVES = {
B7,
C6,E6,
C4,E4,
B3,F3,
A2
};
// Should NOT include B2 (black queen) as it is obstructed by the bishop on D5
const std::unordered_set<Position> BISHOP_BLOCKED1_CAN_MOVE_TO_B_KING = {
D5
};
const Position BISHOP_BLOCKED1_KING_POS = F3;
Loading…
Cancel
Save