2020-05-25 17:05:26 +00:00
|
|
|
use crate::common::util::*;
|
2015-11-16 05:25:01 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_default() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-08-13 21:59:21 +00:00
|
|
|
.pipe_in("100\n200\n300\n400\n500")
|
|
|
|
.run()
|
|
|
|
.stdout_is("500400\n300\n200\n100\n");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_non_newline_separator() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-08-13 21:59:21 +00:00
|
|
|
.args(&["-s", ":"])
|
|
|
|
.pipe_in("100:200:300:400:500")
|
|
|
|
.run()
|
|
|
|
.stdout_is("500400:300:200:100:");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_non_newline_separator_before() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-08-13 21:59:21 +00:00
|
|
|
.args(&["-b", "-s", ":"])
|
|
|
|
.pipe_in("100:200:300:400:500")
|
|
|
|
.run()
|
|
|
|
.stdout_is("500:400:300:200:100");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_single_default() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg("prime_per_line.txt")
|
|
|
|
.run()
|
|
|
|
.stdout_is_fixture("prime_per_line.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_single_non_newline_separator() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["-s", ":", "delimited_primes.txt"])
|
|
|
|
.run()
|
|
|
|
.stdout_is_fixture("delimited_primes.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_single_non_newline_separator_before() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["-b", "-s", ":", "delimited_primes.txt"])
|
|
|
|
.run()
|
|
|
|
.stdout_is_fixture("delimited_primes_before.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
2021-03-31 19:21:10 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_invalid_input() {
|
2021-04-22 20:37:44 +00:00
|
|
|
let scene = TestScenario::new(util_name!());
|
|
|
|
let at = &scene.fixtures;
|
2021-03-31 19:21:10 +00:00
|
|
|
|
2021-04-22 20:37:44 +00:00
|
|
|
scene
|
|
|
|
.ucmd()
|
|
|
|
.arg("b")
|
|
|
|
.fails()
|
|
|
|
.stderr_contains("failed to open 'b' for reading: No such file or directory");
|
2021-03-31 19:21:10 +00:00
|
|
|
|
|
|
|
at.mkdir("a");
|
2021-04-22 20:37:44 +00:00
|
|
|
scene
|
|
|
|
.ucmd()
|
|
|
|
.arg("a")
|
|
|
|
.fails()
|
|
|
|
.stderr_contains("dir: read error: Invalid argument");
|
2021-03-31 19:21:10 +00:00
|
|
|
}
|