Skip to content

Commit f89fcc4

Browse files
committed
Test[HDF5,NetCDF]: speed/simpliy coerce test
1 parent c6f444d commit f89fcc4

File tree

2 files changed

+14
-35
lines changed

2 files changed

+14
-35
lines changed

+stdlib/+test/TestHDF5.m

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
end
66

77
properties (TestParameter)
8-
type = {'single', 'double', 'float32', 'float64', ...
9-
'int8', 'int16', 'int32', 'int64', ...
10-
'uint8', 'uint16', 'uint32', 'uint64'}
118
str = {"string", 'char'}
129
end
1310

@@ -236,26 +233,20 @@ function test_shape(tc)
236233
end
237234

238235

239-
function test_coerce(tc, type)
236+
function test_coerce(tc)
240237
import stdlib.hdf5nc.h5save
241238
import matlab.unittest.constraints.IsFile
242239
basic = tc.TestData.basic;
243240

244-
vn = "/" + type;
241+
for type = ["single", "double", ...
242+
"int8", "int16", "int32", "int64", ...
243+
"uint8", "uint16", "uint32", "uint64"]
245244

246-
h5save(basic, vn, 0, "type",type)
245+
h5save(basic, type, 0, "type",type)
247246

248-
tc.assumeThat(basic, IsFile)
249-
250-
if type == "float32"
251-
vtype = "single";
252-
elseif type == "float64"
253-
vtype = "double";
254-
else
255-
vtype = type;
247+
tc.verifyClass(h5read(basic, "/"+type), type)
256248
end
257249

258-
tc.verifyClass(h5read(basic, vn), vtype)
259250
end
260251

261252

+stdlib/+test/TestNetCDF.m

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
TestData
55
end
66

7-
properties (TestParameter)
8-
type = {'single', 'double', 'float32', 'float64', ...
9-
'int8', 'int16', 'int32', 'int64', ...
10-
'uint8', 'uint16', 'uint32', 'uint64'}
11-
end
12-
13-
147
methods (TestMethodSetup)
158

169
function setup_file(tc)
@@ -221,25 +214,20 @@ function test_read_string(tc)
221214
end
222215

223216

224-
function test_coerce(tc, type)
217+
function test_coerce(tc)
225218
import stdlib.hdf5nc.ncsave
226219
import matlab.unittest.constraints.IsFile
227220
basic = tc.TestData.basic;
228221

229-
vn = type;
222+
for type = ["single", "double", ...
223+
"int8", "int16", "int32", "int64", ...
224+
"uint8", "uint16", "uint32", "uint64"]
230225

231-
ncsave(basic, vn, 0, "type", type)
226+
ncsave(basic, type, 0, "type", type)
232227

233-
tc.assumeThat(basic, IsFile)
234-
235-
if type == "float32"
236-
vtype = "single";
237-
elseif type == "float64"
238-
vtype = "double";
239-
else
240-
vtype = type;
228+
tc.verifyClass(ncread(basic, type), type)
241229
end
242-
tc.verifyClass(ncread(basic, vn), vtype)
230+
243231
end
244232

245233

@@ -248,7 +236,7 @@ function test_rewrite(tc)
248236
import matlab.unittest.constraints.IsFile
249237
basic = tc.TestData.basic;
250238

251-
ncsave(basic, 'A2', 3*magic(4))
239+
ncsave(basic, "A2", 3*magic(4))
252240

253241
tc.assumeThat(basic, IsFile)
254242
tc.verifyEqual(ncread(basic, 'A2'), 3*magic(4))

0 commit comments

Comments
 (0)