mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
parent
7d14961235
commit
56e8dda606
2 changed files with 34 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
|||
// spell-checker:ignore udev pcent
|
||||
// spell-checker:ignore udev pcent iuse itotal iused ipcent
|
||||
use crate::common::util::*;
|
||||
|
||||
#[test]
|
||||
|
@ -179,6 +179,36 @@ fn test_use_percentage() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iuse_percentage() {
|
||||
let output = new_ucmd!()
|
||||
.args(&["--total", "--output=itotal,iused,ipcent"])
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
|
||||
// Skip the header line.
|
||||
let lines: Vec<&str> = output.lines().skip(1).collect();
|
||||
|
||||
for line in lines {
|
||||
let mut iter = line.split_whitespace();
|
||||
let reported_inodes = iter.next().unwrap().parse::<f64>().unwrap();
|
||||
let reported_iused = iter.next().unwrap().parse::<f64>().unwrap();
|
||||
let reported_percentage = iter.next().unwrap();
|
||||
|
||||
if reported_percentage == "-" {
|
||||
assert_eq!(0.0, reported_inodes);
|
||||
assert_eq!(0.0, reported_iused);
|
||||
} else {
|
||||
let reported_percentage = reported_percentage[..reported_percentage.len() - 1]
|
||||
.parse::<u8>()
|
||||
.unwrap();
|
||||
let computed_percentage = (100.0 * (reported_iused / reported_inodes)).ceil() as u8;
|
||||
|
||||
assert_eq!(computed_percentage, reported_percentage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_block_size_1024() {
|
||||
fn get_header(block_size: u64) -> String {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue