Skip to content

Commit e458c4f

Browse files
committed
parametrize test
1 parent b7b24de commit e458c4f

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

+hdf5nc/TestHDF5.m

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
TestData
55
end
66

7+
properties (TestParameter)
8+
type = {'single', 'double', 'int32', 'int64'};
9+
end
10+
711

812
methods (TestClassSetup)
913

@@ -131,20 +135,18 @@ function test_read(tc)
131135
end
132136

133137

134-
function test_coerce(tc)
138+
function test_coerce(tc, type)
135139
import hdf5nc.h5save
136140
import matlab.unittest.constraints.IsFile
137141
basic = tc.TestData.basic;
138142

139-
h5save(basic, '/int32', 0, "type", 'int32')
140-
h5save(basic, '/int64', 0, "type", 'int64')
141-
h5save(basic, '/float32', 0, "type", 'float32')
143+
vn = "/" + type;
144+
145+
h5save(basic, vn, 0, "type", type)
142146

143147
tc.assumeThat(basic, IsFile)
144148

145-
tc.verifyClass(h5read(basic, '/int32'), 'int32')
146-
tc.verifyClass(h5read(basic, '/int64'), 'int64')
147-
tc.verifyClass(h5read(basic, '/float32'), 'single')
149+
tc.verifyClass(h5read(basic, vn), type)
148150
end
149151

150152

+hdf5nc/TestNetCDF.m

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
TestData
55
end
66

7+
properties (TestParameter)
8+
type = {'single', 'double', 'int32', 'int64'};
9+
end
10+
711

812
methods (TestClassSetup)
913

@@ -123,20 +127,18 @@ function test_read(tc)
123127
end
124128

125129

126-
function test_coerce(tc)
130+
function test_coerce(tc, type)
127131
import hdf5nc.ncsave
128132
import matlab.unittest.constraints.IsFile
129133
basic = tc.TestData.basic;
130134

131-
ncsave(basic, 'int32', 0, "type", 'int32')
132-
ncsave(basic, 'int64', 0, "type", 'int64')
133-
ncsave(basic, 'float32', 0, "type", 'float32')
135+
vn = type;
136+
137+
ncsave(basic, vn, 0, "type", type)
134138

135139
tc.assumeThat(basic, IsFile)
136140

137-
tc.verifyClass(h5read(basic, '/int32'), 'int32')
138-
tc.verifyClass(h5read(basic, '/int64'), 'int64')
139-
tc.verifyClass(h5read(basic, '/float32'), 'single')
141+
tc.verifyClass(ncread(basic, vn), type)
140142
end
141143

142144

0 commit comments

Comments
 (0)