mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 23:02:31 +00:00
045bf99ae0
This is prep for moving the derive tests. Besides organizing the test folder for each API, this should reduce link time at the cost of re-compiling more when a test changes.
43 lines
1.3 KiB
Rust
43 lines
1.3 KiB
Rust
use clap::{Arg, ArgSettings};
|
|
|
|
#[test]
|
|
fn setting() {
|
|
let m = Arg::new("setting").setting(ArgSettings::Required);
|
|
assert!(m.is_set(ArgSettings::Required));
|
|
}
|
|
|
|
#[test]
|
|
fn unset_setting() {
|
|
let m = Arg::new("unset_setting").setting(ArgSettings::Required);
|
|
assert!(m.is_set(ArgSettings::Required));
|
|
|
|
let m = m.unset_setting(ArgSettings::Required);
|
|
assert!(!m.is_set(ArgSettings::Required), "{:#?}", m);
|
|
}
|
|
|
|
#[test]
|
|
fn setting_bitor() {
|
|
let m = Arg::new("setting_bitor")
|
|
.setting(ArgSettings::Required | ArgSettings::Hidden | ArgSettings::Last);
|
|
|
|
assert!(m.is_set(ArgSettings::Required));
|
|
assert!(m.is_set(ArgSettings::Hidden));
|
|
assert!(m.is_set(ArgSettings::Last));
|
|
}
|
|
|
|
#[test]
|
|
fn unset_setting_bitor() {
|
|
let m = Arg::new("unset_setting_bitor")
|
|
.setting(ArgSettings::Required)
|
|
.setting(ArgSettings::Hidden)
|
|
.setting(ArgSettings::Last);
|
|
|
|
assert!(m.is_set(ArgSettings::Required));
|
|
assert!(m.is_set(ArgSettings::Hidden));
|
|
assert!(m.is_set(ArgSettings::Last));
|
|
|
|
let m = m.unset_setting(ArgSettings::Required | ArgSettings::Hidden | ArgSettings::Last);
|
|
assert!(!m.is_set(ArgSettings::Required), "{:#?}", m);
|
|
assert!(!m.is_set(ArgSettings::Hidden), "{:#?}", m);
|
|
assert!(!m.is_set(ArgSettings::Last), "{:#?}", m);
|
|
}
|