()
| 726 | /// Every offset across a multi-byte boundary must be safe. |
| 727 | #[test] |
| 728 | fn preview_never_splits_a_utf8_character() { |
| 729 | // "é" is two bytes, "→" three, "🔒" four — so every truncation length |
| 730 | // walks through the middle of some character. |
| 731 | let body = "é→🔒".repeat(200); |
| 732 | for max in 0..64 { |
| 733 | let out = preview(&body, max); |
| 734 | assert!( |
| 735 | out.len() <= body.len() + 32, |
| 736 | "preview should not grow the input" |
| 737 | ); |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | #[test] |
| 742 | fn preview_handles_multibyte_at_exact_limit() { |