mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
cut: improve function signature
and add test for existing functionality
This commit is contained in:
@@ -260,9 +260,9 @@ fn cut_fields_newline_char_delim<R: Read, W: Write>(
|
||||
reader: R,
|
||||
out: &mut W,
|
||||
ranges: &[Range],
|
||||
only_delimited: bool,
|
||||
newline_char: u8,
|
||||
out_delim: &[u8],
|
||||
only_delimited: bool,
|
||||
) -> UResult<()> {
|
||||
let mut reader = BufReader::new(reader);
|
||||
let mut line = Vec::new();
|
||||
@@ -398,9 +398,9 @@ fn cut_fields<R: Read, W: Write>(
|
||||
reader,
|
||||
out,
|
||||
ranges,
|
||||
field_opts.only_delimited,
|
||||
newline_char,
|
||||
out_delim,
|
||||
field_opts.only_delimited,
|
||||
)
|
||||
}
|
||||
Delimiter::Slice(delim) => {
|
||||
|
||||
@@ -229,6 +229,21 @@ fn test_zero_terminated_only_delimited() {
|
||||
.stdout_only("82\n7\0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_suppresses_unterminated_segment() {
|
||||
new_ucmd!()
|
||||
.args(&["-z", "-d", "", "-s", "-f", "1"])
|
||||
.pipe_in("unterminated")
|
||||
.succeeds()
|
||||
.stdout_only_bytes("");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["-z", "-d", "", "-s", "-f", "1"])
|
||||
.pipe_in("terminated\0unterminated")
|
||||
.succeeds()
|
||||
.stdout_only_bytes("terminated\0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_a_directory() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
Reference in New Issue
Block a user