2020-05-25 17:05:26 +00:00
|
|
|
use crate::common::util::*;
|
2015-11-16 05:25:01 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_default_80_column_wrap() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-07-29 21:26:32 +00:00
|
|
|
.arg("lorem_ipsum.txt")
|
|
|
|
.run()
|
|
|
|
.stdout_is_fixture("lorem_ipsum_80_column.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_40_column_hard_cutoff() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-08-13 21:59:21 +00:00
|
|
|
.args(&["-w", "40", "lorem_ipsum.txt"])
|
2016-07-29 21:26:32 +00:00
|
|
|
.run()
|
|
|
|
.stdout_is_fixture("lorem_ipsum_40_column_hard.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_40_column_word_boundary() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-08-13 21:59:21 +00:00
|
|
|
.args(&["-s", "-w", "40", "lorem_ipsum.txt"])
|
2016-07-29 21:26:32 +00:00
|
|
|
.run()
|
|
|
|
.stdout_is_fixture("lorem_ipsum_40_column_word.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
2021-01-05 08:10:01 +00:00
|
|
|
|
|
|
|
#[test]
|
2021-04-02 13:13:25 +00:00
|
|
|
fn test_default_wrap_with_newlines() {
|
2021-01-05 08:10:01 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg("lorem_ipsum_new_line.txt")
|
|
|
|
.run()
|
|
|
|
.stdout_is_fixture("lorem_ipsum_new_line_80_column.expected");
|
|
|
|
}
|
2021-04-02 13:13:25 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_should_preserve_empty_lines() {
|
|
|
|
new_ucmd!().pipe_in("\n").succeeds().stdout_is("\n");
|
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("-w1")
|
|
|
|
.pipe_in("0\n1\n\n2\n\n\n")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_is("0\n1\n\n2\n\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_word_boundary_split_should_preserve_empty_lines() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("-s")
|
|
|
|
.pipe_in("\n")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_is("\n");
|
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.args(&["-w1", "-s"])
|
|
|
|
.pipe_in("0\n1\n\n2\n\n\n")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_is("0\n1\n\n2\n\n\n");
|
|
|
|
}
|