From 677f323bcefc8ccebfff15cb5fbce4352ed021e2 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Mon, 27 Feb 2017 23:36:11 -0500 Subject: [PATCH] tests: adds tests to ensure borrowed args don't break --- tests/borrowed.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/borrowed.rs diff --git a/tests/borrowed.rs b/tests/borrowed.rs new file mode 100644 index 00000000..e7a184b5 --- /dev/null +++ b/tests/borrowed.rs @@ -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()); +}