MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / preview_never_splits_a_utf8_character

Function preview_never_splits_a_utf8_character

atomic-remote/src/storage.rs:728–739  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 1

previewFunction · 0.70

Tested by

no test coverage detected