2015-05-29 17:47:00 +00:00
|
|
|
use std::process::Command;
|
|
|
|
use util::*;
|
2014-05-18 15:58:56 +00:00
|
|
|
|
2014-07-21 17:08:19 +00:00
|
|
|
static PROGNAME: &'static str = "./tr";
|
|
|
|
|
2015-05-29 17:47:00 +00:00
|
|
|
#[path = "common/util.rs"]
|
|
|
|
#[macro_use]
|
|
|
|
mod util;
|
2014-05-18 15:58:56 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_toupper() {
|
2015-05-29 17:47:00 +00:00
|
|
|
let mut cmd = Command::new(PROGNAME);
|
|
|
|
let result = run_piped_stdin(&mut cmd.args(&["a-z", "A-Z"]), b"!abcd!");
|
|
|
|
assert_eq!(result.stdout, "!ABCD!");
|
2014-05-18 15:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_small_set2() {
|
2015-05-29 17:47:00 +00:00
|
|
|
let mut cmd = Command::new(PROGNAME);
|
|
|
|
let result = run_piped_stdin(&mut cmd.args(&["0-9", "X"]), b"@0123456789");
|
|
|
|
assert_eq!(result.stdout, "@XXXXXXXXXX");
|
2014-05-18 15:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_unicode() {
|
2015-05-29 17:47:00 +00:00
|
|
|
let mut cmd = Command::new(PROGNAME);
|
|
|
|
let result = run_piped_stdin(&mut cmd.args(&[", ┬─┬", "╯︵┻━┻"]), "(,°□°), ┬─┬".as_bytes());
|
|
|
|
assert_eq!(result.stdout, "(╯°□°)╯︵┻━┻");
|
2014-05-18 15:58:56 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 20:20:07 +00:00
|
|
|
#[test]
|
|
|
|
fn test_delete() {
|
2015-05-29 17:47:00 +00:00
|
|
|
let mut cmd = Command::new(PROGNAME);
|
|
|
|
let result = run_piped_stdin(&mut cmd.args(&["-d", "a-z"]), b"aBcD");
|
|
|
|
assert_eq!(result.stdout, "BD");
|
2014-05-18 20:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_delete_complement() {
|
2015-05-29 17:47:00 +00:00
|
|
|
let mut cmd = Command::new(PROGNAME);
|
|
|
|
let result = run_piped_stdin(&mut cmd.args(&["-d", "-c", "a-z"]), b"aBcD");
|
|
|
|
assert_eq!(result.stdout, "ac");
|
2014-05-18 20:20:07 +00:00
|
|
|
}
|