mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
78e4c90326
In experimenting on #1772, I want to write test cases for various combinations of required or not, values vs occurrences, etc. There wasn't really a clear place to put these. On top of that, I wanted there to be a clear place in the tests for describing the behavior of special types, to make it easier to audit and easier to see how a PR for #1772 changes things. As part of this effort in organizing these tests, I reduced the number of tests that use special types. This better focuses these tests on the cases they are intending to cover, rather than pulling in unrelated features. This makes it easier to audit special types and makes it so failures give more focused results, making it easier to see what broke.
24 lines
459 B
Rust
24 lines
459 B
Rust
use clap::Parser;
|
|
|
|
#[test]
|
|
fn raw_idents() {
|
|
#[derive(Parser, Debug, PartialEq)]
|
|
struct Opt {
|
|
#[clap(short, long)]
|
|
r#type: String,
|
|
}
|
|
|
|
assert_eq!(
|
|
Opt {
|
|
r#type: "long".into()
|
|
},
|
|
Opt::try_parse_from(&["test", "--type", "long"]).unwrap()
|
|
);
|
|
|
|
assert_eq!(
|
|
Opt {
|
|
r#type: "short".into()
|
|
},
|
|
Opt::try_parse_from(&["test", "-t", "short"]).unwrap()
|
|
);
|
|
}
|