PerftTestCase

Struct PerftTestCase 

Source
pub struct PerftTestCase {
    pub fen: String,
    /* private fields */
}
Expand description

Represents a perft test case.

Contains a FEN string and a list of expected results for different depths.

§Examples

use chessly::PerftTestCase;

let test_case = PerftTestCase::try_from("4k3/8/8/8/8/8/8/4K2R b K - 0 1 ;D1 5 ;D2 75 ;D3 459 ;D4 8290 ;D5 47635 ;D6 899442").unwrap();
assert_eq!(test_case.fen, "4k3/8/8/8/8/8/8/4K2R b K - 0 1");

test_case.run(6, |result| {
   assert!(result.is_ok());
});

Fields§

§fen: String

The FEN string of a position to test.

Implementations§

Source§

impl PerftTestCase

Source

pub fn run(&self, max_depth: u8, callback: impl Fn(PerftTestResult))

Runs the test case.

The callback is called for each depth, with a PerftTestResult as argument.

§Panics

Panics if the FEN string is invalid.

§Examples
use chessly::PerftTestCase;

let test_case = PerftTestCase::try_from("4k3/8/8/8/8/8/8/4K2R b K - 0 1 ;D1 5 ;D2 75 ;D3 459 ;D4 8290 ;D5 47635 ;D6 899442").unwrap();
assert_eq!(test_case.fen, "4k3/8/8/8/8/8/8/4K2R b K - 0 1");

test_case.run(6, |result| {
  assert!(result.is_ok());
});

Trait Implementations§

Source§

impl Debug for PerftTestCase

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TryFrom<&str> for PerftTestCase

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V