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

Implement tail -<number> (#2747)

And add obsolete_syntax test
This commit is contained in:
Smicry 2021-11-20 04:37:47 +08:00 committed by GitHub
parent 00769af807
commit fc851e036b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 313 additions and 75 deletions

View file

@ -358,6 +358,36 @@ fn test_positive_lines() {
.stdout_is("c\nd\ne\n");
}
/// Test for reading all but the first NUM lines: `tail -3`.
#[test]
fn test_obsolete_syntax_positive_lines() {
new_ucmd!()
.args(&["-3"])
.pipe_in("a\nb\nc\nd\ne\n")
.succeeds()
.stdout_is("c\nd\ne\n");
}
/// Test for reading all but the first NUM lines: `tail -n -10`.
#[test]
fn test_small_file() {
new_ucmd!()
.args(&["-n -10"])
.pipe_in("a\nb\nc\nd\ne\n")
.succeeds()
.stdout_is("a\nb\nc\nd\ne\n");
}
/// Test for reading all but the first NUM lines: `tail -10`.
#[test]
fn test_obsolete_syntax_small_file() {
new_ucmd!()
.args(&["-10"])
.pipe_in("a\nb\nc\nd\ne\n")
.succeeds()
.stdout_is("a\nb\nc\nd\ne\n");
}
/// Test for reading all lines, specified by `tail -n +0`.
#[test]
fn test_positive_zero_lines() {