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