cksum: allow repeated flags and arguments

This commit is contained in:
Ben Wiederhake 2024-03-02 03:05:46 +01:00
parent 32b5591736
commit edb1eb0a76
2 changed files with 27 additions and 0 deletions

View file

@ -365,6 +365,7 @@ pub fn uu_app() -> Command {
.about(ABOUT)
.override_usage(format_usage(USAGE))
.infer_long_args(true)
.args_override_self(true)
.arg(
Arg::new(options::FILE)
.hide(true)

View file

@ -128,6 +128,18 @@ fn test_stdin_larger_than_128_bytes() {
assert_eq!(bytes_cnt, 2058);
}
#[test]
fn test_repeated_flags() {
new_ucmd!()
.arg("-a")
.arg("sha1")
.arg("--algo=sha256")
.arg("-a=md5")
.arg("lorem_ipsum.txt")
.succeeds()
.stdout_is_fixture("md5_single_file.expected");
}
#[test]
fn test_algorithm_single_file() {
for algo in ALGOS {
@ -291,6 +303,20 @@ fn test_length_is_zero() {
.stdout_is_fixture("length_is_zero.expected");
}
#[test]
fn test_length_repeated() {
new_ucmd!()
.arg("--length=10")
.arg("--length=123456")
.arg("--length=0")
.arg("--algorithm=blake2b")
.arg("lorem_ipsum.txt")
.arg("alice_in_wonderland.txt")
.succeeds()
.no_stderr()
.stdout_is_fixture("length_is_zero.expected");
}
#[test]
fn test_raw_single_file() {
for algo in ALGOS {