2020-05-25 17:05:26 +00:00
|
|
|
use crate::common::util::*;
|
2015-11-16 05:25:01 +00:00
|
|
|
|
|
|
|
#[test]
|
2021-05-30 05:10:54 +00:00
|
|
|
fn test_stdin_no_newline() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.pipe_in("No Newline")
|
|
|
|
.run()
|
|
|
|
.stdout_is(" 1\tNo Newline\n");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_newline() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-07-29 21:26:32 +00:00
|
|
|
.args(&["-s", "-", "-w", "1"])
|
2016-08-13 21:59:21 +00:00
|
|
|
.pipe_in("Line One\nLine Two\n")
|
|
|
|
.run()
|
|
|
|
.stdout_is("1-Line One\n2-Line Two\n");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_padding_without_overflow() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["-i", "1000", "-s", "x", "-n", "rz", "simple.txt"])
|
|
|
|
.run()
|
2016-08-13 21:59:21 +00:00
|
|
|
.stdout_is(
|
2020-04-13 18:36:03 +00:00
|
|
|
"000001xL1\n001001xL2\n002001xL3\n003001xL4\n004001xL5\n005001xL6\n006001xL7\n0070\
|
2021-03-18 09:24:30 +00:00
|
|
|
01xL8\n008001xL9\n009001xL10\n010001xL11\n011001xL12\n012001xL13\n013001xL14\n014\
|
|
|
|
001xL15\n",
|
2020-04-13 18:36:03 +00:00
|
|
|
);
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_padding_with_overflow() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["-i", "1000", "-s", "x", "-n", "rz", "-w", "4", "simple.txt"])
|
|
|
|
.run()
|
2016-08-13 21:59:21 +00:00
|
|
|
.stdout_is(
|
2020-04-13 18:36:03 +00:00
|
|
|
"0001xL1\n1001xL2\n2001xL3\n3001xL4\n4001xL5\n5001xL6\n6001xL7\n7001xL8\n8001xL9\n\
|
2021-03-18 09:24:30 +00:00
|
|
|
9001xL10\n10001xL11\n11001xL12\n12001xL13\n13001xL14\n14001xL15\n",
|
2020-04-13 18:36:03 +00:00
|
|
|
);
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_sections_and_styles() {
|
2021-05-30 05:10:54 +00:00
|
|
|
// spell-checker:disable
|
2020-04-13 18:36:03 +00:00
|
|
|
for &(fixture, output) in &[
|
|
|
|
(
|
|
|
|
"section.txt",
|
|
|
|
"\nHEADER1\nHEADER2\n\n1 |BODY1\n2 \
|
2021-03-18 09:24:30 +00:00
|
|
|
|BODY2\n\nFOOTER1\nFOOTER2\n\nNEXTHEADER1\nNEXTHEADER2\n\n1 \
|
|
|
|
|NEXTBODY1\n2 |NEXTBODY2\n\nNEXTFOOTER1\nNEXTFOOTER2\n",
|
2020-04-13 18:36:03 +00:00
|
|
|
),
|
|
|
|
(
|
|
|
|
"joinblanklines.txt",
|
|
|
|
"1 |Nonempty\n2 |Nonempty\n3 |Followed by 10x empty\n\n\n\n\n4 \
|
2021-03-18 09:24:30 +00:00
|
|
|
|\n\n\n\n\n5 |\n6 |Followed by 5x empty\n\n\n\n\n7 |\n8 \
|
|
|
|
|Followed by 4x empty\n\n\n\n\n9 |Nonempty\n10 |Nonempty\n11 \
|
|
|
|
|Nonempty.\n",
|
2020-04-13 18:36:03 +00:00
|
|
|
),
|
|
|
|
] {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&[
|
|
|
|
"-s", "|", "-n", "ln", "-w", "3", "-b", "a", "-l", "5", fixture,
|
|
|
|
])
|
2016-08-13 21:59:21 +00:00
|
|
|
.run()
|
|
|
|
.stdout_is(output);
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
2021-05-30 05:10:54 +00:00
|
|
|
// spell-checker:enable
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|