1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

Merge pull request #2980 from jfinkels/split-lines-2

split: add support for "-n l/NUM" option to split
This commit is contained in:
Sylvestre Ledru 2022-03-01 10:13:44 +01:00 committed by GitHub
commit 346cfa060b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 318 additions and 10 deletions

View file

@ -570,3 +570,20 @@ fn test_elide_empty_files() {
assert_eq!(at.read("xac"), "c");
assert!(!at.plus("xad").exists());
}
#[test]
fn test_lines() {
let (at, mut ucmd) = at_and_ucmd!();
let file_read = |f| {
let mut s = String::new();
at.open(f).read_to_string(&mut s).unwrap();
s
};
// Split into two files without splitting up lines.
ucmd.args(&["-n", "l/2", "fivelines.txt"]).succeeds();
assert_eq!(file_read("xaa"), "1\n2\n3\n");
assert_eq!(file_read("xab"), "4\n5\n");
}