diff --git a/board/src/bitboard/bitboard.rs b/board/src/bitboard/bitboard.rs index cbdaf1c..91cc60a 100644 --- a/board/src/bitboard/bitboard.rs +++ b/board/src/bitboard/bitboard.rs @@ -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)); } diff --git a/board/src/position/pieces.rs b/board/src/position/pieces.rs index b1130f5..aeb67f9 100644 --- a/board/src/position/pieces.rs +++ b/board/src/position/pieces.rs @@ -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) diff --git a/board/src/position/position.rs b/board/src/position/position.rs index a578b72..5dd3fb2 100644 --- a/board/src/position/position.rs +++ b/board/src/position/position.rs @@ -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) diff --git a/board/src/square.rs b/board/src/square.rs index 37ac6ea..aa82423 100644 --- a/board/src/square.rs +++ b/board/src/square.rs @@ -45,7 +45,7 @@ impl Square { }) } - pub fn from_algebraic_string(s: &str) -> Result { + pub fn from_algebraic_str(s: &str) -> Result { 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]