forked from clap-rs/clap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
occurrences.rs
62 lines (54 loc) · 1.31 KB
/
occurrences.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#![cfg(feature = "unstable-grouped")]
use clap::Parser;
#[test]
fn test_vec_of_vec() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[arg(short = 'p', num_args = 2)]
points: Vec<Vec<i32>>,
}
assert_eq!(
Opt {
points: vec![vec![1, 2], vec![0, 0]]
},
Opt::try_parse_from(&["test", "-p", "1", "2", "-p", "0", "0"]).unwrap()
);
}
#[test]
fn test_vec_vec_empty() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[arg(short = 'p', num_args = 2)]
points: Vec<Vec<i32>>,
}
assert_eq!(
Opt { points: vec![] },
Opt::try_parse_from(&["test"]).unwrap()
);
}
#[test]
fn test_option_vec_vec() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[arg(short = 'p', num_args = 2)]
points: Option<Vec<Vec<i32>>>,
}
assert_eq!(
Opt {
points: Some(vec![vec![1, 2], vec![3, 4]])
},
Opt::try_parse_from(&["test", "-p", "1", "2", "-p", "3", "4"]).unwrap()
);
}
#[test]
fn test_option_vec_vec_empty() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[arg(short = 'p', num_args = 2)]
points: Option<Vec<Vec<i32>>>,
}
assert_eq!(
Opt { points: None },
Opt::try_parse_from(&["test"]).unwrap()
);
}