Skip to content

Commit 82e0ef3

Browse files
committed
test store::get with start and end
1 parent 4f80830 commit 82e0ef3

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/test/java/dev/zarr/zarrjava/store/StoreTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import java.io.IOException;
1515
import java.io.InputStream;
16+
import java.nio.ByteBuffer;
1617
import java.util.List;
1718
import java.util.Set;
1819
import java.util.stream.Collectors;
@@ -79,6 +80,26 @@ public void testGetSize() {
7980
Assertions.assertEquals(actual_size, size);
8081
}
8182

83+
@Test
84+
public void testGetWithStartEnd() {
85+
StoreHandle storeHandle = storeHandleWithData();
86+
long size = storeHandle.getSize();
87+
System.out.println("Store size: " + size);
88+
if (size < 20) {
89+
Assertions.fail("Store size is too small to test get with start and end");
90+
}
91+
ByteBuffer buffer = storeHandle.read(5, 15);
92+
Assertions.assertEquals(10, buffer.remaining());
93+
94+
ByteBuffer fullBuffer = storeHandle.read();
95+
byte[] expectedBytes = new byte[10];
96+
fullBuffer.position(5);
97+
fullBuffer.get(expectedBytes, 0, 10);
98+
byte[] actualBytes = new byte[10];
99+
buffer.get(actualBytes, 0, 10);
100+
Assertions.assertArrayEquals(expectedBytes, actualBytes);
101+
}
102+
82103
@Test
83104
public abstract void testList() throws ZarrException, IOException;
84105

0 commit comments

Comments
 (0)