2015-11-16 05:25:01 +00:00
|
|
|
use common::util::*;
|
|
|
|
|
|
|
|
static UTIL_NAME: &'static str = "cut";
|
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 = "lists.txt";
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_prefix() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd().args(&["-c", "-10", INPUT]).run().stdout_is_fixture("lists_prefix.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_char_range() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd().args(&["-c", "4-10", INPUT]).run().stdout_is_fixture("lists_char_range.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_column_to_end_of_line() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd().args(&["-d", ":", "-f", "5-", INPUT]).run().stdout_is_fixture("lists_column_to_end_of_line.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_specific_field() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd().args(&["-d", " ", "-f", "3", INPUT]).run().stdout_is_fixture("lists_specific_field.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_multiple_fields() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd().args(&["-d", ":", "-f", "1,3", INPUT]).run().stdout_is_fixture("lists_multiple_fields.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_tail() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd().args(&["-d", ":", "--complement", "-f", "1", INPUT]).run().stdout_is_fixture("lists_tail.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_change_delimiter() {
|
2016-07-29 21:26:32 +00:00
|
|
|
new_ucmd()
|
|
|
|
.args(&["-d", ":", "--complement", "--output-delimiter=#", "-f", "1", INPUT])
|
|
|
|
.run().stdout_is_fixture("lists_change_delimiter.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|