diff --git a/clap-test.rs b/clap-test.rs index 2f91b9e8..3e01edee 100644 --- a/clap-test.rs +++ b/clap-test.rs @@ -39,6 +39,16 @@ mod test { assert_eq!(stderr, err.use_stderr()); compare(left, right) } + pub fn compare_output2(l: App, args: &str, right1: &str, right2: &str, stderr: bool) -> bool { + let mut buf = Cursor::new(Vec::with_capacity(50)); + let res = l.get_matches_from_safe(args.split(' ').collect::>()); + let err = res.unwrap_err(); + err.write_to(&mut buf).unwrap(); + let content = buf.into_inner(); + let left = String::from_utf8(content).unwrap(); + assert_eq!(stderr, err.use_stderr()); + compare(&*left, right1) || compare(&*left, right2) + } // Legacy tests from the pyhton script days