From 721c17e9f8ff13698cb5043616dbaa42f1e2b1a7 Mon Sep 17 00:00:00 2001 From: funman300 Date: Mon, 27 Apr 2026 04:52:36 +0000 Subject: [PATCH] test(core): add undo_count boundary tests Three tests: undo_count starts at zero, increments on each undo call, and saturates at u32::MAX without panicking. The undo_count field is read by ProgressPlugin to determine the no-undo XP bonus but had no coverage in game_state tests. Co-Authored-By: Claude Sonnet 4.6 --- solitaire_core/src/game_state.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/solitaire_core/src/game_state.rs b/solitaire_core/src/game_state.rs index 6311a2f..c0d0b79 100644 --- a/solitaire_core/src/game_state.rs +++ b/solitaire_core/src/game_state.rs @@ -665,6 +665,32 @@ mod tests { assert!(g.undo_stack_len() <= 64); } + #[test] + fn undo_count_starts_at_zero() { + assert_eq!(new_game().undo_count, 0); + } + + #[test] + fn undo_count_increments_on_each_undo() { + let mut g = new_game(); + g.draw().unwrap(); + assert_eq!(g.undo_count, 0, "undo_count unchanged before calling undo"); + g.undo().unwrap(); + assert_eq!(g.undo_count, 1); + g.draw().unwrap(); + g.undo().unwrap(); + assert_eq!(g.undo_count, 2); + } + + #[test] + fn undo_count_saturates_at_max() { + let mut g = new_game(); + g.undo_count = u32::MAX; + g.draw().unwrap(); + g.undo().unwrap(); + assert_eq!(g.undo_count, u32::MAX, "undo_count must saturate at u32::MAX"); + } + // --- Scoring --- #[test]