coreutils/test/tr.rs

44 lines
1.1 KiB
Rust
Raw Normal View History

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";
#[path = "common/util.rs"]
#[macro_use]
mod util;
2014-05-18 15:58:56 +00:00
#[test]
fn test_toupper() {
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() {
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() {
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() {
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() {
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
}