From e64128fbf1cb86b3ee62de33221ee1188cd657f7 Mon Sep 17 00:00:00 2001 From: c0repwn3r Date: Sun, 12 Feb 2023 19:09:27 -0500 Subject: [PATCH] full codecov --- .gitignore | 1 + src/board.rs | 14 ++++++++++++++ src/main.rs | 3 +++ src/piece.rs | 12 ++++++++++++ 4 files changed, 30 insertions(+) diff --git a/.gitignore b/.gitignore index ea8c4bf..04dc301 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +tarpaulin-report.html \ No newline at end of file diff --git a/src/board.rs b/src/board.rs index e3596ea..57e7504 100644 --- a/src/board.rs +++ b/src/board.rs @@ -121,6 +121,20 @@ mod tests { use crate::board::{Boardfield, BoardfieldOps}; use crate::piece::{PieceColor, PieceType}; + #[test] + #[should_panic] + fn get_out_of_bounds() { + let field = Boardfield::startpos(); + field.get_pos(64); + } + + #[test] + #[should_panic] + fn set_out_of_bounds() { + let mut field = Boardfield::startpos(); + field.set_pos(64, 0u8); + } + #[test] fn bitfield_board() { let field = Boardfield::startpos(); diff --git a/src/main.rs b/src/main.rs index 1660215..1013d4c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,9 @@ use std::sync::{Arc}; use crate::uci::{uci_handle_command, UCIState}; use spin::Mutex; +#[cfg(not(tarpaulin_include))] // UCI parse engine is not tested with tarpaulin, outer test harness is planned pub mod uci; + pub mod board; pub mod piece; @@ -12,6 +14,7 @@ pub const ENGINE_NAME: &str = "Bamboo"; pub const ENGINE_VERSION: &str = "1.0"; pub const ENGINE_AUTHOR: &str = "c0repwn3r"; +#[cfg(not(tarpaulin_include))] fn main() { println!("{} {} by {}", ENGINE_NAME, ENGINE_VERSION, ENGINE_AUTHOR); diff --git a/src/piece.rs b/src/piece.rs index 4500e66..95829b9 100644 --- a/src/piece.rs +++ b/src/piece.rs @@ -63,20 +63,32 @@ mod piece_tests { fn piece_color_checks() { assert!(!Piece::is_white(PieceType::Pawn as u8 | PieceColor::Black as u8)); assert!(Piece::is_white(PieceType::Pawn as u8 | PieceColor::White as u8)); + assert!(Piece::is_black(PieceType::Pawn as u8 | PieceColor::Black as u8)); + assert!(!Piece::is_black(PieceType::Pawn as u8 | PieceColor::White as u8)); assert!(!Piece::is_white(PieceType::Knight as u8 | PieceColor::Black as u8)); assert!(Piece::is_white(PieceType::Knight as u8 | PieceColor::White as u8)); + assert!(Piece::is_black(PieceType::Knight as u8 | PieceColor::Black as u8)); + assert!(!Piece::is_black(PieceType::Knight as u8 | PieceColor::White as u8)); assert!(!Piece::is_white(PieceType::Bishop as u8 | PieceColor::Black as u8)); assert!(Piece::is_white(PieceType::Bishop as u8 | PieceColor::White as u8)); + assert!(Piece::is_black(PieceType::Bishop as u8 | PieceColor::Black as u8)); + assert!(!Piece::is_black(PieceType::Bishop as u8 | PieceColor::White as u8)); assert!(!Piece::is_white(PieceType::Rook as u8 | PieceColor::Black as u8)); assert!(Piece::is_white(PieceType::Rook as u8 | PieceColor::White as u8)); + assert!(Piece::is_black(PieceType::Rook as u8 | PieceColor::Black as u8)); + assert!(!Piece::is_black(PieceType::Rook as u8 | PieceColor::White as u8)); assert!(!Piece::is_white(PieceType::Queen as u8 | PieceColor::Black as u8)); assert!(Piece::is_white(PieceType::Queen as u8 | PieceColor::White as u8)); + assert!(Piece::is_black(PieceType::Queen as u8 | PieceColor::Black as u8)); + assert!(!Piece::is_black(PieceType::Queen as u8 | PieceColor::White as u8)); assert!(!Piece::is_white(PieceType::King as u8 | PieceColor::Black as u8)); assert!(Piece::is_white(PieceType::King as u8 | PieceColor::White as u8)); + assert!(Piece::is_black(PieceType::King as u8 | PieceColor::Black as u8)); + assert!(!Piece::is_black(PieceType::King as u8 | PieceColor::White as u8)); } } \ No newline at end of file