mirror of
https://github.com/clap-rs/clap
synced 2024-12-15 15:22:30 +00:00
tests: adds a check_output2 function to compare output to one of two possible solutions
This commit is contained in:
parent
6f25b2830a
commit
79c36396db
1 changed files with 10 additions and 0 deletions
10
clap-test.rs
10
clap-test.rs
|
@ -39,6 +39,16 @@ mod test {
|
||||||
assert_eq!(stderr, err.use_stderr());
|
assert_eq!(stderr, err.use_stderr());
|
||||||
compare(left, right)
|
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::<Vec<_>>());
|
||||||
|
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
|
// Legacy tests from the pyhton script days
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue