mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +00:00
tests: adds tests to verify help and version can be properly overridden
This commit is contained in:
parent
080a9d8bfe
commit
92cc30577d
2 changed files with 27 additions and 1 deletions
|
@ -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"));
|
||||
}
|
|
@ -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"));
|
||||
}
|
Loading…
Reference in a new issue