rluvaton commented on code in PR #10118:
URL: https://github.com/apache/arrow-rs/pull/10118#discussion_r3465496103


##########
arrow-buffer/src/buffer/immutable.rs:
##########
@@ -1080,4 +1093,46 @@ mod tests {
         drop(capture);
         assert_eq!(buffer2.strong_count(), 1);
     }
+
+    #[test]
+    fn 
into_mutable_should_return_error_for_sliced_owned_buffer_when_ptr_offset_is_not_0()
 {
+        let original_buffer_data = [1_u8, 2, 3, 4, 5, 6, 7, 8];
+        for (slice_from, slice_length) in [
+            (original_buffer_data.len(), 0),
+            (2, 4),
+            (2, original_buffer_data.len() - 2),
+        ] {
+            let buffer = Buffer::from(original_buffer_data);
+            let sliced = buffer.slice_with_length(slice_from, slice_length);
+            drop(buffer); // Keep only 1 owner
+            assert_ne!(sliced.ptr_offset(), 0);
+
+            sliced
+                .into_mutable()
+                .expect_err("should not convert sliced buffer when ptr_offset 
is not 0");
+        }
+    }
+
+    #[test]
+    fn 
into_mutable_should_allow_converting_sliced_owned_buffer_when_not_sliced_from_start()
 {

Review Comment:
   not sliced from the start it means that ptr_offset is 0 but still sliced, 
will rename



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to