Skip to content

Commit bae6940

Browse files
committed
test hdf5: skip tests for old matlab
1 parent ee36e33 commit bae6940

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

+stdlib/+test/TestHDF5.m

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ function setup_file(tc)
4545
h5save(basic, '/A2', A2)
4646
h5save(basic, '/A3', A3, "size", size(A3))
4747
h5save(basic, '/A4', A4)
48-
h5save(basic, "/utf", utf)
49-
h5save(basic, "/utf2", utf2)
48+
49+
if ~verLessThan('matlab', '9.8')
50+
h5save(basic, "/utf", utf)
51+
h5save(basic, "/utf2", utf2)
52+
end
5053

5154
h5save(basic, '/t/x', 12)
5255
h5save(basic, '/t/y', 13)
@@ -81,7 +84,11 @@ function test_get_variables(tc)
8184
basic = tc.TestData.basic;
8285

8386
v = h5variables(basic);
84-
tc.verifyEqual(sort(v), ["A0", "A1", "A2", "A3", "A4", "utf", "utf2"])
87+
k = ["A0", "A1", "A2", "A3", "A4"];
88+
if ~verLessThan('matlab', '9.8')
89+
k = [k, ["utf", "utf2"]];
90+
end
91+
tc.verifyEqual(sort(v), k)
8592

8693
% 1-level group
8794
v = h5variables(basic, "/t");
@@ -115,10 +122,12 @@ function test_size(tc)
115122
import stdlib.hdf5nc.h5ndims
116123
basic = tc.TestData.basic;
117124

118-
r = h5ndims(basic, '/A0');
119-
s = h5size(basic, '/A0');
120-
tc.verifyEmpty(s)
121-
tc.verifyEqual(r, 0)
125+
if ~verLessThan('matlab', '9.8')
126+
r = h5ndims(basic, '/A0');
127+
s = h5size(basic, '/A0');
128+
tc.verifyEmpty(s)
129+
tc.verifyEqual(r, 0)
130+
end
122131

123132
r = h5ndims(basic, '/A1');
124133
s = h5size(basic, '/A1');
@@ -144,6 +153,10 @@ function test_size(tc)
144153
tc.verifyEqual(s, [4,3,2,5])
145154
tc.verifyEqual(r, 4)
146155

156+
if verLessThan('matlab', '9.8')
157+
return
158+
end
159+
147160
r = h5ndims(basic, '/utf');
148161
s = h5size(basic, '/utf');
149162
tc.verifyEmpty(s)
@@ -179,6 +192,10 @@ function test_read(tc)
179192
tc.verifyEqual(ndims(s), 4)
180193
tc.verifyEqual(s, tc.TestData.A4)
181194

195+
if verLessThan('matlab', '9.8')
196+
return
197+
end
198+
182199
s = h5read(basic, '/utf');
183200
tc.verifyTrue(ischar(s))
184201
tc.verifyEqual(s, tc.TestData.utf)
@@ -199,9 +216,11 @@ function test_shape(tc)
199216
s = h5size(basic, '/vector1');
200217
tc.verifyEqual(s, 1);
201218

202-
h5save(basic, "/scalar", 34, "size", 0)
203-
s = h5size(basic, '/scalar');
204-
tc.verifyEmpty(s);
219+
if ~verLessThan('matlab', '9.8')
220+
h5save(basic, "/scalar", 34, "size", 0)
221+
s = h5size(basic, '/scalar');
222+
tc.verifyEmpty(s);
223+
end
205224

206225
end
207226

@@ -263,6 +282,9 @@ function test_int8(tc)
263282

264283
function test_string(tc, str)
265284
import stdlib.hdf5nc.h5save
285+
286+
tc.assumeFalse(verLessThan('matlab', '9.8'), "HDF5 string required Matlab >= R2020a")
287+
266288
basic = tc.TestData.basic;
267289

268290
h5save(basic, "/"+str, str)

0 commit comments

Comments
 (0)