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:
parent
dded5fb80d
commit
1718fbe72c
2 changed files with 34 additions and 0 deletions
1
Makefile
1
Makefile
|
@ -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
33
tr/test.rs
Normal 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!("(╯°□°)╯︵┻━┻"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue