tests: adds tests to verify help and version can be properly overridden

This commit is contained in:
Kevin K 2017-04-04 19:54:20 -04:00
parent 080a9d8bfe
commit 92cc30577d
2 changed files with 27 additions and 1 deletions

View file

@ -831,3 +831,16 @@ fn hidden_default_val() {
.default_value("default-argument"));
assert!(test::compare_output(app2, "default --help", HIDE_DEFAULT_VAL, false));
}
#[test]
fn override_help() {
let m = App::new("test")
.author("Kevin K.")
.about("tests stuff")
.version("1.3")
.arg(Arg::from_usage("-H, --help 'some help'"))
.get_matches_from_safe(vec!["test", "--help"]);
assert!(m.is_ok());
assert!(m.unwrap().is_present("help"));
}

View file

@ -3,7 +3,7 @@ extern crate regex;
use std::str;
use clap::{App, ErrorKind};
use clap::{App, Arg, ErrorKind};
include!("../clap-test.rs");
@ -43,3 +43,16 @@ fn complex_version_output() {
a.write_version(&mut ver).unwrap();
assert_eq!(str::from_utf8(&ver).unwrap(), VERSION);
}
#[test]
fn override_ver() {
let m = App::new("test")
.author("Kevin K.")
.about("tests stuff")
.version("1.3")
.arg(Arg::from_usage("-v, --version 'some version'"))
.get_matches_from_safe(vec!["test", "--version"]);
assert!(m.is_ok());
assert!(m.unwrap().is_present("version"));
}