1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Clippy fixes in multiple crates

This commit is contained in:
Jeffrey Finkelstein 2022-03-10 22:31:21 -05:00
parent 2e8945ba7f
commit b42168e9dc
5 changed files with 24 additions and 31 deletions

View file

@ -807,15 +807,16 @@ mod tests {
#[test] #[test]
fn test_parse_bytes_with_opt_multiplier() { fn test_parse_bytes_with_opt_multiplier() {
assert_eq!(parse_bytes_with_opt_multiplier("123").unwrap(), 123); assert_eq!(parse_bytes_with_opt_multiplier("123").unwrap(), 123);
assert_eq!(parse_bytes_with_opt_multiplier("123c").unwrap(), 123 * 1); assert_eq!(parse_bytes_with_opt_multiplier("123c").unwrap(), 123); // 123 * 1
assert_eq!(parse_bytes_with_opt_multiplier("123w").unwrap(), 123 * 2); assert_eq!(parse_bytes_with_opt_multiplier("123w").unwrap(), 123 * 2);
assert_eq!(parse_bytes_with_opt_multiplier("123b").unwrap(), 123 * 512); assert_eq!(parse_bytes_with_opt_multiplier("123b").unwrap(), 123 * 512);
assert_eq!(parse_bytes_with_opt_multiplier("123x3").unwrap(), 123 * 3); assert_eq!(parse_bytes_with_opt_multiplier("123x3").unwrap(), 123 * 3);
assert_eq!(parse_bytes_with_opt_multiplier("123k").unwrap(), 123 * 1024); assert_eq!(parse_bytes_with_opt_multiplier("123k").unwrap(), 123 * 1024);
assert_eq!(parse_bytes_with_opt_multiplier("1x2x3").unwrap(), 1 * 2 * 3); assert_eq!(parse_bytes_with_opt_multiplier("1x2x3").unwrap(), 6); // 1 * 2 * 3
assert_eq!( assert_eq!(
parse_bytes_with_opt_multiplier("1wx2cx3w").unwrap(), parse_bytes_with_opt_multiplier("1wx2cx3w").unwrap(),
(1 * 2) * (2 * 1) * (3 * 2) 2 * 2 * (3 * 2) // (1 * 2) * (2 * 1) * (3 * 2)
); );
assert!(parse_bytes_with_opt_multiplier("123asdf").is_err()); assert!(parse_bytes_with_opt_multiplier("123asdf").is_err());
} }

View file

@ -577,7 +577,7 @@ mod tests {
inodes_usage: Some(0.2), inodes_usage: Some(0.2),
}; };
assert_eq!( assert_eq!(
DisplayRow::new(row, &options).to_string(), DisplayRow::new(&row, &options).to_string(),
"my_device 100 25 75 26% my_mount " "my_device 100 25 75 26% my_mount "
); );
} }

View file

@ -479,7 +479,7 @@ mod tests {
fn num(n: usize) -> Number { fn num(n: usize) -> Number {
let mut number = Number::DynamicWidth(DynamicWidthNumber::new(16)); let mut number = Number::DynamicWidth(DynamicWidthNumber::new(16));
for _ in 0..n { for _ in 0..n {
number.increment().unwrap() number.increment().unwrap();
} }
number number
} }

View file

@ -338,25 +338,21 @@ fn test_dictionary_order() {
#[test] #[test]
fn test_dictionary_order2() { fn test_dictionary_order2() {
for non_dictionary_order2_param in &["-d"] {
new_ucmd!() new_ucmd!()
.pipe_in("a👦🏻aa\tb\naaaa\tb") // spell-checker:disable-line .pipe_in("a👦🏻aa\tb\naaaa\tb") // spell-checker:disable-line
.arg(non_dictionary_order2_param) // spell-checker:disable-line .arg("-d")
.succeeds() .succeeds()
.stdout_only("a👦🏻aa\tb\naaaa\tb\n"); // spell-checker:disable-line .stdout_only("a👦🏻aa\tb\naaaa\tb\n"); // spell-checker:disable-line
} }
}
#[test] #[test]
fn test_non_printing_chars() { fn test_non_printing_chars() {
for non_printing_chars_param in &["-i"] {
new_ucmd!() new_ucmd!()
.pipe_in("a👦🏻aa\naaaa") // spell-checker:disable-line .pipe_in("a👦🏻aa\naaaa") // spell-checker:disable-line
.arg(non_printing_chars_param) // spell-checker:disable-line .arg("-i")
.succeeds() .succeeds()
.stdout_only("a👦🏻aa\naaaa\n"); // spell-checker:disable-line .stdout_only("a👦🏻aa\naaaa\n"); // spell-checker:disable-line
} }
}
#[test] #[test]
fn test_exponents_positive_general_fixed() { fn test_exponents_positive_general_fixed() {
@ -486,15 +482,13 @@ fn test_default_unsorted_ints2() {
#[test] #[test]
fn test_numeric_unique_ints2() { fn test_numeric_unique_ints2() {
for numeric_unique_sort_param in &["-nu"] {
let input = "9\n9\n8\n1\n"; let input = "9\n9\n8\n1\n";
new_ucmd!() new_ucmd!()
.arg(numeric_unique_sort_param) .arg("-nu")
.pipe_in(input) .pipe_in(input)
.succeeds() .succeeds()
.stdout_only("1\n8\n9\n"); .stdout_only("1\n8\n9\n");
} }
}
#[test] #[test]
fn test_keys_open_ended() { fn test_keys_open_ended() {

View file

@ -69,10 +69,8 @@ fn test_login() {
#[test] #[test]
fn test_m() { fn test_m() {
let ts = TestScenario::new(util_name!()); let ts = TestScenario::new(util_name!());
for opt in &["-m"] { let expected_stdout = unwrap_or_return!(expected_result(&ts, &["-m"])).stdout_move_str();
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str(); ts.ucmd().arg("-m").succeeds().stdout_is(expected_stdout);
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
}
} }
#[cfg(unix)] #[cfg(unix)]