Skip to content

Commit 59029fd

Browse files
committed
test readme example
1 parent c1d666c commit 59029fd

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/test/java/dev/zarr/zarrjava/ZarrTest.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,42 @@ public void testV2() throws IOException {
565565
}
566566

567567

568+
@Test
569+
public void testReadme1() throws IOException, ZarrException {
570+
Group hierarchy = Group.open(
571+
new HttpStore("https://static.webknossos.org/data/zarr_v3")
572+
.resolve("l4_sample")
573+
);
574+
Group color = (Group) hierarchy.get("color");
575+
Array array = (Array) color.get("1");
576+
ucar.ma2.Array outArray = array.read(
577+
new long[]{0, 3073, 3073, 513}, // offset
578+
new int[]{1, 64, 64, 64} // shape
579+
);
580+
}
581+
582+
@Test
583+
public void testReadme2() throws IOException, ZarrException {
584+
Array array = Array.create(
585+
new FilesystemStore(TESTOUTPUT).resolve("testoutput", "color", "1"),
586+
Array.metadataBuilder()
587+
.withShape(1, 4096, 4096, 1536)
588+
.withDataType(DataType.UINT32)
589+
.withChunkShape(1, 1024, 1024, 1024)
590+
.withFillValue(0)
591+
.withCodecs(c -> c.withSharding(new int[]{1, 32, 32, 32}, c1 -> c1.withBlosc()))
592+
.build()
593+
);
594+
ucar.ma2.Array data = ucar.ma2.Array.factory(ucar.ma2.DataType.UINT, new int[]{1, 1, 2, 2}, new int[]{1, 2, 3, 4});
595+
array.write(
596+
new long[]{0, 0, 0, 0}, // offset
597+
data
598+
);
599+
ucar.ma2.Array output = array.read(new long[]{0, 0, 0, 0}, new int[]{1, 1, 2, 2});
600+
assert MultiArrayUtils.allValuesEqual(data, output);
601+
602+
}
603+
568604
@ParameterizedTest
569605
@ValueSource(strings = {"1", "2-2-1", "4-4-1", "16-16-4"})
570606
public void testReadL4Sample(String mag) throws IOException, ZarrException {

0 commit comments

Comments
 (0)