Skip to content

Commit

Permalink
Merge pull request #4854 from cakebaker/cksum_split_test_function
Browse files Browse the repository at this point in the history
cksum: split test function into two
  • Loading branch information
sylvestre authored May 10, 2023
2 parents 96a16cf + ba6eb39 commit af58532
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions tests/by-util/test_cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn test_stdin() {
}

#[test]
fn test_empty() {
fn test_empty_file() {
let (at, mut ucmd) = at_and_ucmd!();

at.touch("a");
Expand Down Expand Up @@ -62,25 +62,26 @@ fn test_arg_overrides_stdin() {
}

#[test]
fn test_invalid_file() {
let ts = TestScenario::new(util_name!());
let at = ts.fixtures.clone();
fn test_nonexisting_file() {
let file_name = "asdf";

let folder_name = "asdf";

// First check when file doesn't exist
ts.ucmd()
.arg(folder_name)
new_ucmd!()
.arg(file_name)
.fails()
.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);
ts.ucmd()
.arg(folder_name)

ucmd.arg(folder_name)
.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
Expand Down

0 comments on commit af58532

Please sign in to comment.