mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
split: fix for GNU Tests regression + tests
This commit is contained in:
parent
e79753c1cf
commit
15c7170d20
2 changed files with 76 additions and 4 deletions
|
@ -170,6 +170,22 @@ fn test_split_str_prefixed_chunks_by_bytes() {
|
|||
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||
}
|
||||
|
||||
// Test short bytes option concatenated with value
|
||||
#[test]
|
||||
fn test_split_by_bytes_short_concatenated_with_value() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let name = "split_by_bytes_short_concatenated_with_value";
|
||||
RandomFile::new(&at, name).add_bytes(10000);
|
||||
ucmd.args(&["-b1000", name]).succeeds();
|
||||
|
||||
let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$");
|
||||
assert_eq!(glob.count(), 10);
|
||||
for filename in glob.collect() {
|
||||
assert_eq!(glob.directory.metadata(&filename).len(), 1000);
|
||||
}
|
||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||
}
|
||||
|
||||
// This is designed to test what happens when the desired part size is not a
|
||||
// multiple of the buffer size and we hopefully don't overshoot the desired part
|
||||
// size.
|
||||
|
@ -326,6 +342,19 @@ fn test_split_lines_number() {
|
|||
.stderr_only("split: invalid number of lines: 'file'\n");
|
||||
}
|
||||
|
||||
// Test short lines option with value concatenated
|
||||
#[test]
|
||||
fn test_split_lines_short_concatenated_with_value() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let name = "split_num_prefixed_chunks_by_lines";
|
||||
RandomFile::new(&at, name).add_lines(10000);
|
||||
ucmd.args(&["-l1000", name]).succeeds();
|
||||
|
||||
let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$");
|
||||
assert_eq!(glob.count(), 10);
|
||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||
}
|
||||
|
||||
/// Test for obsolete lines option standalone
|
||||
#[test]
|
||||
fn test_split_obs_lines_standalone() {
|
||||
|
@ -692,6 +721,19 @@ fn test_invalid_suffix_length() {
|
|||
.stderr_contains("invalid suffix length: 'xyz'");
|
||||
}
|
||||
|
||||
// Test short suffix length option with value concatenated
|
||||
#[test]
|
||||
fn test_split_suffix_length_short_concatenated_with_value() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let name = "split_num_prefixed_chunks_by_lines";
|
||||
RandomFile::new(&at, name).add_lines(10000);
|
||||
ucmd.args(&["-a4", name]).succeeds();
|
||||
|
||||
let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]][[:alpha:]][[:alpha:]]$");
|
||||
assert_eq!(glob.count(), 10);
|
||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_include_newlines() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
@ -710,6 +752,19 @@ fn test_include_newlines() {
|
|||
assert_eq!(s, "5\n");
|
||||
}
|
||||
|
||||
// Test short number of chunks option concatenated with value
|
||||
#[test]
|
||||
fn test_split_number_chunks_short_concatenated_with_value() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.args(&["-n3", "threebytes.txt"])
|
||||
.succeeds()
|
||||
.no_stdout()
|
||||
.no_stderr();
|
||||
assert_eq!(at.read("xaa"), "a");
|
||||
assert_eq!(at.read("xab"), "b");
|
||||
assert_eq!(at.read("xac"), "c");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_allow_empty_files() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
@ -784,6 +839,16 @@ fn test_line_bytes() {
|
|||
assert_eq!(at.read("xad"), "ee\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_line_bytes_concatenated_with_value() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.args(&["-C8", "letters.txt"]).succeeds();
|
||||
assert_eq!(at.read("xaa"), "aaaaaaaa");
|
||||
assert_eq!(at.read("xab"), "a\nbbbb\n");
|
||||
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!();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue