test(args): add negative test cases

This commit is contained in:
steven-omaha
2023-10-17 15:37:57 +02:00
parent 87a85b00dd
commit bcf43a8683
+11
View File
@@ -25,3 +25,14 @@ fn arg_parsing(#[case] input: Vec<&str>, #[case] expected: Arguments) {
assert_eq!(parsed, expected); assert_eq!(parsed, expected);
} }
#[rstest]
#[should_panic]
#[case(vec!["pacdef", "package", "search"], "regex missing")]
#[should_panic]
#[case(vec!["pacdef", "p", "s"], "can be either 'sync' or 'search'")]
#[should_panic]
#[case(vec!["pacdef", "group", "edit"], "group missing")]
fn arg_parsing_invalid(#[case] input: Vec<&str>, #[case] err_msg: &str) {
build_cli().try_get_matches_from(input).expect(err_msg);
}