mirror of
https://github.com/clap-rs/clap
synced 2025-01-18 23:53:54 +00:00
Add test
This commit is contained in:
parent
18a58af3ac
commit
619658e17a
1 changed files with 14 additions and 0 deletions
|
@ -48,3 +48,17 @@ fn test_validator_msg_newline() {
|
|||
let msg = format!("{}", err);
|
||||
assert!(msg.ends_with('\n'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stateful_validator() {
|
||||
let mut state = false;
|
||||
App::new("test")
|
||||
.arg(Arg::new("test").validator(|val| {
|
||||
state = true;
|
||||
val.parse::<u32>().map_err(|e| e.to_string())
|
||||
}))
|
||||
.try_get_matches_from(&["app", "10"])
|
||||
.unwrap();
|
||||
|
||||
assert!(state);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue