mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
split: use ByteChunkWriter and LineChunkWriter
Replace `ByteSplitter` and `LineSplitter` with `ByteChunkWriter` and `LineChunkWriter` respectively. This results in a more maintainable design and an increase in the speed of splitting by lines.
This commit is contained in:
parent
ca7af808d5
commit
1d7e1b8732
3 changed files with 65 additions and 59 deletions
|
@ -2,7 +2,7 @@
|
|||
// *
|
||||
// * For the full copyright and license information, please view the LICENSE
|
||||
// * file that was distributed with this source code.
|
||||
// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes asciilowercase fghij klmno pqrst uvwxyz
|
||||
// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes asciilowercase fghij klmno pqrst uvwxyz fivelines
|
||||
extern crate rand;
|
||||
extern crate regex;
|
||||
|
||||
|
@ -449,3 +449,21 @@ fn test_invalid_suffix_length() {
|
|||
.no_stdout()
|
||||
.stderr_contains("invalid suffix length: 'xyz'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_include_newlines() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.args(&["-l", "2", "fivelines.txt"]).succeeds();
|
||||
|
||||
let mut s = String::new();
|
||||
at.open("xaa").read_to_string(&mut s).unwrap();
|
||||
assert_eq!(s, "1\n2\n");
|
||||
|
||||
let mut s = String::new();
|
||||
at.open("xab").read_to_string(&mut s).unwrap();
|
||||
assert_eq!(s, "3\n4\n");
|
||||
|
||||
let mut s = String::new();
|
||||
at.open("xac").read_to_string(&mut s).unwrap();
|
||||
assert_eq!(s, "5\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue