Add yaml multiple_* tests

This commit is contained in:
liudingming 2021-05-07 14:32:34 +08:00
parent 8e1a2e1114
commit a995e5a204
2 changed files with 27 additions and 0 deletions

View file

@ -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

View file

@ -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() {