ms_rs/lib.rs
1pub mod parse;
2pub mod format;
3
4pub use parse::parse;
5pub use format::format;
6
7// Some basic tests for this library.
8// ToDo: Add more tests here. I needed to craft those quickly.
9#[cfg(test)]
10mod tests {
11 use super::*;
12
13 #[test]
14 fn test_parse() {
15 assert_eq!(parse("2 days").unwrap(), 172_800_000);
16 assert_eq!(parse("1 minute").unwrap(), 60_000);
17 assert!(parse("unknown").is_err());
18 }
19
20 #[test]
21 fn test_format() {
22 assert_eq!(format(172_800_000), "2 days");
23 assert_eq!(format(60_000), "1 minute");
24 assert_eq!(format(999), "999 ms");
25 }
26}
27