Implement some helpful testing types and traits in the moves package
This commit is contained in:
parent
d714374f35
commit
9b7bf3a212
4 changed files with 30 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
|||
// Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
use chessfriend_core::{piece, Color, File, Shape, Square};
|
||||
use chessfriend_moves::{Builder, BuilderError, Castle, PromotionShape};
|
||||
use chessfriend_moves::{testing::*, Builder, Castle, PromotionShape};
|
||||
|
||||
macro_rules! assert_flag {
|
||||
($move:expr, $left:expr, $right:expr, $desc:expr) => {
|
||||
|
@ -26,7 +26,7 @@ macro_rules! assert_flags {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn move_flags_quiet() -> Result<(), BuilderError> {
|
||||
fn move_flags_quiet() -> TestResult {
|
||||
let mv = Builder::push(&piece!(White Pawn on A4))
|
||||
.to(Square::A5)
|
||||
.build()?;
|
||||
|
@ -36,7 +36,7 @@ fn move_flags_quiet() -> Result<(), BuilderError> {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn move_flags_double_push() -> Result<(), BuilderError> {
|
||||
fn move_flags_double_push() -> TestResult {
|
||||
let mv = Builder::double_push(File::C, Color::White).build()?;
|
||||
assert_flags!(mv, false, true, false, false, false, false);
|
||||
|
||||
|
@ -44,7 +44,7 @@ fn move_flags_double_push() -> Result<(), BuilderError> {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn move_flags_capture() -> Result<(), BuilderError> {
|
||||
fn move_flags_capture() -> TestResult {
|
||||
let mv = Builder::new()
|
||||
.from(Square::A4)
|
||||
.capturing_on(Square::B5)
|
||||
|
@ -56,7 +56,7 @@ fn move_flags_capture() -> Result<(), BuilderError> {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn move_flags_en_passant_capture() -> Result<(), BuilderError> {
|
||||
fn move_flags_en_passant_capture() -> TestResult {
|
||||
let mv = unsafe {
|
||||
Builder::new()
|
||||
.from(Square::A4)
|
||||
|
@ -73,7 +73,7 @@ fn move_flags_en_passant_capture() -> Result<(), BuilderError> {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn move_flags_promotion() -> Result<(), BuilderError> {
|
||||
fn move_flags_promotion() -> TestResult {
|
||||
let mv = Builder::push(&piece!(White Pawn on H7))
|
||||
.to(Square::H8)
|
||||
.promoting_to(PromotionShape::Queen)
|
||||
|
@ -86,7 +86,7 @@ fn move_flags_promotion() -> Result<(), BuilderError> {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn move_flags_capture_promotion() -> Result<(), BuilderError> {
|
||||
fn move_flags_capture_promotion() -> TestResult {
|
||||
let mv = Builder::push(&piece!(White Pawn on H7))
|
||||
.to(Square::H8)
|
||||
.capturing_piece(&piece!(Black Knight on G8))
|
||||
|
@ -100,7 +100,7 @@ fn move_flags_capture_promotion() -> Result<(), BuilderError> {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn move_flags_castle() -> Result<(), BuilderError> {
|
||||
fn move_flags_castle() -> TestResult {
|
||||
let mv = Builder::castling(Castle::KingSide).build();
|
||||
|
||||
assert_flags!(mv, false, false, false, false, true, false);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
use chessfriend_core::{piece, Square};
|
||||
use chessfriend_moves::{Builder, BuilderError};
|
||||
use chessfriend_moves::{testing::*, Builder};
|
||||
|
||||
#[test]
|
||||
fn pawn_push() -> Result<(), BuilderError> {
|
||||
fn pawn_push() -> TestResult {
|
||||
let mv = Builder::push(&piece!(White Pawn on A3))
|
||||
.to(Square::A4)
|
||||
.build()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue