1use crate::Arg;
2use crate::Command;
3
4#[test]
5fn propagate_version() {
6 let mut cmd = Command::new("test")
7 .propagate_version(true)
8 .version("1.1")
9 .subcommand(Command::new("sub1"));
10 cmd._propagate();
11 assert_eq!(
12 cmd.get_subcommands().next().unwrap().get_version(),
13 Some("1.1")
14 );
15}
16
17#[test]
18fn global_setting() {
19 let mut cmd = Command::new("test")
20 .disable_version_flag(true)
21 .subcommand(Command::new("subcmd"));
22 cmd._propagate();
23 assert!(cmd
24 .get_subcommands()
25 .find(|s| s.get_name() == "subcmd")
26 .unwrap()
27 .is_disable_version_flag_set());
28}
29
30// This test will *fail to compile* if Command is not Send + Sync
31#[test]
32fn app_send_sync() {
33 fn foo<T: Send + Sync>(_: T) {}
34 foo(Command::new("test"))
35}
36
37#[test]
38fn issue_2090() {
39 let mut cmd = Command::new("cmd")
40 .disable_version_flag(true)
41 .subcommand(Command::new("sub"));
42 cmd._build_self(false);
43
44 assert!(cmd
45 .get_subcommands()
46 .next()
47 .unwrap()
48 .is_disable_version_flag_set());
49}
50
51// This test will *fail to compile* if Arg is not Send + Sync
52#[test]
53fn arg_send_sync() {
54 fn foo<T: Send + Sync>(_: T) {}
55 foo(Arg::new("test"))
56}
57