2015-11-16 05:25:01 +00:00
|
|
|
use common::util::*;
|
|
|
|
|
|
|
|
static UTIL_NAME: &'static str = "tac";
|
2016-07-29 21:26:32 +00:00
|
|
|
fn new_ucmd() -> UCommand {
|
|
|
|
TestScenario::new(UTIL_NAME).ucmd()
|
|
|
|
}
|
2015-11-16 05:25:01 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_default() {
|
2016-07-29 21:26:32 +00:00
|
|
|
let result = new_ucmd()
|
|
|
|
.run_piped_stdin("100\n200\n300\n400\n500");
|
2015-11-16 05:25:01 +00:00
|
|
|
assert_eq!(result.stdout, "500400\n300\n200\n100\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_non_newline_separator() {
|
2016-07-29 21:26:32 +00:00
|
|
|
let result = new_ucmd()
|
|
|
|
.args(&["-s", ":"]).run_piped_stdin("100:200:300:400:500");
|
2015-11-16 05:25:01 +00:00
|
|
|
assert_eq!(result.stdout, "500400:300:200:100:");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_non_newline_separator_before() {
|
2016-07-29 21:26:32 +00:00
|
|
|
let result = new_ucmd()
|
|
|
|
.args(&["-b", "-s", ":"]).run_piped_stdin("100:200:300:400:500");
|
2015-11-16 05:25:01 +00:00
|
|
|
assert_eq!(result.stdout, "500:400:300:200:100");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_single_default() {
|
2016-07-29 21:26:32 +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() {
|
2016-07-29 21:26:32 +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() {
|
2016-07-29 21:26:32 +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
|
|
|
}
|