Takes too long
()
| 339 | #[test] |
| 340 | #[cfg_attr(miri, ignore)] // Takes too long |
| 341 | fn test_sliced_run_array_iterator() { |
| 342 | let total_len = 80; |
| 343 | let input_array = build_input_array(total_len); |
| 344 | |
| 345 | // Encode the input_array to run array |
| 346 | let mut builder = |
| 347 | PrimitiveRunBuilder::<Int16Type, Int32Type>::with_capacity(input_array.len()); |
| 348 | builder.extend(input_array.iter().copied()); |
| 349 | let run_array = builder.finish(); |
| 350 | |
| 351 | // test for all slice lengths. |
| 352 | for slice_len in 1..=total_len { |
| 353 | // test for offset = 0, slice length = slice_len |
| 354 | let sliced_run_array: RunArray<Int16Type> = |
| 355 | run_array.slice(0, slice_len).into_data().into(); |
| 356 | let sliced_typed_run_array = sliced_run_array |
| 357 | .downcast::<PrimitiveArray<Int32Type>>() |
| 358 | .unwrap(); |
| 359 | |
| 360 | // Iterate on sliced typed run array |
| 361 | let actual: Vec<Option<i32>> = sliced_typed_run_array.into_iter().collect(); |
| 362 | let expected: Vec<Option<i32>> = input_array.iter().take(slice_len).copied().collect(); |
| 363 | assert_eq!(expected, actual); |
| 364 | |
| 365 | // test for offset = total_len - slice_len, length = slice_len |
| 366 | let sliced_run_array: RunArray<Int16Type> = run_array |
| 367 | .slice(total_len - slice_len, slice_len) |
| 368 | .into_data() |
| 369 | .into(); |
| 370 | let sliced_typed_run_array = sliced_run_array |
| 371 | .downcast::<PrimitiveArray<Int32Type>>() |
| 372 | .unwrap(); |
| 373 | |
| 374 | // Iterate on sliced typed run array |
| 375 | let actual: Vec<Option<i32>> = sliced_typed_run_array.into_iter().collect(); |
| 376 | let expected: Vec<Option<i32>> = input_array |
| 377 | .iter() |
| 378 | .skip(total_len - slice_len) |
| 379 | .copied() |
| 380 | .collect(); |
| 381 | assert_eq!(expected, actual); |
| 382 | } |
| 383 | } |
| 384 | } |