1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

tr: add some tests

This commit is contained in:
Michael Gehring 2014-05-18 17:58:56 +02:00
parent dded5fb80d
commit 1718fbe72c
2 changed files with 34 additions and 0 deletions

View file

@ -61,6 +61,7 @@ TEST_PROGS := \
cat \ cat \
mkdir \ mkdir \
seq \ seq \
tr \
truncate \ truncate \
TEST ?= $(TEST_PROGS) TEST ?= $(TEST_PROGS)

33
tr/test.rs Normal file
View file

@ -0,0 +1,33 @@
use std::io::process::Command;
fn run(input: &str, set1: &str, set2: &str) -> Vec<u8> {
let mut process = Command::new("build/tr").arg(set1).arg(set2).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(), bytes!("!ABCD!"));
}
#[test]
fn test_small_set2() {
let out = run("@0123456789", "0-9", "X");
assert_eq!(out.as_slice(), bytes!("@XXXXXXXXXX"));
}
#[test]
fn test_unicode() {
let out = run("(,°□°), ┬─┬", ", ┬─┬", "╯︵┻━┻");
assert_eq!(out.as_slice(), bytes!("(╯°□°)╯︵┻━┻"));
}