From 1e11a99991064cb8326d42c380374e122029179b Mon Sep 17 00:00:00 2001 From: Fabricio Dematte Date: Mon, 17 May 2021 21:56:22 -0300 Subject: [PATCH] Add unknown short flag test --- oof/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/oof/src/lib.rs b/oof/src/lib.rs index 6621867..2158ae2 100644 --- a/oof/src/lib.rs +++ b/oof/src/lib.rs @@ -239,6 +239,19 @@ mod tests { assert!(!flags.is_present("output_file")); } + #[test] + fn test_unknown_short_flag() { + let flags_info = [ + ArgFlag::long("output_file").short('o'), + Flag::long("verbose").short('v'), + Flag::long("help").short('h'), + ]; + + let args = gen_args("ouch a.zip -s b.tar.gz"); + let result = filter_flags(args, &flags_info).unwrap_err(); + assert!(matches!(result, OofError::UnknownShortFlag('s'))); + } + #[test] fn test_pop_subcommand() { let subcommands = &["commit", "add", "push", "remote"];