mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 23:37:32 +00:00
Add yaml multiple_* tests
This commit is contained in:
parent
8e1a2e1114
commit
a995e5a204
2 changed files with 27 additions and 0 deletions
9
tests/fixtures/app.yaml
vendored
9
tests/fixtures/app.yaml
vendored
|
@ -79,6 +79,10 @@ args:
|
|||
multiple: true
|
||||
use_delimiter: true
|
||||
require_delimiter: true
|
||||
- settings:
|
||||
short: s
|
||||
takes_value: true
|
||||
multiple_values: true
|
||||
- singlealias:
|
||||
long: singlealias
|
||||
about: Tests single alias
|
||||
|
@ -122,6 +126,11 @@ args:
|
|||
long: value-hint
|
||||
help: Test value_hint
|
||||
value_hint: FilePath
|
||||
- verbose:
|
||||
short: v
|
||||
multiple_occurrences: true
|
||||
takes_value: false
|
||||
help: Sets the level of verbosity
|
||||
- visiblealiases:
|
||||
long: visiblealiases
|
||||
about: Tests visible aliases
|
||||
|
|
|
@ -100,6 +100,24 @@ fn default_value_if_triggered_by_flag_and_argument() {
|
|||
assert_eq!(matches.value_of("positional2").unwrap(), "some");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn yaml_multiple_occurrences() {
|
||||
let yaml = load_yaml!("fixtures/app.yaml");
|
||||
let matches = App::from(yaml)
|
||||
.try_get_matches_from(vec!["prog", "-vvv"])
|
||||
.unwrap();
|
||||
assert_eq!(matches.occurrences_of("verbose"), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn yaml_multiple_values() {
|
||||
let yaml = load_yaml!("fixtures/app.yaml");
|
||||
let matches = App::from(yaml)
|
||||
.try_get_matches_from(vec!["prog", "-s", "aaa", "bbb"])
|
||||
.unwrap();
|
||||
assert_eq!(matches.values_of("settings").unwrap().collect::<Vec<&str>>(), vec!["aaa", "bbb"]);
|
||||
}
|
||||
|
||||
#[cfg(feature = "regex")]
|
||||
#[test]
|
||||
fn regex_with_invalid_string() {
|
||||
|
|
Loading…
Add table
Reference in a new issue