()
| 2517 | |
| 2518 | #[test] |
| 2519 | fn test_equality() { |
| 2520 | let int_data = ArrayData::builder(DataType::Int32) |
| 2521 | .len(1) |
| 2522 | .add_buffer(make_i32_buffer(1)) |
| 2523 | .build() |
| 2524 | .unwrap(); |
| 2525 | |
| 2526 | let float_data = ArrayData::builder(DataType::Float32) |
| 2527 | .len(1) |
| 2528 | .add_buffer(make_f32_buffer(1)) |
| 2529 | .build() |
| 2530 | .unwrap(); |
| 2531 | assert_ne!(int_data, float_data); |
| 2532 | assert!(!int_data.ptr_eq(&float_data)); |
| 2533 | assert!(int_data.ptr_eq(&int_data)); |
| 2534 | |
| 2535 | #[allow(clippy::redundant_clone)] |
| 2536 | let int_data_clone = int_data.clone(); |
| 2537 | assert_eq!(int_data, int_data_clone); |
| 2538 | assert!(int_data.ptr_eq(&int_data_clone)); |
| 2539 | assert!(int_data_clone.ptr_eq(&int_data)); |
| 2540 | |
| 2541 | let int_data_slice = int_data_clone.slice(1, 0); |
| 2542 | assert!(int_data_slice.ptr_eq(&int_data_slice)); |
| 2543 | assert!(!int_data.ptr_eq(&int_data_slice)); |
| 2544 | assert!(!int_data_slice.ptr_eq(&int_data)); |
| 2545 | |
| 2546 | let data_buffer = Buffer::from_slice_ref("abcdef".as_bytes()); |
| 2547 | let offsets_buffer = Buffer::from_slice_ref([0_i32, 2_i32, 2_i32, 5_i32]); |
| 2548 | let string_data = ArrayData::try_new( |
| 2549 | DataType::Utf8, |
| 2550 | 3, |
| 2551 | Some(Buffer::from_iter(vec![true, false, true])), |
| 2552 | 0, |
| 2553 | vec![offsets_buffer, data_buffer], |
| 2554 | vec![], |
| 2555 | ) |
| 2556 | .unwrap(); |
| 2557 | |
| 2558 | assert_ne!(float_data, string_data); |
| 2559 | assert!(!float_data.ptr_eq(&string_data)); |
| 2560 | |
| 2561 | assert!(string_data.ptr_eq(&string_data)); |
| 2562 | |
| 2563 | #[allow(clippy::redundant_clone)] |
| 2564 | let string_data_cloned = string_data.clone(); |
| 2565 | assert!(string_data_cloned.ptr_eq(&string_data)); |
| 2566 | assert!(string_data.ptr_eq(&string_data_cloned)); |
| 2567 | |
| 2568 | let string_data_slice = string_data.slice(1, 2); |
| 2569 | assert!(string_data_slice.ptr_eq(&string_data_slice)); |
| 2570 | assert!(!string_data_slice.ptr_eq(&string_data)) |
| 2571 | } |
| 2572 | |
| 2573 | #[test] |
| 2574 | fn test_slice_memory_size() { |
nothing calls this directly
no test coverage detected