Skip to content

Commit

Permalink
Merge pull request #5786 from samueltardieu/style-fixes
Browse files Browse the repository at this point in the history
uucore: fix style in tests
  • Loading branch information
sylvestre authored Jan 5, 2024
2 parents b61e859 + e566828 commit e341759
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/uucore/src/lib/features/backup_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ mod tests {
let target = Path::new("data.txt");
let suffix = String::from(".bak");

assert!(source_is_target_backup(&source, &target, &suffix));
assert!(source_is_target_backup(source, target, &suffix));
}

#[test]
Expand All @@ -671,7 +671,7 @@ mod tests {
let target = Path::new("backup.txt");
let suffix = String::from(".bak");

assert!(!source_is_target_backup(&source, &target, &suffix));
assert!(!source_is_target_backup(source, target, &suffix));
}

#[test]
Expand All @@ -680,6 +680,6 @@ mod tests {
let target = Path::new("example");
let suffix = String::from("~");

assert!(source_is_target_backup(&source, &target, &suffix));
assert!(source_is_target_backup(source, target, &suffix));
}
}
8 changes: 4 additions & 4 deletions src/uucore/src/lib/features/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ mod tests {
let path1 = temp_file.path();
let path2 = temp_file.path();

assert!(are_hardlinks_to_same_file(&path1, &path2));
assert!(are_hardlinks_to_same_file(path1, path2));
}

#[cfg(unix)]
Expand All @@ -893,7 +893,7 @@ mod tests {
let path1 = temp_file1.path();
let path2 = temp_file2.path();

assert!(!are_hardlinks_to_same_file(&path1, &path2));
assert!(!are_hardlinks_to_same_file(path1, path2));
}

#[cfg(unix)]
Expand All @@ -904,9 +904,9 @@ mod tests {
let path1 = temp_file.path();

let path2 = temp_file.path().with_extension("hardlink");
fs::hard_link(&path1, &path2).unwrap();
fs::hard_link(path1, &path2).unwrap();

assert!(are_hardlinks_to_same_file(&path1, &path2));
assert!(are_hardlinks_to_same_file(path1, &path2));
}

#[cfg(unix)]
Expand Down
16 changes: 8 additions & 8 deletions src/uucore/src/lib/parser/parse_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,23 +424,23 @@ mod tests {

for &(c, exp) in &suffixes {
let s = format!("2{c}B"); // KB
assert_eq!(Ok((2 * (1000_u128).pow(exp)) as u128), parse_size_u128(&s));
assert_eq!(Ok(2 * (1000_u128).pow(exp)), parse_size_u128(&s));
let s = format!("2{c}"); // K
assert_eq!(Ok((2 * (1024_u128).pow(exp)) as u128), parse_size_u128(&s));
assert_eq!(Ok(2 * (1024_u128).pow(exp)), parse_size_u128(&s));
let s = format!("2{c}iB"); // KiB
assert_eq!(Ok((2 * (1024_u128).pow(exp)) as u128), parse_size_u128(&s));
assert_eq!(Ok(2 * (1024_u128).pow(exp)), parse_size_u128(&s));
let s = format!("2{}iB", c.to_lowercase()); // kiB
assert_eq!(Ok((2 * (1024_u128).pow(exp)) as u128), parse_size_u128(&s));
assert_eq!(Ok(2 * (1024_u128).pow(exp)), parse_size_u128(&s));

// suffix only
let s = format!("{c}B"); // KB
assert_eq!(Ok(((1000_u128).pow(exp)) as u128), parse_size_u128(&s));
assert_eq!(Ok((1000_u128).pow(exp)), parse_size_u128(&s));
let s = format!("{c}"); // K
assert_eq!(Ok(((1024_u128).pow(exp)) as u128), parse_size_u128(&s));
assert_eq!(Ok((1024_u128).pow(exp)), parse_size_u128(&s));
let s = format!("{c}iB"); // KiB
assert_eq!(Ok(((1024_u128).pow(exp)) as u128), parse_size_u128(&s));
assert_eq!(Ok((1024_u128).pow(exp)), parse_size_u128(&s));
let s = format!("{}iB", c.to_lowercase()); // kiB
assert_eq!(Ok(((1024_u128).pow(exp)) as u128), parse_size_u128(&s));
assert_eq!(Ok((1024_u128).pow(exp)), parse_size_u128(&s));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/uucore/src/lib/parser/shortcut_value_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ mod tests {
let parser = ShortcutValueParser::new(["abcd"]);
let cmd = Command::new("cmd");

let result = parser.parse_ref(&cmd, None, OsStr::from_bytes(&[0xc3 as u8, 0x28 as u8]));
let result = parser.parse_ref(&cmd, None, OsStr::from_bytes(&[0xc3, 0x28]));
assert_eq!(ErrorKind::InvalidUtf8, result.unwrap_err().kind());
}
}

0 comments on commit e341759

Please sign in to comment.