mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
parent
583ed341a7
commit
d504ae18c9
8 changed files with 307 additions and 0 deletions
|
@ -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
25
tests/pathchk.rs
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue