test(help): Veriy rendering of min_values

This commit is contained in:
Ed Page 2022-07-28 13:33:42 -05:00
parent ef9d582464
commit 2be2924f91

View file

@ -4678,7 +4678,53 @@ mod test {
} }
#[test] #[test]
fn option_display2() { fn option_display_zero_or_more_values() {
let mut o = Arg::new("opt")
.long("option")
.action(ArgAction::Set)
.min_values(0);
o._build();
assert_eq!(o.to_string(), "--option [<opt>...]");
}
#[test]
fn option_display_one_or_more_values() {
let mut o = Arg::new("opt")
.long("option")
.action(ArgAction::Set)
.min_values(1);
o._build();
assert_eq!(o.to_string(), "--option <opt>...");
}
#[test]
fn option_display_zero_or_more_values_with_value_name() {
let mut o = Arg::new("opt")
.short('o')
.action(ArgAction::Set)
.min_values(0)
.value_names(&["file"]);
o._build();
assert_eq!(o.to_string(), "-o [<file>...]");
}
#[test]
fn option_display_one_or_more_values_with_value_name() {
let mut o = Arg::new("opt")
.short('o')
.action(ArgAction::Set)
.min_values(1)
.value_names(&["file"]);
o._build();
assert_eq!(o.to_string(), "-o <file>...");
}
#[test]
fn option_display_value_names() {
let mut o = Arg::new("opt") let mut o = Arg::new("opt")
.short('o') .short('o')
.action(ArgAction::Set) .action(ArgAction::Set)
@ -4756,6 +4802,22 @@ mod test {
assert_eq!(p.to_string(), "<pos>..."); assert_eq!(p.to_string(), "<pos>...");
} }
#[test]
fn positional_display_zero_or_more_values() {
let mut p = Arg::new("pos").index(1).min_values(0);
p._build();
assert_eq!(p.to_string(), "[<pos>...]");
}
#[test]
fn positional_display_one_or_more_values() {
let mut p = Arg::new("pos").index(1).min_values(1);
p._build();
assert_eq!(p.to_string(), "<pos>...");
}
#[test] #[test]
fn positional_display_multiple_occurrences() { fn positional_display_multiple_occurrences() {
let mut p = Arg::new("pos").index(1).action(ArgAction::Append); let mut p = Arg::new("pos").index(1).action(ArgAction::Append);