mirror of
https://github.com/uutils/coreutils.git
synced 2025-07-07 21:45:01 +00:00
Merge pull request #7636 from karlmcdowall/cat_find_a_bug_fix_a_bug
cat: bugfix when running with -T option
This commit is contained in:
commit
7af2c94678
2 changed files with 24 additions and 1 deletions
|
@ -644,7 +644,7 @@ fn write_tab_to_end<W: Write>(mut in_buf: &[u8], writer: &mut W) -> usize {
|
|||
}
|
||||
None => {
|
||||
writer.write_all(in_buf).unwrap();
|
||||
return in_buf.len();
|
||||
return in_buf.len() + count;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -688,6 +688,20 @@ fn write_end_of_line<W: Write>(
|
|||
mod tests {
|
||||
use std::io::{BufWriter, stdout};
|
||||
|
||||
#[test]
|
||||
fn test_write_tab_to_end_with_newline() {
|
||||
let mut writer = BufWriter::with_capacity(1024 * 64, stdout());
|
||||
let in_buf = b"a\tb\tc\n";
|
||||
assert_eq!(super::write_tab_to_end(in_buf, &mut writer), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_write_tab_to_end_no_newline() {
|
||||
let mut writer = BufWriter::with_capacity(1024 * 64, stdout());
|
||||
let in_buf = b"a\tb\tc";
|
||||
assert_eq!(super::write_tab_to_end(in_buf, &mut writer), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_write_nonprint_to_end_new_line() {
|
||||
let mut writer = BufWriter::with_capacity(1024 * 64, stdout());
|
||||
|
|
|
@ -414,6 +414,15 @@ fn test_stdin_nonprinting_and_tabs_repeated() {
|
|||
.stdout_only("^I^@\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stdin_tabs_no_newline() {
|
||||
new_ucmd!()
|
||||
.args(&["-T"])
|
||||
.pipe_in("\ta")
|
||||
.succeeds()
|
||||
.stdout_only("^Ia");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stdin_squeeze_blank() {
|
||||
for same_param in ["-s", "--squeeze-blank", "--squeeze"] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue