2
0
Fork 0
mirror of https://github.com/uutils/coreutils synced 2024-12-29 06:23:17 +00:00
coreutils/tests/test_wc.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

56 lines
1.8 KiB
Rust

use common::util::*;
static UTIL_NAME: &'static str = "wc";
#[test]
fn test_stdin_default() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.run_piped_stdin(at.read("lorem_ipsum.txt"));
assert_eq!(result.stdout, " 13 109 772\n");
}
#[test]
fn test_stdin_only_bytes() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-c"]).run_piped_stdin(at.read("lorem_ipsum.txt"));
assert_eq!(result.stdout, " 772\n");
}
#[test]
fn test_stdin_all_counts() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-c", "-m", "-l", "-L", "-w"])
.run_piped_stdin(at.read("alice_in_wonderland.txt"));
assert_eq!(result.stdout, " 5 57 302 302 66\n");
}
#[test]
fn test_single_default() {
let (_, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.arg("moby_dick.txt").run();
assert_eq!(result.stdout, " 18 204 1115 moby_dick.txt\n");
}
#[test]
fn test_single_only_lines() {
let (_, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-l", "moby_dick.txt"]).run();
assert_eq!(result.stdout, " 18 moby_dick.txt\n");
}
#[test]
fn test_single_all_counts() {
let (_, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["-c", "-l", "-L", "-m", "-w", "alice_in_wonderland.txt"]).run();
assert_eq!(result.stdout,
" 5 57 302 302 66 alice_in_wonderland.txt\n");
}
#[test]
fn test_multiple_default() {
let (_, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["lorem_ipsum.txt", "moby_dick.txt", "alice_in_wonderland.txt"]).run();
assert_eq!(result.stdout,
" 13 109 772 lorem_ipsum.txt\n 18 204 1115 moby_dick.txt\n 5 57 302 \
alice_in_wonderland.txt\n 36 370 2189 total\n");
}