alamb commented on code in PR #3326:
URL: https://github.com/apache/arrow-rs/pull/3326#discussion_r1052593539


##########
arrow-array/src/array/string_array.rs:
##########
@@ -697,4 +698,40 @@ mod tests {
         assert_eq!(string.len(), 0);
         assert_eq!(string.value_offsets(), &[0]);
     }
+
+    #[test]
+    fn test_into_builder() {
+        let array: StringArray = vec!["hello", "arrow"].into();
+
+        // Modify values
+        let mut builder = array.into_builder().unwrap();
+
+        let (offset_slice, value_slice, _) = builder.slices_mut();
+
+        assert_eq!(offset_slice, &[0, 5, 10]);
+
+        let expected_slice = "helloarrow".as_bytes();
+        assert_eq!(value_slice, expected_slice);
+
+        value_slice[0] = 'H'.as_();
+        value_slice[1] = 'E'.as_();
+        value_slice[2] = 'L'.as_();
+        value_slice[3] = 'L'.as_();
+        value_slice[4] = 'O'.as_();
+
+        let expected: StringArray = vec!["HELLO", "arrow"].into();
+        let array = builder.finish();
+        assert_eq!(expected, array);
+
+        // Modify offsets
+        let mut builder = array.into_builder().unwrap();
+
+        let (offset_slice, _, _) = builder.slices_mut();
+
+        offset_slice[1] = 7;
+
+        let expected: StringArray = vec!["HELLOar", "row"].into();
+        let array = builder.finish();
+        assert_eq!(expected, array);

Review Comment:
   I recommend at least one test that `into_builder()` returns Err() if the 
reference has been shared
   
   



-- 
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