Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
CreepySkeleton committed Jul 3, 2020
1 parent 95c1178 commit b596f31
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,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);
}

0 comments on commit b596f31

Please sign in to comment.