add test for short size render

This commit is contained in:
Abin Simon 2020-04-09 16:45:58 +05:30
parent 20a6a09695
commit bef4ad22a6

View file

@ -141,6 +141,7 @@ impl Size {
#[cfg(test)]
mod test {
use super::Size;
use crate::color::{Colors, Theme};
use crate::flags::{Flags, SizeFlag};
#[test]
@ -218,4 +219,15 @@ mod test {
assert_eq!(size.value_string(&flags).as_str(), "42");
assert_eq!(size.unit_string(&flags).as_str(), "KB");
}
#[test]
fn render_short_nospaces() {
let size = Size::new(42 * 1024); // 42 kilobytes
let mut flags = Flags::default();
flags.size = SizeFlag::Short;
let colors = Colors::new(Theme::NoColor);
assert_eq!(size.render(&colors, &flags, 2).to_string(), "42K");
assert_eq!(size.render(&colors, &flags, 3).to_string(), " 42K");
}
}