mirror of
https://github.com/uutils/coreutils
synced 2024-12-16 00:02:50 +00:00
45 lines
1 KiB
Rust
45 lines
1 KiB
Rust
use std::io::process::Command;
|
|
|
|
fn run(input: &str, args: &[&'static str]) -> Vec<u8> {
|
|
let mut process = Command::new("build/tr").args(args).spawn().unwrap();
|
|
|
|
process.stdin.take_unwrap().write_str(input).unwrap();
|
|
|
|
let po = match process.wait_with_output() {
|
|
Ok(p) => p,
|
|
Err(err) => fail!("{}", err),
|
|
};
|
|
po.output
|
|
}
|
|
|
|
#[test]
|
|
fn test_toupper() {
|
|
let out = run("!abcd!", ["a-z", "A-Z"]);
|
|
assert_eq!(out.as_slice(), b"!ABCD!");
|
|
}
|
|
|
|
#[test]
|
|
fn test_small_set2() {
|
|
let out = run("@0123456789", ["0-9", "X"]);
|
|
assert_eq!(out.as_slice(), b"@XXXXXXXXXX");
|
|
}
|
|
|
|
#[test]
|
|
fn test_unicode() {
|
|
let out = run("(,°□°), ┬─┬", [", ┬─┬", "╯︵┻━┻"]);
|
|
assert_eq!(out.as_slice(), "(╯°□°)╯︵┻━┻".as_bytes());
|
|
}
|
|
|
|
#[test]
|
|
fn test_delete() {
|
|
let out = run("aBcD", ["-d", "a-z"]);
|
|
assert_eq!(out.as_slice(), b"BD");
|
|
}
|
|
|
|
#[test]
|
|
fn test_delete_complement() {
|
|
let out = run("aBcD", ["-d", "-c", "a-z"]);
|
|
assert_eq!(out.as_slice(), b"ac");
|
|
}
|
|
|
|
|