Skip to content

Commit d458dae

Browse files
chore: try to improve test coverage for principle variation
bench: 2517656
1 parent a8a895b commit d458dae

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

engine/src/principle_variation.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ impl PrincipleVariation {
3333
///
3434
/// Empty Result<> on success or an error if the underlying ArrayVec
3535
/// is full before trying to push.
36+
#[allow(clippy::panic)]
3637
pub(crate) fn push(&mut self, m: Move) {
37-
self.data.push(m);
38+
self.data.try_push(m).unwrap_or_else(|err| {
39+
panic!(
40+
"Error extending PV of size {} when adding {}\n {err}",
41+
self.data.len(),
42+
m
43+
);
44+
})
3845
}
3946

4047
/// Extend the current [PrincipleVariation] with the given move and another principle variation.
@@ -136,7 +143,7 @@ mod tests {
136143
}
137144

138145
#[test]
139-
#[should_panic]
146+
#[should_panic(expected = "Error extending PV")]
140147
fn extending_or_pushing_move_past_max_size_panics() {
141148
let (move1, move2) = make_moves();
142149
let mut pv = PrincipleVariation::new();

0 commit comments

Comments
 (0)