2018-01-25 04:05:05 +00:00
|
|
|
#![cfg(feature = "yaml")]
|
2016-01-12 05:13:14 +00:00
|
|
|
|
2015-08-31 03:26:17 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate clap;
|
|
|
|
|
|
|
|
use clap::App;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn create_app_from_yaml() {
|
|
|
|
let yml = load_yaml!("app.yml");
|
|
|
|
App::from_yaml(yml);
|
2016-01-12 05:13:14 +00:00
|
|
|
}
|
2017-03-10 06:52:02 +00:00
|
|
|
|
2018-06-22 11:50:44 +00:00
|
|
|
// TODO: Uncomment to test yaml with 2 spaces https://github.com/chyh1990/yaml-rust/issues/101
|
|
|
|
// #[test]
|
|
|
|
// fn create_app_from_yaml_2spaces() {
|
|
|
|
// let yml = load_yaml!("app_2space.yml");
|
|
|
|
// App::from(yml);
|
|
|
|
// }
|
|
|
|
|
2017-03-10 06:52:02 +00:00
|
|
|
#[test]
|
|
|
|
fn help_message() {
|
|
|
|
let yml = load_yaml!("app.yml");
|
|
|
|
let mut app = App::from_yaml(yml);
|
|
|
|
// Generate the full help message!
|
|
|
|
let _ = app.get_matches_from_safe_borrow(Vec::<String>::new());
|
|
|
|
|
|
|
|
let mut help_buffer = Vec::new();
|
|
|
|
app.write_help(&mut help_buffer).unwrap();
|
|
|
|
let help_string = String::from_utf8(help_buffer).unwrap();
|
2018-01-25 04:05:05 +00:00
|
|
|
assert!(
|
|
|
|
help_string.contains("-h, --help prints help with a nonstandard description\n")
|
|
|
|
);
|
2017-03-10 06:52:02 +00:00
|
|
|
}
|
2017-03-22 07:49:23 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn author() {
|
|
|
|
let yml = load_yaml!("app.yml");
|
|
|
|
let mut app = App::from_yaml(yml);
|
|
|
|
// Generate the full help message!
|
|
|
|
let _ = app.get_matches_from_safe_borrow(Vec::<String>::new());
|
|
|
|
|
|
|
|
let mut help_buffer = Vec::new();
|
|
|
|
app.write_help(&mut help_buffer).unwrap();
|
|
|
|
let help_string = String::from_utf8(help_buffer).unwrap();
|
2018-01-25 04:05:05 +00:00
|
|
|
assert!(help_string.contains("Kevin K. <kbknapp@gmail.com>"));
|
2017-03-22 07:49:23 +00:00
|
|
|
}
|