mirror of
https://github.com/ouch-org/ouch.git
synced 2025-07-23 10:00:37 +00:00
Add tests for byte pretty-printing
This commit is contained in:
parent
1b9faab96a
commit
42b139f1a5
73
src/test.rs
73
src/test.rs
@ -26,7 +26,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod argparsing {
|
||||||
use super::{make_dummy_files};
|
use super::{make_dummy_files};
|
||||||
use crate::cli;
|
use crate::cli;
|
||||||
use crate::cli::Command;
|
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)]
|
// #[cfg(test)]
|
||||||
// mod cli {
|
// mod cli {
|
||||||
// use super::*;
|
// use super::*;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user