coreutils/tests/test_head.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

71 lines
2 KiB
Rust

use common::util::*;
static UTIL_NAME: &'static str = "head";
static INPUT: &'static str = "lorem_ipsum.txt";
#[test]
fn test_stdin_default() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.run_piped_stdin(at.read(INPUT));
assert_eq!(result.stdout, at.read("lorem_ipsum_default.expected"));
}
#[test]
fn test_stdin_1_line_obsolete() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-1"])
.run_piped_stdin(at.read(INPUT));
assert_eq!(result.stdout, at.read("lorem_ipsum_1_line.expected"));
}
#[test]
fn test_stdin_1_line() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-n", "1"])
.run_piped_stdin(at.read(INPUT));
assert_eq!(result.stdout, at.read("lorem_ipsum_1_line.expected"));
}
#[test]
fn test_stdin_5_chars() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-c", "5"])
.run_piped_stdin(at.read(INPUT));
assert_eq!(result.stdout, at.read("lorem_ipsum_5_chars.expected"));
}
#[test]
fn test_single_default() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.arg(INPUT).run();
assert_eq!(result.stdout, at.read("lorem_ipsum_default.expected"));
}
#[test]
fn test_single_1_line_obsolete() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-1", INPUT]).run();
assert_eq!(result.stdout, at.read("lorem_ipsum_1_line.expected"));
}
#[test]
fn test_single_1_line() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-n", "1", INPUT]).run();
assert_eq!(result.stdout, at.read("lorem_ipsum_1_line.expected"));
}
#[test]
fn test_single_5_chars() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-c", "5", INPUT]).run();
assert_eq!(result.stdout, at.read("lorem_ipsum_5_chars.expected"));
}
#[test]
fn test_verbose() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-v", INPUT]).run();
assert_eq!(result.stdout, at.read("lorem_ipsum_verbose.expected"));
}