1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

pathchk implemented (see #841) (#860)

* Added pathchk
This commit is contained in:
ibabushkin 2016-05-22 13:59:57 +02:00 committed by Heather
parent 583ed341a7
commit d504ae18c9
8 changed files with 307 additions and 0 deletions

View file

@ -41,6 +41,15 @@ macro_rules! assert_empty_stderr(
);
);
#[macro_export]
macro_rules! assert_empty_stdout(
($cond:expr) => (
if $cond.stdout.len() > 0 {
panic!(format!("stdout: {}", $cond.stdout))
}
);
);
#[macro_export]
macro_rules! assert_no_error(
($cond:expr) => (
@ -51,6 +60,14 @@ macro_rules! assert_no_error(
);
);
pub fn repeat_str(s: &str, n: u32) -> String {
let mut repeated = String::new();
for _ in 0..n {
repeated.push_str(s);
}
repeated
}
#[macro_export]
macro_rules! path_concat {
($e:expr, ..$n:expr) => {{

25
tests/pathchk.rs Normal file
View file

@ -0,0 +1,25 @@
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "pathchk";
#[test]
fn test_default_mode() {
// test the default mode
{
// accept some reasonable default
let (_, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&["abc/def"]).run();
assert_eq!(result.stdout, "");
assert!(result.success);
}
{
// fail on long inputs
let (_, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.args(&[repeat_str("test", 20000)]).run();
assert_eq!(result.stdout, "");
assert!(!result.success);
}
}