Skip to content

Commit 08af2e5

Browse files
authored
Merge pull request #68 from prataprc/issue_51
test case to check opt_present() panic for undefined options #51.
2 parents 626a43b + dd5db94 commit 08af2e5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,4 +2006,16 @@ Options:
20062006
let mut opts = Options::new();
20072007
opts.optflag("", "a", "Oops, long option too short");
20082008
}
2009+
2010+
#[test]
2011+
#[should_panic]
2012+
fn test_undefined_opt_present() {
2013+
let mut opts = Options::new();
2014+
opts.optflag("h", "help", "Description");
2015+
let args = vec!["-h"];
2016+
match opts.parse(args) {
2017+
Ok(matches) => assert!(!matches.opt_present("undefined")),
2018+
Err(e) => panic!("{}", e)
2019+
}
2020+
}
20092021
}

0 commit comments

Comments
 (0)