mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
test: Add test for opting out of Vec<Vec<T>> derive
This commit is contained in:
parent
eaa9273f91
commit
ccce3c3db5
1 changed files with 22 additions and 0 deletions
|
@ -17,6 +17,28 @@ fn test_vec_of_vec() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_vec_of_vec_opt_out() {
|
||||
fn parser(s: &str) -> Result<Vec<Vec<String>>, std::convert::Infallible> {
|
||||
Ok(s.split(':')
|
||||
.map(|v| v.split(',').map(str::to_owned).collect())
|
||||
.collect())
|
||||
}
|
||||
|
||||
#[derive(Parser, PartialEq, Debug)]
|
||||
struct Opt {
|
||||
#[arg(value_parser = parser, short = 'p')]
|
||||
arg: ::std::vec::Vec<Vec<String>>,
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
Opt {
|
||||
arg: vec![vec!["1".into(), "2".into()], vec!["a".into(), "b".into()]],
|
||||
},
|
||||
Opt::try_parse_from(["test", "-p", "1,2:a,b"]).unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_vec_vec_empty() {
|
||||
#[derive(Parser, Debug, PartialEq)]
|
||||
|
|
Loading…
Reference in a new issue