mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #7698 from nyurik/assert-eq
chore: use `assert_eq!` and `assert_ne!` instead of `assert!`
This commit is contained in:
commit
0a99ab86e9
16 changed files with 71 additions and 60 deletions
|
@ -389,8 +389,14 @@ fn test_traverse_symlinks() {
|
|||
.arg("dir3/file")
|
||||
.succeeds();
|
||||
|
||||
assert!(at.plus("dir2/file").metadata().unwrap().gid() == first_group.as_raw());
|
||||
assert!(at.plus("dir3/file").metadata().unwrap().gid() == first_group.as_raw());
|
||||
assert_eq!(
|
||||
at.plus("dir2/file").metadata().unwrap().gid(),
|
||||
first_group.as_raw()
|
||||
);
|
||||
assert_eq!(
|
||||
at.plus("dir3/file").metadata().unwrap().gid(),
|
||||
first_group.as_raw()
|
||||
);
|
||||
|
||||
ucmd.arg("-R")
|
||||
.args(args)
|
||||
|
|
|
@ -38,11 +38,10 @@ fn run_single_test(test: &TestCase, at: &AtPath, mut ucmd: UCommand) {
|
|||
make_file(&at.plus_as_string(TEST_FILE), test.before);
|
||||
let perms = at.metadata(TEST_FILE).permissions().mode();
|
||||
|
||||
assert!(
|
||||
perms == test.before,
|
||||
assert_eq!(
|
||||
perms, test.before,
|
||||
"{}: expected: {:o} got: {perms:o}",
|
||||
"setting permissions on test files before actual test run failed",
|
||||
test.after,
|
||||
"setting permissions on test files before actual test run failed", test.after
|
||||
);
|
||||
|
||||
for arg in &test.args {
|
||||
|
@ -58,10 +57,10 @@ fn run_single_test(test: &TestCase, at: &AtPath, mut ucmd: UCommand) {
|
|||
}
|
||||
|
||||
let perms = at.metadata(TEST_FILE).permissions().mode();
|
||||
assert!(
|
||||
perms == test.after,
|
||||
assert_eq!(
|
||||
perms, test.after,
|
||||
"{ucmd}: expected: {:o} got: {perms:o}",
|
||||
test.after,
|
||||
test.after
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1045,8 +1045,9 @@ mod tests_split_iterator {
|
|||
);
|
||||
}
|
||||
Ok(actual) => {
|
||||
assert!(
|
||||
expected == actual.as_slice(),
|
||||
assert_eq!(
|
||||
expected,
|
||||
actual.as_slice(),
|
||||
"[{i}] After split({input:?}).unwrap()\nexpected: {expected:?}\n actual: {actual:?}\n"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -592,7 +592,7 @@ fn test_install_copy_then_compare_file_with_extra_mode() {
|
|||
file2_meta = at.metadata(file2);
|
||||
let after_install_sticky = FileTime::from_last_modification_time(&file2_meta);
|
||||
|
||||
assert!(before != after_install_sticky);
|
||||
assert_ne!(before, after_install_sticky);
|
||||
|
||||
sleep(std::time::Duration::from_millis(100));
|
||||
|
||||
|
@ -608,7 +608,7 @@ fn test_install_copy_then_compare_file_with_extra_mode() {
|
|||
file2_meta = at.metadata(file2);
|
||||
let after_install_sticky_again = FileTime::from_last_modification_time(&file2_meta);
|
||||
|
||||
assert!(after_install_sticky != after_install_sticky_again);
|
||||
assert_ne!(after_install_sticky, after_install_sticky_again);
|
||||
}
|
||||
|
||||
const STRIP_TARGET_FILE: &str = "helloworld_installed";
|
||||
|
|
|
@ -39,7 +39,7 @@ fn test_shred() {
|
|||
// File exists
|
||||
assert!(at.file_exists(file));
|
||||
// File is obfuscated
|
||||
assert!(at.read_bytes(file) != file_original_content.as_bytes());
|
||||
assert_ne!(at.read_bytes(file), file_original_content.as_bytes());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -336,7 +336,10 @@ fn test_filter_with_env_var_set() {
|
|||
|
||||
let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$");
|
||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||
assert!(env::var("FILE").unwrap_or_else(|_| "var was unset".to_owned()) == env_var_value);
|
||||
assert_eq!(
|
||||
env::var("FILE").unwrap_or_else(|_| "var was unset".to_owned()),
|
||||
env_var_value
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -279,7 +279,7 @@ fn test_touch_set_only_atime() {
|
|||
|
||||
let start_of_year = str_to_filetime("%Y%m%d%H%M", "201501010000");
|
||||
let (atime, mtime) = get_file_times(&at, file);
|
||||
assert!(atime != mtime);
|
||||
assert_ne!(atime, mtime);
|
||||
assert_eq!(atime.unix_seconds() - start_of_year.unix_seconds(), 45240);
|
||||
}
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ fn test_touch_set_only_mtime() {
|
|||
|
||||
let start_of_year = str_to_filetime("%Y%m%d%H%M", "201501010000");
|
||||
let (atime, mtime) = get_file_times(&at, file);
|
||||
assert!(atime != mtime);
|
||||
assert_ne!(atime, mtime);
|
||||
assert_eq!(mtime.unix_seconds() - start_of_year.unix_seconds(), 45240);
|
||||
}
|
||||
}
|
||||
|
@ -805,7 +805,7 @@ fn test_touch_changes_time_of_file_in_stdout() {
|
|||
.no_stderr();
|
||||
|
||||
let (_, mtime_after) = get_file_times(&at, file);
|
||||
assert!(mtime_after != mtime);
|
||||
assert_ne!(mtime_after, mtime);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -23,7 +23,7 @@ fn test_increase_file_size() {
|
|||
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
assert_eq!(expected, actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -35,7 +35,7 @@ fn test_increase_file_size_kb() {
|
|||
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
assert_eq!(expected, actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -57,7 +57,7 @@ fn test_reference() {
|
|||
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
assert_eq!(expected, actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -69,7 +69,7 @@ fn test_decrease_file_size() {
|
|||
ucmd.args(&["--size=-4", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
assert_eq!(expected, actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -81,7 +81,7 @@ fn test_space_in_size() {
|
|||
ucmd.args(&["--size", " 4", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
assert_eq!(expected, actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -110,7 +110,7 @@ fn test_at_most_shrinks() {
|
|||
ucmd.args(&["--size", "<4", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
assert_eq!(expected, actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -122,7 +122,7 @@ fn test_at_most_no_change() {
|
|||
ucmd.args(&["--size", "<40", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
assert_eq!(expected, actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -134,7 +134,7 @@ fn test_at_least_grows() {
|
|||
ucmd.args(&["--size", ">15", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
assert_eq!(expected, actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -146,7 +146,7 @@ fn test_at_least_no_change() {
|
|||
ucmd.args(&["--size", ">4", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
assert_eq!(expected, actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -158,7 +158,7 @@ fn test_round_down() {
|
|||
ucmd.args(&["--size", "/4", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
assert_eq!(expected, actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -170,7 +170,7 @@ fn test_round_up() {
|
|||
ucmd.args(&["--size", "%4", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
assert_eq!(expected, actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -184,7 +184,7 @@ fn test_size_and_reference() {
|
|||
.succeeds();
|
||||
file2.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file2.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
assert_eq!(expected, actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue