Skip to content

Commit 9efc959

Browse files
authored
Merge pull request #115 from mathworks/partial_read_negative_tests
Adding negative tests for partial read workflow
2 parents 350881d + ef351ba commit 9efc959

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

test/tZarrRead.m

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,24 +136,35 @@ function invalidFilePath(testcase)
136136

137137
function invalidPartialReadParams(testcase)
138138
% Verify zarrread errors when invalid partial read
139-
% Start/Stride/Count are used
140-
139+
% Start/Stride/Count are used.
141140
zpath = testcase.ArrPathReadSmall; % a 2D array, 3x4
142141

142+
% Wrong number of dimensions in comparison to the array
143143
errID = 'MATLAB:Zarr:badPartialReadDimensions';
144-
wrongNumberOfDimensions = [1,1,1];
145-
testcase.verifyError(...
146-
@()zarrread(zpath,Start=wrongNumberOfDimensions),...
147-
errID);
148-
testcase.verifyError(...
149-
@()zarrread(zpath,Stride=wrongNumberOfDimensions),...
150-
errID);
151-
testcase.verifyError(...
152-
@()zarrread(zpath,Count=wrongNumberOfDimensions),...
153-
errID);
154-
155-
%TODO: negative values, wrong datatypes, out of bounds
156-
144+
wrongDims = [1,1,1];
145+
testcase.verifyError(@()zarrread(zpath,Start=wrongDims),errID);
146+
testcase.verifyError(@()zarrread(zpath,Stride=wrongDims),errID);
147+
testcase.verifyError(@()zarrread(zpath,Count=wrongDims),errID);
148+
149+
% Invalid type
150+
errID = 'MATLAB:validators:mustBeNumericOrLogical';
151+
testcase.verifyError(@()zarrread(zpath,"Start",""),errID);
152+
testcase.verifyError(@()zarrread(zpath,"Stride",""),errID);
153+
testcase.verifyError(@()zarrread(zpath,"Count",""),errID);
154+
155+
% Negative values
156+
inpVal = [-1 1];
157+
errID = 'MATLAB:validators:mustBePositive';
158+
testcase.verifyError(@()zarrread(zpath,"Start",inpVal),errID);
159+
testcase.verifyError(@()zarrread(zpath,"Stride",inpVal),errID);
160+
testcase.verifyError(@()zarrread(zpath,"Count",inpVal),errID);
161+
162+
% Input out of bounds
163+
inpVal = [100 200];
164+
errID = 'MATLAB:Python:PyException';
165+
testcase.verifyError(@()zarrread(zpath,"Start",inpVal),errID);
166+
%testcase.verifyError(@()zarrread(zpath,"Stride",inpVal),errID);
167+
testcase.verifyError(@()zarrread(zpath,"Count",inpVal),errID);
157168
end
158169
end
159170
end

0 commit comments

Comments
 (0)