use arrow2::{ array::Utf8Array, bitmap::Bitmap, buffer::Buffer, datatypes::DataType, offset::OffsetsBuffer, }; #[test] fn not_shared() { let array = Utf8Array::::from([Some("hello"), Some(" "), None]); assert!(array.into_mut().is_right()); } #[test] #[allow(clippy::redundant_clone)] fn shared_validity() { let validity = Bitmap::from([true]); let array = Utf8Array::::new( DataType::Utf8, vec![0, 1].try_into().unwrap(), b"a".to_vec().into(), Some(validity.clone()), ); assert!(array.into_mut().is_left()) } #[test] #[allow(clippy::redundant_clone)] fn shared_values() { let values: Buffer = b"a".to_vec().into(); let array = Utf8Array::::new( DataType::Utf8, vec![0, 1].try_into().unwrap(), values.clone(), Some(Bitmap::from([true])), ); assert!(array.into_mut().is_left()) } #[test] #[allow(clippy::redundant_clone)] fn shared_offsets_values() { let offsets: OffsetsBuffer = vec![0, 1].try_into().unwrap(); let values: Buffer = b"a".to_vec().into(); let array = Utf8Array::::new( DataType::Utf8, offsets.clone(), values.clone(), Some(Bitmap::from([true])), ); assert!(array.into_mut().is_left()) } #[test] #[allow(clippy::redundant_clone)] fn shared_offsets() { let offsets: OffsetsBuffer = vec![0, 1].try_into().unwrap(); let array = Utf8Array::::new( DataType::Utf8, offsets.clone(), b"a".to_vec().into(), Some(Bitmap::from([true])), ); assert!(array.into_mut().is_left()) } #[test] #[allow(clippy::redundant_clone)] fn shared_all() { let array = Utf8Array::::from([Some("hello"), Some(" "), None]); assert!(array.clone().into_mut().is_left()) }