1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

fix tr with any flag with more than 2 operands (#5952)

* fix tr

* add tests

* fix clippy

* fix clippy2

* do suggestions

* do suggestions

* remove mut

* tr: move var to block & remove its type

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
This commit is contained in:
BaherSalama 2024-02-13 16:30:15 +02:00 committed by GitHub
parent 826cdbe3dc
commit 5603305e75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 7 deletions

View file

@ -1155,3 +1155,27 @@ fn test_delete_flag_takes_only_one_operand() {
"extra operand 'p'\nOnly one string may be given when deleting without squeezing repeats.",
);
}
#[test]
fn test_truncate_flag_fails_with_more_than_two_operand() {
new_ucmd!()
.args(&["-t", "a", "b", "c"])
.fails()
.stderr_contains("extra operand 'c'");
}
#[test]
fn test_squeeze_flag_fails_with_more_than_two_operand() {
new_ucmd!()
.args(&["-s", "a", "b", "c"])
.fails()
.stderr_contains("extra operand 'c'");
}
#[test]
fn test_complement_flag_fails_with_more_than_two_operand() {
new_ucmd!()
.args(&["-c", "a", "b", "c"])
.fails()
.stderr_contains("extra operand 'c'");
}