From 45d26e0013527e6653403311efceeb4dc671199f Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 11 Nov 2022 12:22:30 -0600 Subject: [PATCH] test(parser): Show UTF8 bug --- tests/builder/utf8.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/builder/utf8.rs b/tests/builder/utf8.rs index 03f8e9f2..08e6cf50 100644 --- a/tests/builder/utf8.rs +++ b/tests/builder/utf8.rs @@ -100,6 +100,29 @@ fn invalid_utf8_strict_option_long_equals() { assert_eq!(m.unwrap_err().kind(), ErrorKind::InvalidUtf8); } +#[test] +fn invalid_utf8_strict_invalid_short() { + let m = Command::new("bad_utf8").try_get_matches_from(vec![ + OsString::from(""), + OsString::from("-a"), + OsString::from_vec(vec![0xe9]), + ]); + assert!(m.is_err()); + assert_eq!(m.unwrap_err().kind(), ErrorKind::UnknownArgument); +} + +#[test] +#[should_panic] +fn invalid_utf8_strict_invalid_long() { + let m = Command::new("bad_utf8").try_get_matches_from(vec![ + OsString::from(""), + OsString::from("--arg"), + OsString::from_vec(vec![0xe9]), + ]); + assert!(m.is_err()); + assert_eq!(m.unwrap_err().kind(), ErrorKind::UnknownArgument); +} + #[test] fn invalid_utf8_positional() { let r = Command::new("bad_utf8")