mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
tests: cat minor refactor for dryness
This commit is contained in:
parent
df618d60ea
commit
be22cf2e20
1 changed files with 11 additions and 14 deletions
|
@ -5,10 +5,7 @@ static UTIL_NAME: &'static str = "cat";
|
|||
#[test]
|
||||
fn test_output_multi_files_print_all_chars() {
|
||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.arg("alpha.txt")
|
||||
.arg("256.txt")
|
||||
.arg("-A")
|
||||
.arg("-n")
|
||||
ucmd.args(&["alpha.txt", "256.txt", "-A", "-n"])
|
||||
.succeeds()
|
||||
.stdout_only(" 1\tabcde$\n 2\tfghij$\n 3\tklmno$\n 4\tpqrst$\n \
|
||||
5\tuvwxyz$\n 6\t^@^A^B^C^D^E^F^G^H^I$\n \
|
||||
|
@ -38,7 +35,7 @@ fn test_stdin_show_nonprinting() {
|
|||
fn test_stdin_show_tabs() {
|
||||
for same_param in vec!["-T", "--show-tabs"] {
|
||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.args(&vec![same_param])
|
||||
ucmd.args(&[same_param])
|
||||
.pipe_in("\t\0\n")
|
||||
.succeeds()
|
||||
.stdout_only("^I\0");
|
||||
|
@ -50,7 +47,7 @@ fn test_stdin_show_tabs() {
|
|||
fn test_stdin_show_ends() {
|
||||
for same_param in vec!["-E", "--show-ends"] {
|
||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.args(&vec![same_param,"-"])
|
||||
ucmd.args(&[same_param,"-"])
|
||||
.pipe_in("\t\0\n")
|
||||
.succeeds()
|
||||
.stdout_only("\t\0$");
|
||||
|
@ -61,7 +58,7 @@ fn test_stdin_show_ends() {
|
|||
fn test_stdin_show_all() {
|
||||
for same_param in vec!["-A", "--show-all"] {
|
||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.args(&vec![same_param])
|
||||
ucmd.args(&[same_param])
|
||||
.pipe_in("\t\0\n")
|
||||
.succeeds()
|
||||
.stdout_only("^I^@$");
|
||||
|
@ -71,7 +68,7 @@ fn test_stdin_show_all() {
|
|||
#[test]
|
||||
fn test_stdin_nonprinting_and_endofline() {
|
||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.args(&vec!["-e"])
|
||||
ucmd.args(&["-e"])
|
||||
.pipe_in("\t\0\n")
|
||||
.succeeds()
|
||||
.stdout_only("\t^@$\n");
|
||||
|
@ -80,7 +77,7 @@ fn test_stdin_nonprinting_and_endofline() {
|
|||
#[test]
|
||||
fn test_stdin_nonprinting_and_tabs() {
|
||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.args(&vec!["-t"])
|
||||
ucmd.args(&["-t"])
|
||||
.pipe_in("\t\0\n")
|
||||
.succeeds()
|
||||
.stdout_only("^I^@\n");
|
||||
|
@ -91,7 +88,7 @@ fn test_stdin_squeeze_blank() {
|
|||
for same_param in vec!["-s", "--squeeze-blank"] {
|
||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.arg(same_param)
|
||||
.pipe_in("\n\na\n\n\n\n\nb\n\n\n".as_bytes())
|
||||
.pipe_in("\n\na\n\n\n\n\nb\n\n\n")
|
||||
.succeeds()
|
||||
.stdout_only("\na\n\nb\n\n");
|
||||
}
|
||||
|
@ -103,7 +100,7 @@ fn test_stdin_number_non_blank() {
|
|||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.arg(same_param)
|
||||
.arg("-")
|
||||
.pipe_in("\na\nb\n\n\nc".as_bytes())
|
||||
.pipe_in("\na\nb\n\n\nc")
|
||||
.succeeds()
|
||||
.stdout_only("\n 1\ta\n 2\tb\n\n\n 3\tc");
|
||||
}
|
||||
|
@ -113,8 +110,8 @@ fn test_stdin_number_non_blank() {
|
|||
fn test_non_blank_overrides_number() {
|
||||
for same_param in vec!["-b", "--number-nonblank"] {
|
||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.args(&vec![same_param, "-"])
|
||||
.pipe_in("\na\nb\n\n\nc".as_bytes())
|
||||
ucmd.args(&[same_param, "-"])
|
||||
.pipe_in("\na\nb\n\n\nc")
|
||||
.succeeds()
|
||||
.stdout_only("\n 1\ta\n 2\tb\n\n\n 3\tc");
|
||||
}
|
||||
|
@ -124,7 +121,7 @@ fn test_non_blank_overrides_number() {
|
|||
fn test_squeeze_blank_before_numbering() {
|
||||
for same_param in vec!["-s", "--squeeze-blank"] {
|
||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.args(&vec![same_param, "-n", "-"])
|
||||
ucmd.args(&[same_param, "-n", "-"])
|
||||
.pipe_in("a\n\n\nb")
|
||||
.succeeds()
|
||||
.stdout_only(" 1\ta\n 2\t\n 3\tb");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue