1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Add initial tests for dirname.

This commit is contained in:
Joseph Crail 2015-05-09 15:16:45 -04:00
parent 39de3f7b71
commit e700e0d2f4
2 changed files with 29 additions and 0 deletions

View file

@ -161,6 +161,7 @@ TEST_PROGS := \
cat \
cp \
env \
dirname \
factor \
fold \
mkdir \

28
test/dirname.rs Normal file
View 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");
}