[board] Rename from_algebraic_string → from_algebraic_str
This commit is contained in:
parent
758a3d95fc
commit
9d0761f8c6
4 changed files with 15 additions and 15 deletions
|
@ -163,10 +163,10 @@ mod tests {
|
|||
fn has_piece_at() {
|
||||
let bb = BitBoard(0b1001100);
|
||||
|
||||
let c1 = Square::from_algebraic_string("c1").expect("Unable to get square for 'c1'");
|
||||
let c1 = Square::from_algebraic_str("c1").expect("Unable to get square for 'c1'");
|
||||
assert!(bb.has_piece_at(&c1));
|
||||
|
||||
let b1 = Square::from_algebraic_string("b1").expect("Unable to get square for 'b1'");
|
||||
let b1 = Square::from_algebraic_str("b1").expect("Unable to get square for 'b1'");
|
||||
assert!(!bb.has_piece_at(&b1));
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ mod tests {
|
|||
use std::collections::HashSet;
|
||||
|
||||
fn square_at(sq: &str) -> Square {
|
||||
Square::from_algebraic_string(sq).expect(sq)
|
||||
Square::from_algebraic_str(sq).expect(sq)
|
||||
}
|
||||
|
||||
fn place_piece_in_position(pos: &mut Position, sq: &str, piece: Piece) {
|
||||
|
@ -110,7 +110,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn one() {
|
||||
let sq = Square::from_algebraic_string("e4").expect("e4");
|
||||
let sq = Square::from_algebraic_str("e4").expect("e4");
|
||||
|
||||
let mut pos = Position::empty();
|
||||
pos.place_piece(&Piece::new(Color::White, Shape::Queen), &sq)
|
||||
|
|
|
@ -144,7 +144,7 @@ mod tests {
|
|||
let mut position = Position::empty();
|
||||
|
||||
let piece = Piece::new(Color::White, Shape::Queen);
|
||||
let square = Square::from_algebraic_string("e4").expect("Unable to get e4 square");
|
||||
let square = Square::from_algebraic_str("e4").expect("Unable to get e4 square");
|
||||
|
||||
position
|
||||
.place_piece(&piece, &square)
|
||||
|
|
|
@ -45,7 +45,7 @@ impl Square {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn from_algebraic_string(s: &str) -> Result<Square, ParseSquareError> {
|
||||
pub fn from_algebraic_str(s: &str) -> Result<Square, ParseSquareError> {
|
||||
s.parse()
|
||||
}
|
||||
|
||||
|
@ -142,27 +142,27 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn good_algebraic_input() {
|
||||
let sq1 = Square::from_algebraic_string("a4").expect("Failed to parse 'a4' square");
|
||||
let sq1 = Square::from_algebraic_str("a4").expect("Failed to parse 'a4' square");
|
||||
assert_eq!(sq1.file, 0);
|
||||
assert_eq!(sq1.rank, 3);
|
||||
|
||||
let sq2 = Square::from_algebraic_string("B8").expect("Failed to parse 'B8' square");
|
||||
let sq2 = Square::from_algebraic_str("B8").expect("Failed to parse 'B8' square");
|
||||
assert_eq!(sq2.file, 1);
|
||||
assert_eq!(sq2.rank, 7);
|
||||
|
||||
let sq3 = Square::from_algebraic_string("e4").expect("Failed to parse 'B8' square");
|
||||
let sq3 = Square::from_algebraic_str("e4").expect("Failed to parse 'B8' square");
|
||||
assert_eq!(sq3.rank, 3, "Expected rank of e4 to be 3");
|
||||
assert_eq!(sq3.file, 4, "Expected file of e4 to be 4");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_algebraic_input() {
|
||||
Square::from_algebraic_string("a0").expect_err("Got valid Square for 'a0'");
|
||||
Square::from_algebraic_string("j3").expect_err("Got valid Square for 'j3'");
|
||||
Square::from_algebraic_string("a11").expect_err("Got valid Square for 'a11'");
|
||||
Square::from_algebraic_string("b-1").expect_err("Got valid Square for 'b-1'");
|
||||
Square::from_algebraic_string("a 1").expect_err("Got valid Square for 'a 1'");
|
||||
Square::from_algebraic_string("").expect_err("Got valid Square for ''");
|
||||
Square::from_algebraic_str("a0").expect_err("Got valid Square for 'a0'");
|
||||
Square::from_algebraic_str("j3").expect_err("Got valid Square for 'j3'");
|
||||
Square::from_algebraic_str("a11").expect_err("Got valid Square for 'a11'");
|
||||
Square::from_algebraic_str("b-1").expect_err("Got valid Square for 'b-1'");
|
||||
Square::from_algebraic_str("a 1").expect_err("Got valid Square for 'a 1'");
|
||||
Square::from_algebraic_str("").expect_err("Got valid Square for ''");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue