mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
tests/cksum: add tests for the length argument
This commit is contained in:
parent
037073d852
commit
09ef150085
3 changed files with 38 additions and 0 deletions
|
@ -228,3 +228,37 @@ fn test_untagged_algorithm_stdin() {
|
||||||
.stdout_is_fixture(format!("untagged/{algo}_stdin.expected"));
|
.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");
|
||||||
|
}
|
||||||
|
|
2
tests/fixtures/cksum/supported_length.expected
vendored
Normal file
2
tests/fixtures/cksum/supported_length.expected
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
BLAKE2b-16 (lorem_ipsum.txt) = 7e2f
|
||||||
|
BLAKE2b-16 (alice_in_wonderland.txt) = a546
|
2
tests/fixtures/cksum/unsupported_length.expected
vendored
Normal file
2
tests/fixtures/cksum/unsupported_length.expected
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
cksum: invalid length: ‘15’
|
||||||
|
cksum: length is not a multiple of 8
|
Loading…
Add table
Add a link
Reference in a new issue