tests: adds tests to ensure borrowed args don't break

This commit is contained in:
Kevin K 2017-02-27 23:36:11 -05:00
parent 0a922e5f61
commit 677f323bce
No known key found for this signature in database
GPG key ID: 17218E4B3692F01A

19
tests/borrowed.rs Normal file
View file

@ -0,0 +1,19 @@
extern crate clap;
extern crate regex;
use clap::{App, Arg, SubCommand};
include!("../clap-test.rs");
#[test]
fn borrowed_args() {
let arg = Arg::with_name("some").short("s").long("some").help("other help");
let arg2 = Arg::with_name("some2").short("S").long("some-thing").help("other help");
let result = App::new("sub_command_negate")
.arg(Arg::with_name("test").index(1))
.arg(&arg)
.arg(&arg2)
.subcommand(SubCommand::with_name("sub1").arg(&arg))
.get_matches_from_safe(vec!["prog"]);
assert!(result.is_ok());
}