clap/tests/derive/explicit_name_no_renaming.rs
Ed Page b190a6a817 test: Consolidate clap tests
This reduces the need for us to have `clap` as a dependency in
`clap_derive`, preparing the way to fix #15.
2021-11-30 10:07:08 -06:00

36 lines
733 B
Rust

use crate::utils;
use clap::Parser;
#[test]
fn explicit_short_long_no_rename() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short = '.', long = ".foo")]
foo: String,
}
assert_eq!(
Opt { foo: "long".into() },
Opt::try_parse_from(&["test", "--.foo", "long"]).unwrap()
);
assert_eq!(
Opt {
foo: "short".into(),
},
Opt::try_parse_from(&["test", "-.", "short"]).unwrap()
);
}
#[test]
fn explicit_name_no_rename() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(name = ".options")]
foo: String,
}
let help = utils::get_long_help::<Opt>();
assert!(help.contains("<.options>"))
}