Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-42002: [Java] Update Unit Tests for Vector Module #42019

Merged
merged 7 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

package org.apache.arrow.vector;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
Expand All @@ -28,7 +28,7 @@
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.holders.NullableDecimalHolder;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

package org.apache.arrow.vector;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.stream.IntStream;

Expand All @@ -29,22 +29,21 @@
import org.apache.arrow.memory.util.hash.MurmurHasher;
import org.apache.arrow.vector.testing.ValueVectorDataPopulator;
import org.apache.arrow.vector.util.TransferPair;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class TestBitVector {
private static final String EMPTY_SCHEMA_PATH = "";

private BufferAllocator allocator;

@Before
@BeforeEach
public void init() {
allocator = new RootAllocator(Long.MAX_VALUE);
}

@After
@AfterEach
public void terminate() throws Exception {
allocator.close();
}
Expand Down Expand Up @@ -124,8 +123,8 @@ public void testSplitAndTransfer() throws Exception {
for (int i = 0; i < length; i++) {
int actual = toVector.get(i);
int expected = sourceVector.get(start + i);
assertEquals("different data values not expected --> sourceVector index: " + (start + i) +
" toVector index: " + i, expected, actual);
assertEquals(expected, actual,
"different data values not expected --> sourceVector index: " + (start + i) + " toVector index: " + i);
}
}
}
Expand Down Expand Up @@ -167,8 +166,8 @@ public void testSplitAndTransfer1() throws Exception {
for (int i = 0; i < length; i++) {
int actual = toVector.get(i);
int expected = sourceVector.get(start + i);
assertEquals("different data values not expected --> sourceVector index: " + (start + i) +
" toVector index: " + i, expected, actual);
assertEquals(expected, actual,
"different data values not expected --> sourceVector index: " + (start + i) + " toVector index: " + i);
}
}
}
Expand Down Expand Up @@ -218,8 +217,8 @@ public void testSplitAndTransfer2() throws Exception {
for (int i = 0; i < length; i++) {
int actual = toVector.get(i);
int expected = sourceVector.get(start + i);
assertEquals("different data values not expected --> sourceVector index: " + (start + i) +
" toVector index: " + i, expected, actual);
assertEquals(expected, actual,
"different data values not expected --> sourceVector index: " + (start + i) + " toVector index: " + i);
}
}
}
Expand All @@ -241,9 +240,9 @@ public void testReallocAfterVectorTransfer1() {

for (int i = 0; i < valueCapacity; i++) {
if ((i & 1) == 1) {
assertEquals("unexpected cleared bit at index: " + i, 1, vector.get(i));
assertEquals(1, vector.get(i), "unexpected cleared bit at index: " + i);
} else {
assertTrue("unexpected set bit at index: " + i, vector.isNull(i));
assertTrue(vector.isNull(i), "unexpected set bit at index: " + i);
}
}

Expand All @@ -259,9 +258,9 @@ public void testReallocAfterVectorTransfer1() {

for (int i = 0; i < valueCapacity * 2; i++) {
if (((i & 1) == 1) || (i == valueCapacity)) {
assertEquals("unexpected cleared bit at index: " + i, 1, vector.get(i));
assertEquals(1, vector.get(i), "unexpected cleared bit at index: " + i);
} else {
assertTrue("unexpected set bit at index: " + i, vector.isNull(i));
assertTrue(vector.isNull(i), "unexpected set bit at index: " + i);
}
}

Expand All @@ -277,9 +276,9 @@ public void testReallocAfterVectorTransfer1() {

for (int i = 0; i < valueCapacity * 4; i++) {
if (((i & 1) == 1) || (i == valueCapacity) || (i == valueCapacity * 2)) {
assertEquals("unexpected cleared bit at index: " + i, 1, vector.get(i));
assertEquals(1, vector.get(i), "unexpected cleared bit at index: " + i);
} else {
assertTrue("unexpected set bit at index: " + i, vector.isNull(i));
assertTrue(vector.isNull(i), "unexpected set bit at index: " + i);
}
}

Expand All @@ -297,12 +296,12 @@ public void testReallocAfterVectorTransfer1() {
if (i <= valueCapacity * 4) {
if (((i & 1) == 1) || (i == valueCapacity) ||
(i == valueCapacity * 2) || (i == valueCapacity * 4)) {
assertEquals("unexpected cleared bit at index: " + i, 1, toVector.get(i));
assertEquals(1, toVector.get(i), "unexpected cleared bit at index: " + i);
} else {
assertTrue("unexpected set bit at index: " + i, toVector.isNull(i));
assertTrue(toVector.isNull(i), "unexpected set bit at index: " + i);
}
} else {
assertTrue("unexpected set bit at index: " + i, toVector.isNull(i));
assertTrue(toVector.isNull(i), "unexpected set bit at index: " + i);
}
}

Expand All @@ -325,9 +324,9 @@ public void testReallocAfterVectorTransfer2() {

for (int i = 0; i < valueCapacity; i++) {
if ((i & 1) == 1) {
assertFalse("unexpected cleared bit at index: " + i, vector.isNull(i));
assertFalse(vector.isNull(i), "unexpected cleared bit at index: " + i);
} else {
assertTrue("unexpected set bit at index: " + i, vector.isNull(i));
assertTrue(vector.isNull(i), "unexpected set bit at index: " + i);
}
}

Expand All @@ -343,9 +342,9 @@ public void testReallocAfterVectorTransfer2() {

for (int i = 0; i < valueCapacity * 2; i++) {
if (((i & 1) == 1) || (i == valueCapacity)) {
assertFalse("unexpected cleared bit at index: " + i, vector.isNull(i));
assertFalse(vector.isNull(i), "unexpected cleared bit at index: " + i);
} else {
assertTrue("unexpected set bit at index: " + i, vector.isNull(i));
assertTrue(vector.isNull(i), "unexpected set bit at index: " + i);
}
}

Expand All @@ -361,9 +360,9 @@ public void testReallocAfterVectorTransfer2() {

for (int i = 0; i < valueCapacity * 4; i++) {
if (((i & 1) == 1) || (i == valueCapacity) || (i == valueCapacity * 2)) {
assertFalse("unexpected cleared bit at index: " + i, vector.isNull(i));
assertFalse(vector.isNull(i), "unexpected cleared bit at index: " + i);
} else {
assertTrue("unexpected set bit at index: " + i, vector.isNull(i));
assertTrue(vector.isNull(i), "unexpected set bit at index: " + i);
}
}

Expand All @@ -381,12 +380,12 @@ public void testReallocAfterVectorTransfer2() {
if (i <= valueCapacity * 4) {
if (((i & 1) == 1) || (i == valueCapacity) ||
(i == valueCapacity * 2) || (i == valueCapacity * 4)) {
assertFalse("unexpected cleared bit at index: " + i, toVector.isNull(i));
assertFalse(toVector.isNull(i), "unexpected cleared bit at index: " + i);
} else {
assertTrue("unexpected set bit at index: " + i, toVector.isNull(i));
assertTrue(toVector.isNull(i), "unexpected set bit at index: " + i);
}
} else {
assertTrue("unexpected set bit at index: " + i, toVector.isNull(i));
assertTrue(toVector.isNull(i), "unexpected set bit at index: " + i);
}
}

Expand Down Expand Up @@ -500,13 +499,13 @@ private void validateRange(int length, int start, int count) {
bitVector.allocateNew(length);
bitVector.setRangeToOne(start, count);
for (int i = 0; i < start; i++) {
Assert.assertTrue(desc + i, bitVector.isNull(i));
assertTrue(bitVector.isNull(i), desc + i);
}
for (int i = start; i < start + count; i++) {
Assert.assertEquals(desc + i, 1, bitVector.get(i));
assertEquals(1, bitVector.get(i), desc + i);
}
for (int i = start + count; i < length; i++) {
Assert.assertTrue(desc + i, bitVector.isNull(i));
assertTrue(bitVector.isNull(i), desc + i);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

package org.apache.arrow.vector;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.memory.util.MemoryUtil;
import org.apache.arrow.vector.ipc.message.ArrowFieldNode;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class TestBitVectorHelper {
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

package org.apache.arrow.vector;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.nio.charset.StandardCharsets;

Expand All @@ -30,7 +30,7 @@
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.FieldType;
import org.apache.arrow.vector.util.CallBack;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class TestBufferOwnershipTransfer {

Expand Down
Loading
Loading