coreutils/tests/test_uniq.rs
Nathan Ross 569cd162d3 tests: refactor conventional TestScenario usage
Updates to individual integration tests

  - use proposed conventional approach to beginning tests

  - use new convenience functions for using fixtures

  - use new names for TestScenario

Updates to integration test modules

  - add proposed conventional module-level functions

Updates to test/common/util.rs

  - rename TestSet, and its methods, for semantic clarity

  - create convenience functions for use of fixtures

  - delete convenience functions obsoleted by new conventions
2016-08-01 13:42:00 -04:00

94 lines
2.3 KiB
Rust

use common::util::*;
static UTIL_NAME: &'static str = "uniq";
fn new_ucmd() -> UCommand {
TestScenario::new(UTIL_NAME).ucmd()
}
static INPUT: &'static str = "sorted.txt";
static SKIP_CHARS: &'static str = "skip-chars.txt";
static SKIP_FIELDS: &'static str = "skip-fields.txt";
#[test]
fn test_stdin_default() {
new_ucmd()
.pipe_in_fixture(INPUT)
.run().stdout_is_fixture("sorted-simple.expected");
}
#[test]
fn test_single_default() {
new_ucmd()
.arg(INPUT)
.run().stdout_is_fixture("sorted-simple.expected");
}
#[test]
fn test_stdin_counts() {
new_ucmd()
.args(&["-c"]).pipe_in_fixture(INPUT)
.run().stdout_is_fixture("sorted-counts.expected");
}
#[test]
fn test_stdin_skip_1_char() {
new_ucmd()
.args(&["-s1"]).pipe_in_fixture(SKIP_CHARS)
.run().stdout_is_fixture("skip-1-char.expected");
}
#[test]
fn test_stdin_skip_5_chars() {
new_ucmd()
.args(&["-s5"]).pipe_in_fixture(SKIP_CHARS)
.run().stdout_is_fixture("skip-5-chars.expected");
}
#[test]
fn test_stdin_skip_and_check_2_chars() {
new_ucmd()
.args(&["-s3", "-w2"]).pipe_in_fixture(SKIP_CHARS)
.run().stdout_is_fixture("skip-3-check-2-chars.expected");
}
#[test]
fn test_stdin_skip_1_field() {
new_ucmd()
.args(&["-f2"]).pipe_in_fixture(SKIP_FIELDS)
.run().stdout_is_fixture("skip-2-fields.expected");
}
#[test]
fn test_stdin_all_repeated() {
new_ucmd()
.args(&["--all-repeated"]).pipe_in_fixture(INPUT)
.run().stdout_is_fixture("sorted-all-repeated.expected");
}
#[test]
fn test_stdin_all_repeated_separate() {
new_ucmd()
.args(&["--all-repeated", "separate"]).pipe_in_fixture(INPUT)
.run().stdout_is_fixture("sorted-all-repeated-separate.expected");
}
#[test]
fn test_stdin_all_repeated_prepend() {
new_ucmd()
.args(&["--all-repeated", "prepend"]).pipe_in_fixture(INPUT)
.run().stdout_is_fixture("sorted-all-repeated-prepend.expected");
}
#[test]
fn test_stdin_unique_only() {
new_ucmd()
.args(&["-u"]).pipe_in_fixture(INPUT)
.run().stdout_is_fixture("sorted-unique-only.expected");
}
#[test]
fn test_stdin_repeated_only() {
new_ucmd()
.args(&["-d"]).pipe_in_fixture(INPUT)
.run().stdout_is_fixture("sorted-repeated-only.expected");
}