From b254503c8bf42e2d6123ed18d3065358f2d83c82 Mon Sep 17 00:00:00 2001 From: Ryoki Date: Mon, 7 Oct 2024 23:49:14 +0900 Subject: [PATCH] test: add unit test of human_readable_duration function to try it out --- src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.rs b/src/main.rs index c85984b..2bfce15 100644 --- a/src/main.rs +++ b/src/main.rs @@ -174,3 +174,15 @@ fn human_readable_duration(duration: Duration) -> String { format!("{}年", secs / (86400 * 365)) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_human_readable_duration() { + let duration = Duration::new(1, 0).unwrap(); + let result = human_readable_duration(duration); + assert_eq!(result, "1秒"); + } +}