mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-15 11:36:16 +00:00
Merge pull request #5285 from cakebaker/nl_multiple_files
nl: make line number and --join-blank-lines work over multiple files
This commit is contained in:
commit
ba3f266b2c
2 changed files with 64 additions and 12 deletions
|
@ -284,6 +284,31 @@ fn test_join_blank_lines() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_join_blank_lines_multiple_files() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
at.write("a.txt", "\n\n");
|
||||
at.write("b.txt", "\n\n");
|
||||
at.write("c.txt", "\n\n");
|
||||
|
||||
for arg in ["-l3", "--join-blank-lines=3"] {
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&[arg, "--body-numbering=a", "a.txt", "b.txt", "c.txt"])
|
||||
.succeeds()
|
||||
.stdout_is(concat!(
|
||||
" \n",
|
||||
" \n",
|
||||
" 1\t\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" 2\t\n",
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_join_blank_lines_zero() {
|
||||
for arg in ["-l0", "--join-blank-lines=0"] {
|
||||
|
@ -311,6 +336,19 @@ fn test_default_body_numbering() {
|
|||
.stdout_is(" 1\ta\n \n 2\tb\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_default_body_numbering_multiple_files() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.write("a.txt", "a");
|
||||
at.write("b.txt", "b");
|
||||
at.write("c.txt", "c");
|
||||
|
||||
ucmd.args(&["a.txt", "b.txt", "c.txt"])
|
||||
.succeeds()
|
||||
.stdout_is(" 1\ta\n 2\tb\n 3\tc\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_body_numbering_all_lines_without_delimiter() {
|
||||
for arg in ["-ba", "--body-numbering=a"] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue