mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
split: handle no final newline with --line-bytes
Fix a panic due to out-of-bounds indexing when using `split --line-bytes` with an input that had no trailing newline.
This commit is contained in:
parent
1d17400b80
commit
95f58fbf3c
2 changed files with 17 additions and 1 deletions
|
@ -618,3 +618,19 @@ fn test_line_bytes() {
|
|||
assert_eq!(at.read("xac"), "cccc\ndd\n");
|
||||
assert_eq!(at.read("xad"), "ee\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_line_bytes_no_final_newline() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.args(&["-C", "2"])
|
||||
.pipe_in("1\n2222\n3\n4")
|
||||
.succeeds()
|
||||
.no_stdout()
|
||||
.no_stderr();
|
||||
assert_eq!(at.read("xaa"), "1\n");
|
||||
assert_eq!(at.read("xab"), "22");
|
||||
assert_eq!(at.read("xac"), "22");
|
||||
assert_eq!(at.read("xad"), "\n");
|
||||
assert_eq!(at.read("xae"), "3\n");
|
||||
assert_eq!(at.read("xaf"), "4");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue