[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
|
@ -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