improvise-711n: pin that a multibyte format string cannot split a char boundary

`format:` is `rest_of_line` in `improv.pest`, so the format string can hold any
text. `leading_digits` slices at the byte index `str::find` returns, which is a
char boundary by construction — but that is an argument, and this is the test.
It also pins that a non-ASCII digit (U+0662) names no precision rather than one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FC2jVn8Au7E9JPkw6bwXXH
This commit is contained in:
Edward Langley
2026-09-21 10:19:14 -07:00
parent e045f9871b
commit aa06a9db84
+9
View File
@@ -131,6 +131,15 @@ mod tests {
assert_eq!(parse_number_format(",.999f"), (true, 0));
}
/// `format:` is `rest_of_line` in the grammar, so the format string can hold
/// any text at all — including a multibyte char right after the dot.
#[test]
fn a_multibyte_character_after_the_dot_does_not_split_a_char_boundary() {
assert_eq!(parse_number_format(",.2\u{20ac}"), (true, 2));
assert_eq!(parse_number_format(".\u{20ac}"), (false, 0));
assert_eq!(parse_number_format(".\u{0662}"), (false, 0));
}
#[test]
fn a_format_naming_no_precision_at_all_reads_as_zero() {
assert_eq!(parse_number_format(",f"), (true, 0));