1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

tests/cksum: add tests for the length argument

This commit is contained in:
Vardhan Patil 2023-12-30 16:01:22 +05:30
parent 037073d852
commit 09ef150085
3 changed files with 38 additions and 0 deletions

View file

@ -228,3 +228,37 @@ fn test_untagged_algorithm_stdin() {
.stdout_is_fixture(format!("untagged/{algo}_stdin.expected"));
}
}
#[test]
fn test_length_with_wrong_algorithm() {
new_ucmd!()
.arg("--length=16")
.arg("--algorithm=md5")
.arg("lorem_ipsum.txt")
.fails()
.no_stdout()
.stderr_contains("cksum: --length is only supported with --algorithm=blake2b")
.code_is(1);
}
#[test]
fn test_length_not_supported() {
new_ucmd!()
.arg("--length=15")
.arg("lorem_ipsum.txt")
.fails()
.no_stdout()
.stderr_is_fixture("unsupported_length.expected")
.code_is(1);
}
#[test]
fn test_length() {
new_ucmd!()
.arg("--length=16")
.arg("--algorithm=blake2b")
.arg("lorem_ipsum.txt")
.arg("alice_in_wonderland.txt")
.succeeds()
.stdout_is_fixture("supported_length.expected");
}

View file

@ -0,0 +1,2 @@
BLAKE2b-16 (lorem_ipsum.txt) = 7e2f
BLAKE2b-16 (alice_in_wonderland.txt) = a546

View file

@ -0,0 +1,2 @@
cksum: invalid length: 15
cksum: length is not a multiple of 8