Skip to content

Commit 8d4eae5

Browse files
committed
include crc32c codec into tests
1 parent 9733e07 commit 8d4eae5

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/main/java/dev/zarr/zarrjava/v3/codec/CodecBuilder.java

+4
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ public CodecBuilder withSharding(int[] chunkShape,
139139
return this;
140140
}
141141

142+
public CodecBuilder withCrc32c() {
143+
codecs.add(new Crc32cCodec());
144+
return this;
145+
}
142146
private void autoInsertBytesCodec() {
143147
if (codecs.stream().noneMatch(c -> c instanceof ArrayBytesCodec)) {
144148
Codec[] arrayArrayCodecs = codecs.stream().filter(c -> c instanceof ArrayArrayCodec)

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ public void testZstdLibrary(int clevel, boolean checksumFlag) throws IOException
127127
assert exitCode == 0;
128128
}
129129

130-
//TODO: add crc32c
131130
@ParameterizedTest
132-
@ValueSource(strings = {"blosc", "gzip", "zstd", "bytes", "transpose", "sharding_start", "sharding_end"})
131+
@ValueSource(strings = {"blosc", "gzip", "zstd", "bytes", "transpose", "sharding_start", "sharding_end", "crc32c"})
133132
public void testWriteToZarrita(String codec) throws IOException, ZarrException, InterruptedException {
134133
StoreHandle storeHandle = new FilesystemStore(TESTOUTPUT).resolve("write_to_zarrita", codec);
135134
ArrayMetadataBuilder builder = Array.metadataBuilder()
@@ -161,7 +160,7 @@ public void testWriteToZarrita(String codec) throws IOException, ZarrException,
161160
builder = builder.withCodecs(c -> c.withSharding(new int[]{4, 4}, c1 -> c1.withBytes("LITTLE"), "end"));
162161
break;
163162
case "crc32c":
164-
//missing
163+
builder = builder.withCodecs(CodecBuilder::withCrc32c);
165164
break;
166165
default:
167166
throw new IllegalArgumentException("Invalid Codec: " + codec);
@@ -195,7 +194,7 @@ public void testWriteToZarrita(String codec) throws IOException, ZarrException,
195194

196195

197196
@ParameterizedTest
198-
@ValueSource(strings = {"blosc", "gzip", "zstd", "bytes", "transpose", "sharding_start", "sharding_end"})
197+
@ValueSource(strings = {"blosc", "gzip", "zstd", "bytes", "transpose", "sharding_start", "sharding_end", "crc32c"})
199198
public void testCodecsWriteRead(String codec) throws IOException, ZarrException {
200199
int[] testData = new int[16 * 16 * 16];
201200
Arrays.setAll(testData, p -> p);
@@ -231,7 +230,7 @@ public void testCodecsWriteRead(String codec) throws IOException, ZarrException
231230
builder = builder.withCodecs(c -> c.withSharding(new int[]{2, 2, 4}, c1 -> c1.withBytes("LITTLE"), "start"));
232231
break;
233232
case "crc32c":
234-
//missing
233+
builder = builder.withCodecs(CodecBuilder::withCrc32c);
235234
break;
236235
default:
237236
throw new IllegalArgumentException("Invalid Codec: " + codec);

0 commit comments

Comments
 (0)