mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
Add initial tests for echo.
This commit is contained in:
parent
e700e0d2f4
commit
87e7cc9b44
2 changed files with 51 additions and 0 deletions
1
Makefile
1
Makefile
|
@ -162,6 +162,7 @@ TEST_PROGS := \
|
||||||
cp \
|
cp \
|
||||||
env \
|
env \
|
||||||
dirname \
|
dirname \
|
||||||
|
echo \
|
||||||
factor \
|
factor \
|
||||||
fold \
|
fold \
|
||||||
mkdir \
|
mkdir \
|
||||||
|
|
50
test/echo.rs
Normal file
50
test/echo.rs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
use std::process::Command;
|
||||||
|
use std::str;
|
||||||
|
|
||||||
|
static PROGNAME: &'static str = "./echo";
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_default() {
|
||||||
|
let po = Command::new(PROGNAME)
|
||||||
|
.output()
|
||||||
|
.unwrap_or_else(|err| panic!("{}", err));
|
||||||
|
|
||||||
|
let out = str::from_utf8(&po.stdout[..]).unwrap();
|
||||||
|
assert_eq!(out, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_no_trailing_newline() {
|
||||||
|
let po = Command::new(PROGNAME)
|
||||||
|
.arg("-n")
|
||||||
|
.arg("hello_world")
|
||||||
|
.output()
|
||||||
|
.unwrap_or_else(|err| panic!("{}", err));
|
||||||
|
|
||||||
|
let out = str::from_utf8(&po.stdout[..]).unwrap();
|
||||||
|
assert_eq!(out, "hello_world");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_enable_escapes() {
|
||||||
|
let po = Command::new(PROGNAME)
|
||||||
|
.arg("-e")
|
||||||
|
.arg("\\\\\\t\\r")
|
||||||
|
.output()
|
||||||
|
.unwrap_or_else(|err| panic!("{}", err));
|
||||||
|
|
||||||
|
let out = str::from_utf8(&po.stdout[..]).unwrap();
|
||||||
|
assert_eq!(out, "\\\t\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_disable_escapes() {
|
||||||
|
let po = Command::new(PROGNAME)
|
||||||
|
.arg("-E")
|
||||||
|
.arg("\\b\\c\\e")
|
||||||
|
.output()
|
||||||
|
.unwrap_or_else(|err| panic!("{}", err));
|
||||||
|
|
||||||
|
let out = str::from_utf8(&po.stdout[..]).unwrap();
|
||||||
|
assert_eq!(out, "\\b\\c\\e\n");
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue