1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

cksum: split test function into two

This commit is contained in:
Daniel Hofstetter 2023-05-10 09:48:32 +02:00
parent 96a16cf272
commit ba6eb392aa

View file

@ -33,7 +33,7 @@ fn test_stdin() {
} }
#[test] #[test]
fn test_empty() { fn test_empty_file() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
at.touch("a"); at.touch("a");
@ -62,25 +62,26 @@ fn test_arg_overrides_stdin() {
} }
#[test] #[test]
fn test_invalid_file() { fn test_nonexisting_file() {
let ts = TestScenario::new(util_name!()); let file_name = "asdf";
let at = ts.fixtures.clone();
let folder_name = "asdf"; new_ucmd!()
.arg(file_name)
// First check when file doesn't exist
ts.ucmd()
.arg(folder_name)
.fails() .fails()
.no_stdout() .no_stdout()
.stderr_contains("cksum: asdf: No such file or directory"); .stderr_contains(format!("cksum: {file_name}: No such file or directory"));
}
// Then check when the file is of an invalid type #[test]
fn test_folder() {
let (at, mut ucmd) = at_and_ucmd!();
let folder_name = "a_folder";
at.mkdir(folder_name); at.mkdir(folder_name);
ts.ucmd()
.arg(folder_name) ucmd.arg(folder_name)
.succeeds() .succeeds()
.stdout_only("4294967295 0 asdf\n"); .stdout_only(format!("4294967295 0 {folder_name}\n"));
} }
// Make sure crc is correct for files larger than 32 bytes // Make sure crc is correct for files larger than 32 bytes