2015-11-16 05:25:01 +00:00
|
|
|
use common::util::*;
|
|
|
|
|
|
|
|
static UTIL_NAME: &'static str = "head";
|
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
|
|
|
|
|
|
|
static INPUT: &'static str = "lorem_ipsum.txt";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_default() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd()
|
|
|
|
.pipe_in_fixture(INPUT)
|
|
|
|
.run().stdout_is_fixture("lorem_ipsum_default.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_1_line_obsolete() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd()
|
|
|
|
.args(&["-1"])
|
|
|
|
.pipe_in_fixture(INPUT)
|
|
|
|
.run().stdout_is_fixture("lorem_ipsum_1_line.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_1_line() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd()
|
|
|
|
.args(&["-n", "1"])
|
|
|
|
.pipe_in_fixture(INPUT)
|
|
|
|
.run().stdout_is_fixture("lorem_ipsum_1_line.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_5_chars() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd()
|
|
|
|
.args(&["-c", "5"])
|
|
|
|
.pipe_in_fixture(INPUT)
|
|
|
|
.run().stdout_is_fixture("lorem_ipsum_5_chars.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_single_default() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd()
|
|
|
|
.arg(INPUT)
|
|
|
|
.run().stdout_is_fixture("lorem_ipsum_default.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_single_1_line_obsolete() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd()
|
|
|
|
.args(&["-1", INPUT])
|
|
|
|
.run().stdout_is_fixture("lorem_ipsum_1_line.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_single_1_line() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd()
|
|
|
|
.args(&["-n", "1", INPUT])
|
|
|
|
.run().stdout_is_fixture("lorem_ipsum_1_line.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_single_5_chars() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd()
|
|
|
|
.args(&["-c", "5", INPUT])
|
|
|
|
.run().stdout_is_fixture("lorem_ipsum_5_chars.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_verbose() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd()
|
|
|
|
.args(&["-v", INPUT])
|
|
|
|
.run().stdout_is_fixture("lorem_ipsum_verbose.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|