mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
shuf: treat -e as a flag, not as a multi-value arg
This commit is contained in:
parent
f7821cd0d2
commit
a59924ece5
2 changed files with 97 additions and 17 deletions
|
@ -32,6 +32,28 @@ fn test_output_is_random_permutation() {
|
|||
assert_eq!(result_seq, input_seq, "Output is not a permutation");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_explicit_stdin_file() {
|
||||
let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let input = input_seq
|
||||
.iter()
|
||||
.map(ToString::to_string)
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n");
|
||||
|
||||
let result = new_ucmd!().arg("-").pipe_in(input.as_bytes()).succeeds();
|
||||
result.no_stderr();
|
||||
|
||||
let mut result_seq: Vec<i32> = result
|
||||
.stdout_str()
|
||||
.split('\n')
|
||||
.filter(|x| !x.is_empty())
|
||||
.map(|x| x.parse().unwrap())
|
||||
.collect();
|
||||
result_seq.sort_unstable();
|
||||
assert_eq!(result_seq, input_seq, "Output is not a permutation");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_zero_termination() {
|
||||
let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
|
@ -116,6 +138,36 @@ fn test_echo_multi() {
|
|||
assert_eq!(result_seq, ["a", "b", "c"], "Output is not a permutation");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_echo_postfix() {
|
||||
let result = new_ucmd!().arg("a").arg("b").arg("c").arg("-e").succeeds();
|
||||
result.no_stderr();
|
||||
|
||||
let mut result_seq: Vec<String> = result
|
||||
.stdout_str()
|
||||
.split('\n')
|
||||
.filter(|x| !x.is_empty())
|
||||
.map(|x| x.into())
|
||||
.collect();
|
||||
result_seq.sort_unstable();
|
||||
assert_eq!(result_seq, ["a", "b", "c"], "Output is not a permutation");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_echo_short_collapsed_zero() {
|
||||
let result = new_ucmd!().arg("-ez").arg("a").arg("b").arg("c").succeeds();
|
||||
result.no_stderr();
|
||||
|
||||
let mut result_seq: Vec<String> = result
|
||||
.stdout_str()
|
||||
.split('\0')
|
||||
.filter(|x| !x.is_empty())
|
||||
.map(|x| x.parse().unwrap())
|
||||
.collect();
|
||||
result_seq.sort_unstable();
|
||||
assert_eq!(result_seq, ["a", "b", "c"], "Output is not a permutation");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_head_count() {
|
||||
let repeat_limit = 5;
|
||||
|
@ -365,6 +417,22 @@ fn test_shuf_multiple_outputs() {
|
|||
.stderr_contains("cannot be used multiple times");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_shuf_two_input_files() {
|
||||
new_ucmd!()
|
||||
.args(&["file_a", "file_b"])
|
||||
.fails()
|
||||
.stderr_contains("unexpected argument 'file_b' found");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_shuf_three_input_files() {
|
||||
new_ucmd!()
|
||||
.args(&["file_a", "file_b", "file_c"])
|
||||
.fails()
|
||||
.stderr_contains("unexpected argument 'file_b' found");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_shuf_invalid_input_line_count() {
|
||||
new_ucmd!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue