coreutils/tests/test_tac.rs
Joseph Crail 7ef4bb37a8 tests: consolidate into one crate
The main motivation is to move toward running those tests for a specific
target, that is, if a test won't run on Windows, then we shouldn't build
it. This was previously the default behavior and prevented a successful
run on AppVeyor.

I borrowed this pattern from the tests in the Cargo project.
2016-05-22 03:46:54 -04:00

45 lines
1.4 KiB
Rust

use common::util::*;
static UTIL_NAME: &'static str = "tac";
#[test]
fn test_stdin_default() {
let (_, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.run_piped_stdin("100\n200\n300\n400\n500");
assert_eq!(result.stdout, "500400\n300\n200\n100\n");
}
#[test]
fn test_stdin_non_newline_separator() {
let (_, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-s", ":"]).run_piped_stdin("100:200:300:400:500");
assert_eq!(result.stdout, "500400:300:200:100:");
}
#[test]
fn test_stdin_non_newline_separator_before() {
let (_, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-b", "-s", ":"]).run_piped_stdin("100:200:300:400:500");
assert_eq!(result.stdout, "500:400:300:200:100");
}
#[test]
fn test_single_default() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.arg("prime_per_line.txt").run();
assert_eq!(result.stdout, at.read("prime_per_line.expected"));
}
#[test]
fn test_single_non_newline_separator() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-s", ":", "delimited_primes.txt"]).run();
assert_eq!(result.stdout, at.read("delimited_primes.expected"));
}
#[test]
fn test_single_non_newline_separator_before() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-b", "-s", ":", "delimited_primes.txt"]).run();
assert_eq!(result.stdout, at.read("delimited_primes_before.expected"));
}