Skip to content

Commit 7090614

Browse files
authored
Merge pull request #6 from sbesson/invalidchunkbounds_test
Add unit test for invalid chunk bounds
2 parents fa0937e + bf3f08f commit 7090614

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

+24
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.junit.jupiter.api.Test;
2020
import org.junit.jupiter.params.ParameterizedTest;
2121
import org.junit.jupiter.params.provider.CsvSource;
22+
import org.junit.jupiter.params.provider.MethodSource;
2223
import org.junit.jupiter.params.provider.ValueSource;
2324
import ucar.ma2.MAMath;
2425

@@ -230,6 +231,29 @@ public void testWriteReadWithZarrita(String codec, String codecParam) throws Exc
230231
assert exitCode == 0;
231232
}
232233

234+
static Stream<int[]> invalidchunkSizes() {
235+
return Stream.of(
236+
new int[] {1} ,
237+
new int[] {1, 1, 1},
238+
new int[] {5, 1},
239+
new int[] {1, 5}
240+
);
241+
}
242+
243+
@ParameterizedTest
244+
@MethodSource("invalidchunkSizes")
245+
public void testCheckInvalidChunkBounds(int[] chunkSize) throws Exception {
246+
long[] shape = new long[] {4, 4};
247+
248+
StoreHandle storeHandle = new FilesystemStore(TESTOUTPUT).resolve("invalid_chunksize");
249+
ArrayMetadataBuilder builder = Array.metadataBuilder()
250+
.withShape(shape)
251+
.withDataType(DataType.UINT32)
252+
.withChunkShape(chunkSize);
253+
254+
assertThrows(ZarrException.class, builder::build);
255+
}
256+
233257
@ParameterizedTest
234258
@ValueSource(strings = {"large", "small", "nested", "wrong dims", "correct"})
235259
public void testCheckShardingBounds(String scenario) throws Exception {

0 commit comments

Comments
 (0)