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

Function test_sliced_array_child

arrow/tests/array_validation.rs:1092–1117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1090#[test]
1091#[cfg(not(feature = "force_validate"))]
1092fn test_sliced_array_child() {
1093 let values = Int32Array::from_iter_values([1, 2, 3]);
1094 let values_sliced = values.slice(1, 2);
1095 let offsets = Buffer::from_iter([1_i32, 3_i32]);
1096
1097 let list_field = Field::new("element", DataType::Int32, false);
1098 let data_type = DataType::List(Arc::new(list_field));
1099
1100 let data = unsafe {
1101 ArrayData::new_unchecked(
1102 data_type,
1103 1,
1104 None,
1105 None,
1106 0,
1107 vec![offsets],
1108 vec![values_sliced.into_data()],
1109 )
1110 };
1111
1112 let err = data.validate_values().unwrap_err();
1113 assert_eq!(
1114 err.to_string(),
1115 "Invalid argument error: Offset invariant failure: offset at position 1 out of bounds: 3 > 2"
1116 );
1117}

Callers

nothing calls this directly

Calls 4

validate_valuesMethod · 0.80
from_iterFunction · 0.50
ListClass · 0.50
sliceMethod · 0.45

Tested by

no test coverage detected