mirror of
https://github.com/uutils/coreutils
synced 2024-12-16 08:12:39 +00:00
71 lines
1.9 KiB
Rust
71 lines
1.9 KiB
Rust
|
use std::process::Command;
|
||
|
use util::*;
|
||
|
|
||
|
static PROGNAME: &'static str = "./sum";
|
||
|
|
||
|
#[path = "common/util.rs"]
|
||
|
#[macro_use]
|
||
|
mod util;
|
||
|
|
||
|
#[test]
|
||
|
fn test_bsd_single_file() {
|
||
|
let mut cmd = Command::new(PROGNAME);
|
||
|
let result = run(&mut cmd.arg("lorem_ipsum.txt"));
|
||
|
|
||
|
assert_empty_stderr!(result);
|
||
|
assert!(result.success);
|
||
|
assert_eq!(result.stdout, get_file_contents("bsd_single_file.expected"));
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_bsd_multiple_files() {
|
||
|
let mut cmd = Command::new(PROGNAME);
|
||
|
let result = run(&mut cmd.arg("lorem_ipsum.txt").arg("alice_in_wonderland.txt"));
|
||
|
|
||
|
assert_empty_stderr!(result);
|
||
|
assert!(result.success);
|
||
|
assert_eq!(result.stdout, get_file_contents("bsd_multiple_files.expected"));
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_bsd_stdin() {
|
||
|
let input = get_file_contents("lorem_ipsum.txt");
|
||
|
let mut cmd = Command::new(PROGNAME);
|
||
|
let result = run_piped_stdin(&mut cmd, input);
|
||
|
|
||
|
assert_empty_stderr!(result);
|
||
|
assert!(result.success);
|
||
|
assert_eq!(result.stdout, get_file_contents("bsd_stdin.expected"));
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_sysv_single_file() {
|
||
|
let mut cmd = Command::new(PROGNAME);
|
||
|
let result = run(&mut cmd.arg("-s").arg("lorem_ipsum.txt"));
|
||
|
|
||
|
assert_empty_stderr!(result);
|
||
|
assert!(result.success);
|
||
|
assert_eq!(result.stdout, get_file_contents("sysv_single_file.expected"));
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_sysv_multiple_files() {
|
||
|
let mut cmd = Command::new(PROGNAME);
|
||
|
let result = run(&mut cmd.arg("-s").arg("lorem_ipsum.txt").arg("alice_in_wonderland.txt"));
|
||
|
|
||
|
assert_empty_stderr!(result);
|
||
|
assert!(result.success);
|
||
|
assert_eq!(result.stdout, get_file_contents("sysv_multiple_files.expected"));
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_sysv_stdin() {
|
||
|
let input = get_file_contents("lorem_ipsum.txt");
|
||
|
let mut cmd = Command::new(PROGNAME);
|
||
|
let result = run_piped_stdin(&mut cmd.arg("-s"), input);
|
||
|
|
||
|
assert_empty_stderr!(result);
|
||
|
assert!(result.success);
|
||
|
assert_eq!(result.stdout, get_file_contents("sysv_stdin.expected"));
|
||
|
}
|