Skip to content

Commit

Permalink
Merge pull request #68 from prataprc/issue_51
Browse files Browse the repository at this point in the history
test case to check opt_present() panic for undefined options #51.
  • Loading branch information
KodrAus committed May 27, 2018
2 parents 626a43b + dd5db94 commit 08af2e5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib.rs
Expand Up @@ -2006,4 +2006,16 @@ Options:
let mut opts = Options::new();
opts.optflag("", "a", "Oops, long option too short");
}

#[test]
#[should_panic]
fn test_undefined_opt_present() {
let mut opts = Options::new();
opts.optflag("h", "help", "Description");
let args = vec!["-h"];
match opts.parse(args) {
Ok(matches) => assert!(!matches.opt_present("undefined")),
Err(e) => panic!("{}", e)
}
}
}

0 comments on commit 08af2e5

Please sign in to comment.