MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / utf16_cols_match_counting

Function utf16_cols_match_counting

codegraph-kernel/src/textutil.rs:273–286  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

271 /// counting the line's characters gives.
272 #[test]
273 fn utf16_cols_match_counting() {
274 let src = "plain ascii\naé😀b — ü\n\n日本語 x 😀😀\nlast";
275 let starts = line_starts(src);
276 for (row, &start) in starts.iter().enumerate() {
277 let end = starts.get(row + 1).map_or(src.len(), |next| next - 1);
278 for (offset, _) in src[start..end].char_indices().chain([(end - start, ' ')]) {
279 let counted = utf16_len(&src[start..start + offset]) as u32;
280 assert_eq!(col16(src, &starts, row, start + offset), counted, "row {row} offset {offset}");
281 }
282 }
283 // Before a line's start, or on a row the source does not have: 0, and the offset itself.
284 assert_eq!(col16(src, &starts, 1, 3), 0);
285 assert_eq!(col16("abc", &line_starts("abc"), 9, 2), 2);
286 }
287
288 #[test]
289 fn init_sig_short_and_long() {

Callers

nothing calls this directly

Calls 4

utf16_lenFunction · 0.85
lenMethod · 0.80
line_startsFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected