mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
Add initial tests for dirname.
This commit is contained in:
parent
39de3f7b71
commit
e700e0d2f4
2 changed files with 29 additions and 0 deletions
1
Makefile
1
Makefile
|
@ -161,6 +161,7 @@ TEST_PROGS := \
|
||||||
cat \
|
cat \
|
||||||
cp \
|
cp \
|
||||||
env \
|
env \
|
||||||
|
dirname \
|
||||||
factor \
|
factor \
|
||||||
fold \
|
fold \
|
||||||
mkdir \
|
mkdir \
|
||||||
|
|
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");
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue