1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

printf: add error handling to escaped unicode characters

This commit is contained in:
Joseph Jon Booker 2025-04-05 21:36:40 -05:00
parent b10aa47e38
commit ef7a8c300e
4 changed files with 128 additions and 28 deletions

View file

@ -112,6 +112,26 @@ fn escaped_unicode_null_byte() {
.stdout_is_bytes([1u8, b'_']);
}
#[test]
fn escaped_unicode_incomplete() {
for arg in ["\\u", "\\U", "\\uabc", "\\Uabcd"] {
new_ucmd!()
.arg(arg)
.fails_with_code(1)
.stderr_only("printf: missing hexadecimal number in escape\n");
}
}
#[test]
fn escaped_unicode_invalid() {
for arg in ["\\ud9d0", "\\U0000D8F9"] {
new_ucmd!().arg(arg).fails_with_code(1).stderr_only(format!(
"printf: invalid universal character name {}\n",
arg
));
}
}
#[test]
fn escaped_percent_sign() {
new_ucmd!()