This is an automated email from the ASF dual-hosted git repository.

bchapuis pushed a commit to branch calcite
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git

commit cfd206b1de6d8813f7810d6064544db1b4136836
Author: Bertil Chapuis <[email protected]>
AuthorDate: Thu Jun 22 11:25:50 2023 +0200

    Fix tests
---
 .../collection/type/DoubleArrayDataType.java        |  5 ++---
 .../baremaps/collection/AppendOnlyBufferTest.java   | 21 ++++++++++++++++++++-
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git 
a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DoubleArrayDataType.java
 
b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DoubleArrayDataType.java
index 08122aa0..57756c8c 100644
--- 
a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DoubleArrayDataType.java
+++ 
b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DoubleArrayDataType.java
@@ -34,9 +34,8 @@ public class DoubleArrayDataType implements 
DataType<double[]> {
   /** {@inheritDoc} */
   @Override
   public void write(final ByteBuffer buffer, final int position, final 
double[] values) {
-    var p = position;
-    buffer.putInt(p, size(values));
-    p += Integer.BYTES;
+    buffer.putInt(position, size(values));
+    int p = position + Integer.BYTES;
     for (double value : values) {
       buffer.putDouble(p, value);
       p += Double.BYTES;
diff --git 
a/baremaps-core/src/test/java/org/apache/baremaps/collection/AppendOnlyBufferTest.java
 
b/baremaps-core/src/test/java/org/apache/baremaps/collection/AppendOnlyBufferTest.java
index d1e6bebc..cef31239 100644
--- 
a/baremaps-core/src/test/java/org/apache/baremaps/collection/AppendOnlyBufferTest.java
+++ 
b/baremaps-core/src/test/java/org/apache/baremaps/collection/AppendOnlyBufferTest.java
@@ -12,6 +12,7 @@
 
 package org.apache.baremaps.collection;
 
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.ArrayList;
@@ -73,7 +74,25 @@ class AppendOnlyBufferTest {
     // read values
     int count = 0;
     for (var v : collection) {
-      assertEquals(value, v);
+      if (value instanceof byte[]) {
+        assertArrayEquals((byte[]) value, (byte[]) v);
+      } else if (value instanceof short[]) {
+        assertArrayEquals((short[]) value, (short[]) v);
+      } else if (value instanceof int[]) {
+        assertArrayEquals((int[]) value, (int[]) v);
+      } else if (value instanceof long[]) {
+        assertArrayEquals((long[]) value, (long[]) v);
+      } else if (value instanceof float[]) {
+        assertArrayEquals((float[]) value, (float[]) v);
+      } else if (value instanceof double[]) {
+        assertArrayEquals((double[]) value, (double[]) v);
+      } else if (value instanceof char[]) {
+        assertArrayEquals((char[]) value, (char[]) v);
+      } else if (value instanceof boolean[]) {
+        assertArrayEquals((boolean[]) value, (boolean[]) v);
+      } else {
+        assertEquals(value, v);
+      }
       count++;
     }
 

Reply via email to