MCPcopy Create free account
hub / github.com/apache/arrow-rs / check_utf8_char_boundary

Function check_utf8_char_boundary

arrow/tests/array_validation.rs:531–548  ·  view source on GitHub ↗

Tests that offsets are at valid codepoint boundaries

(data_type: DataType)

Source from the content-addressed store, hash-verified

529
530/// Tests that offsets are at valid codepoint boundaries
531fn check_utf8_char_boundary<T: ArrowNativeType>(data_type: DataType) {
532 let data_buffer = Buffer::from("🙀".as_bytes());
533 let offsets: Vec<T> = [0, 1, data_buffer.len()]
534 .iter()
535 .map(|&v| T::from_usize(v).unwrap())
536 .collect();
537
538 let offsets_buffer = Buffer::from_slice_ref(offsets);
539 ArrayData::try_new(
540 data_type,
541 2,
542 None,
543 0,
544 vec![offsets_buffer, data_buffer],
545 vec![],
546 )
547 .unwrap();
548}
549
550#[test]
551#[should_panic(expected = "incomplete utf-8 byte sequence from index 0")]

Callers

nothing calls this directly

Calls 5

try_newFunction · 0.85
collectMethod · 0.80
as_bytesMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected