From 1c103ff2f33670947a32b9b32f6a448f7154a4b0 Mon Sep 17 00:00:00 2001 From: Shubh Sohal Date: Thu, 10 Jul 2025 14:47:55 -0400 Subject: [PATCH 1/2] Adding negative tests for partial read workflow --- test/tZarrRead.m | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/test/tZarrRead.m b/test/tZarrRead.m index 262c77b..ffed292 100644 --- a/test/tZarrRead.m +++ b/test/tZarrRead.m @@ -136,24 +136,35 @@ function invalidFilePath(testcase) function invalidPartialReadParams(testcase) % Verify zarrread errors when invalid partial read - % Start/Stride/Count are used - + % Start/Stride/Count are used. zpath = testcase.ArrPathReadSmall; % a 2D array, 3x4 + % Wrong dimensions errID = 'MATLAB:Zarr:badPartialReadDimensions'; - wrongNumberOfDimensions = [1,1,1]; - testcase.verifyError(... - @()zarrread(zpath,Start=wrongNumberOfDimensions),... - errID); - testcase.verifyError(... - @()zarrread(zpath,Stride=wrongNumberOfDimensions),... - errID); - testcase.verifyError(... - @()zarrread(zpath,Count=wrongNumberOfDimensions),... - errID); - - %TODO: negative values, wrong datatypes, out of bounds - + wrongDims = [1,1,1]; + testcase.verifyError(@()zarrread(zpath,Start=wrongDims),errID); + testcase.verifyError(@()zarrread(zpath,Stride=wrongDims),errID); + testcase.verifyError(@()zarrread(zpath,Count=wrongDims),errID); + + % Invalid type + errID = 'MATLAB:validators:mustBeNumericOrLogical'; + testcase.verifyError(@()zarrread(zpath,"Start",""),errID); + testcase.verifyError(@()zarrread(zpath,"Stride",""),errID); + testcase.verifyError(@()zarrread(zpath,"Count",""),errID); + + % Negative values + inpVal = [-1 1]; + errID = 'MATLAB:validators:mustBePositive'; + testcase.verifyError(@()zarrread(zpath,"Start",inpVal),errID); + testcase.verifyError(@()zarrread(zpath,"Stride",inpVal),errID); + testcase.verifyError(@()zarrread(zpath,"Count",inpVal),errID); + + % Input out of bounds + inpVal = [100 200]; + errID = 'MATLAB:Python:PyException'; + testcase.verifyError(@()zarrread(zpath,"Start",inpVal),errID); + %testcase.verifyError(@()zarrread(zpath,"Stride",inpVal),errID); + testcase.verifyError(@()zarrread(zpath,"Count",inpVal),errID); end end end \ No newline at end of file From ef351ba350f0dccd67b3ef847fff3dd1be3fc882 Mon Sep 17 00:00:00 2001 From: Shubh Sohal Date: Mon, 14 Jul 2025 09:57:06 -0400 Subject: [PATCH 2/2] Address feedback --- test/tZarrRead.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tZarrRead.m b/test/tZarrRead.m index ffed292..6a2b25b 100644 --- a/test/tZarrRead.m +++ b/test/tZarrRead.m @@ -139,7 +139,7 @@ function invalidPartialReadParams(testcase) % Start/Stride/Count are used. zpath = testcase.ArrPathReadSmall; % a 2D array, 3x4 - % Wrong dimensions + % Wrong number of dimensions in comparison to the array errID = 'MATLAB:Zarr:badPartialReadDimensions'; wrongDims = [1,1,1]; testcase.verifyError(@()zarrread(zpath,Start=wrongDims),errID);