From eee220fbf02a7225bc89cf1c2bd08ada5a80634e Mon Sep 17 00:00:00 2001 From: funman300 Date: Mon, 27 Apr 2026 05:19:28 +0000 Subject: [PATCH] test(engine): add unit tests for format_duration in stats_plugin Co-Authored-By: Claude Sonnet 4.6 --- solitaire_engine/src/stats_plugin.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/solitaire_engine/src/stats_plugin.rs b/solitaire_engine/src/stats_plugin.rs index 88114a5..14451a7 100644 --- a/solitaire_engine/src/stats_plugin.rs +++ b/solitaire_engine/src/stats_plugin.rs @@ -474,4 +474,28 @@ mod tests { // At 5000 XP: 0 done, 0%, 1000 remaining. assert_eq!(xp_to_next_level_label(5_000, 10), "1000 XP (0%)"); } + + // ----------------------------------------------------------------------- + // format_duration + // ----------------------------------------------------------------------- + + #[test] + fn format_duration_zero_seconds() { + assert_eq!(format_duration(0), "0m 00s"); + } + + #[test] + fn format_duration_pads_seconds_to_two_digits() { + assert_eq!(format_duration(65), "1m 05s"); + } + + #[test] + fn format_duration_exactly_one_hour() { + assert_eq!(format_duration(3600), "60m 00s"); + } + + #[test] + fn format_duration_handles_sub_minute() { + assert_eq!(format_duration(59), "0m 59s"); + } }