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 <noreply@anthropic.com>
This commit is contained in:
funman300
2026-04-27 04:52:36 +00:00
parent 60e853f52b
commit 721c17e9f8
+26
View File
@@ -665,6 +665,32 @@ mod tests {
assert!(g.undo_stack_len() <= 64); 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 --- // --- Scoring ---
#[test] #[test]