1
Fork 0
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:
Sylvestre Ledru 2023-09-23 09:34:04 +02:00 committed by GitHub
commit ba3f266b2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 12 deletions

View file

@ -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"] {