Skip to content

Commit

Permalink
test: adds test to demonstrate regression
Browse files Browse the repository at this point in the history
  • Loading branch information
plaflamme committed Mar 7, 2022
1 parent 2bd3dd7 commit ca6ac8a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/derive/arg_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,39 @@ fn option_vec_type() {
);
assert!(Opt::try_parse_from(&["", "-a", "fOo"]).is_err());
}

#[test]
fn vec_type_default_value() {
#[derive(clap::ArgEnum, PartialEq, Debug, Clone)]
enum ArgChoice {
Foo,
Bar,
Baz,
}

#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(
arg_enum,
short,
long,
default_value = "foo,bar",
value_delimiter = ','
)]
arg: Vec<ArgChoice>,
}

assert_eq!(
Opt {
arg: vec![ArgChoice::Foo, ArgChoice::Bar]
},
Opt::try_parse_from(&[""]).unwrap()
);

assert_eq!(
Opt {
arg: vec![ArgChoice::Foo, ArgChoice::Baz]
},
Opt::try_parse_from(&["", "-a", "foo,baz"]).unwrap()
);
}

0 comments on commit ca6ac8a

Please sign in to comment.