mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
Merge pull request #2827 from jfinkels/split-std-io-copy
split: use std::io::copy() with new writer implementation to improve maintainability and speed
This commit is contained in:
commit
6b6d5ee7db
7 changed files with 333 additions and 146 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;
|
||||
|
||||
|
@ -446,7 +446,7 @@ fn test_number() {
|
|||
assert_eq!(file_read("xab"), "fghij");
|
||||
assert_eq!(file_read("xac"), "klmno");
|
||||
assert_eq!(file_read("xad"), "pqrst");
|
||||
assert_eq!(file_read("xae"), "uvwxyz");
|
||||
assert_eq!(file_read("xae"), "uvwxyz\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -457,3 +457,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