mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
fold: preserve carriage return and overwritten chars in output
This commit is contained in:
parent
0b731dfd1a
commit
56bc7a44eb
2 changed files with 71 additions and 16 deletions
|
@ -285,6 +285,34 @@ fn test_backspace_is_not_word_boundary() {
|
|||
.stdout_is("foobar\x086789a\nbcdef");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_carriage_return_should_be_preserved() {
|
||||
new_ucmd!().pipe_in("\r").succeeds().stdout_is("\r");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_carriage_return_overwrriten_char_should_be_preserved() {
|
||||
new_ucmd!().pipe_in("x\ry").succeeds().stdout_is("x\ry");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_carriage_return_should_reset_column_count() {
|
||||
new_ucmd!()
|
||||
.arg("-w6")
|
||||
.pipe_in("12345\r123456789abcdef")
|
||||
.succeeds()
|
||||
.stdout_is("12345\r123456\n789abc\ndef");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_carriage_return_is_not_word_boundary() {
|
||||
new_ucmd!()
|
||||
.args(&["-w6", "-s"])
|
||||
.pipe_in("fizz\rbuzz\rfizzbuzz")
|
||||
.succeeds()
|
||||
.stdout_is("fizz\rbuzz\rfizzbu\nzz");
|
||||
}
|
||||
|
||||
//
|
||||
// bytewise tests
|
||||
|
||||
|
@ -470,3 +498,39 @@ fn test_bytewise_backspace_is_not_word_boundary() {
|
|||
.succeeds()
|
||||
.stdout_is("foobar\x0889a\nbcdef");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bytewise_carriage_return_should_be_preserved() {
|
||||
new_ucmd!()
|
||||
.arg("-b")
|
||||
.pipe_in("\r")
|
||||
.succeeds()
|
||||
.stdout_is("\r");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bytewise_carriage_return_overwrriten_char_should_be_preserved() {
|
||||
new_ucmd!()
|
||||
.arg("-b")
|
||||
.pipe_in("x\ry")
|
||||
.succeeds()
|
||||
.stdout_is("x\ry");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bytewise_carriage_return_should_not_reset_column_count() {
|
||||
new_ucmd!()
|
||||
.args(&["-w6", "-b"])
|
||||
.pipe_in("12345\r123456789abcdef")
|
||||
.succeeds()
|
||||
.stdout_is("12345\r\n123456\n789abc\ndef");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bytewise_carriage_return_is_not_word_boundary() {
|
||||
new_ucmd!()
|
||||
.args(&["-w6", "-s", "-b"])
|
||||
.pipe_in("fizz\rbuzz\rfizzbuzz")
|
||||
.succeeds()
|
||||
.stdout_is("fizz\rb\nuzz\rfi\nzzbuzz");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue