forked from clap-rs/clap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.rs
32 lines (29 loc) · 933 Bytes
/
tests.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
use super::{settings::ArgSettings, Arg};
#[test]
fn short_flag_misspell() {
let a = Arg::from("-f1, --flag 'some flag'");
assert_eq!(a.name, "flag");
assert_eq!(a.short.unwrap(), 'f');
assert_eq!(a.long.unwrap(), "flag");
assert_eq!(a.about.unwrap(), "some flag");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.val_names.is_empty());
assert!(a.num_vals.is_none());
}
#[test]
fn short_flag_name_missing() {
let a = Arg::from("-f 'some flag'");
assert_eq!(a.name, "f");
assert_eq!(a.short.unwrap(), 'f');
assert!(a.long.is_none());
assert_eq!(a.about.unwrap(), "some flag");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.val_names.is_empty());
assert!(a.num_vals.is_none());
}
// This test will *fail to compile* if Arg is not Send + Sync
#[test]
fn arg_send_sync() {
fn foo<T: Send + Sync>(_: T) {}
foo(Arg::new("test"))
}