trxcllnt commented on code in PR #14587:
URL: https://github.com/apache/arrow/pull/14587#discussion_r1044859014


##########
js/test/unit/vector/vector-tests.ts:
##########
@@ -211,6 +211,34 @@ describe(`ListVector`, () => {
     });
 });
 
+describe(`toArray()`, () => {
+    test(`when some data blobs have been padded`, () => {
+        const d1 = vectorFromArray([...Array(16).keys()]);
+        const d2 = vectorFromArray([...Array(10).keys()]);
+
+        // Padding has been added
+        expect(d2.length < d2.data.length)
+
+        const vector = new Vector([d1, d2]);
+
+        // This used to crash with "RangeError: offset is out of bounds"
+        // https://issues.apache.org/jira/browse/ARROW-18247
+        const array = vector.toArray();
+        expect(array).toHaveLength(26);
+    });
+
+    test(`when stride is 2`, () => {
+        let d1 = vectorFromArray([0, 1, 2], new 
Timestamp(TimeUnit.MILLISECOND)).data[0];
+        let d2 = vectorFromArray([3, 4, 5], new 
Timestamp(TimeUnit.MILLISECOND)).data[0];
+
+        const vector = new Vector([d1, d2]);
+
+        let array = Array.from(vector.toArray());
+        expect(array).toHaveLength(6 * 2);
+        expect(Array.from(array)).toMatchObject([0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 
5, 0]);
+    })

Review Comment:
   ```suggestion
       });
   ```



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