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


##########
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:
   Added one test for it.



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to