mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 12:37:49 +00:00
commit
7300624a50
6 changed files with 117 additions and 0 deletions
5
Makefile
5
Makefile
|
@ -161,16 +161,21 @@ TEST_PROGS := \
|
||||||
cat \
|
cat \
|
||||||
cp \
|
cp \
|
||||||
env \
|
env \
|
||||||
|
dirname \
|
||||||
|
echo \
|
||||||
factor \
|
factor \
|
||||||
|
false \
|
||||||
fold \
|
fold \
|
||||||
mkdir \
|
mkdir \
|
||||||
mv \
|
mv \
|
||||||
nl \
|
nl \
|
||||||
paste \
|
paste \
|
||||||
|
pwd \
|
||||||
seq \
|
seq \
|
||||||
sort \
|
sort \
|
||||||
test \
|
test \
|
||||||
tr \
|
tr \
|
||||||
|
true \
|
||||||
truncate \
|
truncate \
|
||||||
unexpand
|
unexpand
|
||||||
|
|
||||||
|
|
28
test/dirname.rs
Normal file
28
test/dirname.rs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
use std::process::Command;
|
||||||
|
use std::str;
|
||||||
|
|
||||||
|
static PROGNAME: &'static str = "./dirname";
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_path_with_trailing_slashes() {
|
||||||
|
let dir = "/root/alpha/beta/gamma/delta/epsilon/omega//";
|
||||||
|
let po = Command::new(PROGNAME)
|
||||||
|
.arg(dir)
|
||||||
|
.output()
|
||||||
|
.unwrap_or_else(|err| panic!("{}", err));
|
||||||
|
|
||||||
|
let out = str::from_utf8(&po.stdout[..]).unwrap().trim_right();
|
||||||
|
assert_eq!(out, "/root/alpha/beta/gamma/delta/epsilon");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_path_without_trailing_slashes() {
|
||||||
|
let dir = "/root/alpha/beta/gamma/delta/epsilon/omega";
|
||||||
|
let po = Command::new(PROGNAME)
|
||||||
|
.arg(dir)
|
||||||
|
.output()
|
||||||
|
.unwrap_or_else(|err| panic!("{}", err));
|
||||||
|
|
||||||
|
let out = str::from_utf8(&po.stdout[..]).unwrap().trim_right();
|
||||||
|
assert_eq!(out, "/root/alpha/beta/gamma/delta/epsilon");
|
||||||
|
}
|
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");
|
||||||
|
}
|
9
test/false.rs
Normal file
9
test/false.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
static PROGNAME: &'static str = "./false";
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_exit_code() {
|
||||||
|
let exit_status = Command::new(PROGNAME).status().unwrap().success();
|
||||||
|
assert_eq!(exit_status, false);
|
||||||
|
}
|
16
test/pwd.rs
Normal file
16
test/pwd.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
use std::env;
|
||||||
|
use std::process::Command;
|
||||||
|
use std::str;
|
||||||
|
|
||||||
|
static PROGNAME: &'static str = "./pwd";
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_default() {
|
||||||
|
let po = Command::new(PROGNAME)
|
||||||
|
.output()
|
||||||
|
.unwrap_or_else(|err| panic!("{}", err));
|
||||||
|
|
||||||
|
let out = str::from_utf8(&po.stdout[..]).unwrap().trim_right();
|
||||||
|
let expected = env::current_dir().unwrap().into_os_string().into_string().unwrap();
|
||||||
|
assert_eq!(out, expected);
|
||||||
|
}
|
9
test/true.rs
Normal file
9
test/true.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
static PROGNAME: &'static str = "./true";
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_exit_code() {
|
||||||
|
let exit_status = Command::new(PROGNAME).status().unwrap().success();
|
||||||
|
assert_eq!(exit_status, true);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue