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

Function test_validation_of_invalid_string_array

arrow-ipc/src/reader.rs:3286–3305  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3284
3285 #[test]
3286 fn test_validation_of_invalid_string_array() {
3287 let valid: &[u8] = b" ";
3288 let mut invalid = vec![];
3289 invalid.extend_from_slice(b"ThisStringIsCertainlyLongerThan12Bytes");
3290 invalid.extend_from_slice(INVALID_UTF8_FIRST_CHAR);
3291 let binary_array = BinaryArray::from_iter(vec![None, Some(valid), None, Some(&invalid)]);
3292 // data is not valid utf8 we can not construct a correct StringArray
3293 // safely, so purposely create an invalid StringArray
3294 let array = unsafe {
3295 StringArray::new_unchecked(
3296 binary_array.offsets().clone(),
3297 binary_array.values().clone(),
3298 binary_array.nulls().cloned(),
3299 )
3300 };
3301 expect_ipc_validation_error(
3302 Arc::new(array),
3303 "Invalid argument error: Invalid UTF8 sequence at string index 3 (3..45): invalid utf-8 sequence of 1 bytes from index 38",
3304 );
3305 }
3306
3307 #[test]
3308 fn test_validation_of_invalid_string_view_array() {

Callers

nothing calls this directly

Calls 7

extend_from_sliceMethod · 0.80
from_iterFunction · 0.50
cloneMethod · 0.45
offsetsMethod · 0.45
valuesMethod · 0.45
nullsMethod · 0.45

Tested by

no test coverage detected