mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 06:12:40 +00:00
9bd7060089
- ArgSettings are part of #2717 - Errors are part of #2628 - `help_heading` is part of #1807 and #1553 - Some misc parts are for API consistency
44 lines
1.2 KiB
Rust
44 lines
1.2 KiB
Rust
#![allow(deprecated)]
|
|
use clap::{Arg, ArgSettings};
|
|
|
|
#[test]
|
|
fn setting() {
|
|
let m = Arg::new("setting").setting(ArgSettings::Required);
|
|
assert!(m.is_required_set());
|
|
}
|
|
|
|
#[test]
|
|
fn unset_setting() {
|
|
let m = Arg::new("unset_setting").setting(ArgSettings::Required);
|
|
assert!(m.is_required_set());
|
|
|
|
let m = m.unset_setting(ArgSettings::Required);
|
|
assert!(!m.is_required_set(), "{:#?}", m);
|
|
}
|
|
|
|
#[test]
|
|
fn setting_bitor() {
|
|
let m = Arg::new("setting_bitor")
|
|
.setting(ArgSettings::Required | ArgSettings::Hidden | ArgSettings::Last);
|
|
|
|
assert!(m.is_required_set());
|
|
assert!(m.is_hide_set());
|
|
assert!(m.is_last_set());
|
|
}
|
|
|
|
#[test]
|
|
fn unset_setting_bitor() {
|
|
let m = Arg::new("unset_setting_bitor")
|
|
.setting(ArgSettings::Required)
|
|
.setting(ArgSettings::Hidden)
|
|
.setting(ArgSettings::Last);
|
|
|
|
assert!(m.is_required_set());
|
|
assert!(m.is_hide_set());
|
|
assert!(m.is_last_set());
|
|
|
|
let m = m.unset_setting(ArgSettings::Required | ArgSettings::Hidden | ArgSettings::Last);
|
|
assert!(!m.is_required_set(), "{:#?}", m);
|
|
assert!(!m.is_hide_set(), "{:#?}", m);
|
|
assert!(!m.is_last_set(), "{:#?}", m);
|
|
}
|