diff --git a/src/test.rs b/src/test.rs index ebc32f8..3fc5065 100644 --- a/src/test.rs +++ b/src/test.rs @@ -26,7 +26,7 @@ where } #[cfg(test)] -mod tests { +mod argparsing { use super::{make_dummy_files}; use crate::cli; use crate::cli::Command; @@ -103,6 +103,77 @@ mod tests { } } +#[cfg(test)] +mod byte_pretty_printing { + use crate::bytes::Bytes; + #[test] + fn bytes () { + assert_eq!( + &format!("{}", Bytes::new(234)), + "234.00 B" + ); + + assert_eq!( + &format!("{}", Bytes::new(999)), + "999.00 B" + ); + } + + #[test] + fn kilobytes () { + assert_eq!( + &format!("{}", Bytes::new(2234)), + "2.23 kB" + ); + + assert_eq!( + &format!("{}", Bytes::new(62500)), + "62.50 kB" + ); + + assert_eq!( + &format!("{}", Bytes::new(329990)), + "329.99 kB" + ); + } + + #[test] + fn megabytes () { + assert_eq!( + &format!("{}", Bytes::new(2750000)), + "2.75 MB" + ); + + assert_eq!( + &format!("{}", Bytes::new(55000000)), + "55.00 MB" + ); + + assert_eq!( + &format!("{}", Bytes::new(987654321)), + "987.65 MB" + ); + } + + #[test] + fn gigabytes () { + assert_eq!( + &format!("{}", Bytes::new(5280000000)), + "5.28 GB" + ); + + assert_eq!( + &format!("{}", Bytes::new(95200000000)), + "95.20 GB" + ); + + assert_eq!( + &format!("{}", Bytes::new(302000000000)), + "302.00 GB" + ); + } +} + // #[cfg(test)] // mod cli { // use super::*;