|
174 | 174 |
|
175 | 175 | %% Test: fetch features
|
176 | 176 | function [] = test_fetch_features( varargin )
|
177 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
178 |
| - getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
179 |
| - getMultiTag = getBlock.open_multi_tag(getBlock.multiTags{1,1}.id); |
| 177 | + test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 178 | + b = test_file.createBlock('featureTest', 'nixBlock'); |
| 179 | + tmp = b.create_data_array('featureTestDataArray', 'nixDataArray', 'double', [1 2]); |
| 180 | + getMTag = b.create_multi_tag('featuretest', 'nixMultiTag', b.dataArrays{1}); |
180 | 181 |
|
181 |
| - %-- ToDo get testfile with tag referencing a source |
182 |
| - assert(size(getMultiTag.features(), 1) == 0); |
183 |
| - disp('Test MultiTag: fetch features ... TODO (proper testfile)'); |
| 182 | + assert(isempty(getMTag.features)); |
| 183 | + tmp = b.create_data_array('featTestDA', 'nixDataArray', 'double', [1 2]); |
| 184 | + tmp = getMTag.add_feature(b.dataArrays{2}, nix.LinkType.Tagged); |
| 185 | + assert(size(getMTag.features, 1) == 1); |
184 | 186 | end
|
185 | 187 |
|
186 | 188 | %% Test: Open source by ID or name
|
|
205 | 207 | assert(isempty(getSource));
|
206 | 208 | end
|
207 | 209 |
|
208 |
| -%% Test: Open feature by ID or name |
| 210 | +%% Test: Open feature by ID |
209 | 211 | function [] = test_open_feature( varargin )
|
210 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
211 |
| - getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
212 |
| - getMultiTag = getBlock.open_multi_tag(getBlock.multiTags{1,1}.id); |
213 |
| - |
214 |
| - %-- TODO: implement testfile with feature referenced from a tag |
215 |
| - %getFeatByID = getMultiTag.open_feature(getMultiTag.features{1,1}.id); |
216 |
| - %assert(strcmp(getFeatByID.id, '')); |
217 |
| - disp('Test MultiTag: open feature by ID ... TODO (proper testfile)'); |
218 |
| - |
219 |
| - %getFeatByName = getTag.open_feature(getTag.features{1,1}.name); |
220 |
| - %assert(strcmp(getFeatByName.id, '')); |
221 |
| - disp('Test MultiTag: open feature by name ... TODO (proper testfile)'); |
222 |
| - |
| 212 | + test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 213 | + b = test_file.createBlock('featureTest', 'nixBlock'); |
| 214 | + tmp = b.create_data_array('featureTestDataArray', 'nixDataArray', 'double', [1 2]); |
| 215 | + getMTag = b.create_multi_tag('featuretest', 'nixMultiTag', b.dataArrays{1}); |
| 216 | + |
| 217 | + tmp = b.create_data_array('featTestDA', 'nixDataArray', 'double', [1 2]); |
| 218 | + tmp = getMTag.add_feature(b.dataArrays{2}, nix.LinkType.Tagged); |
| 219 | + assert(~isempty(getMTag.open_feature(getMTag.features{1}.id))); |
| 220 | + |
223 | 221 | %-- test open non existing feature
|
224 |
| - getFeat = getMultiTag.open_feature('I dont exist'); |
| 222 | + getFeat = getMTag.open_feature('I do not exist'); |
225 | 223 | assert(isempty(getFeat));
|
226 | 224 | end
|
227 | 225 |
|
|
265 | 263 |
|
266 | 264 | %% Test: Has positions
|
267 | 265 | function [] = test_has_positions( varargin )
|
268 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
269 |
| - getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
| 266 | + test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 267 | + b = test_file.createBlock('positionsTest', 'nixBlock'); |
| 268 | + tmp = b.create_data_array('positionsTestDataArray', 'nixDataArray', 'double', [1 2 3 4 5 6]); |
| 269 | + getMTag = b.create_multi_tag('positionstest', 'nixMultiTag', b.dataArrays{1}); |
| 270 | + tmp = b.create_data_array('positionsTest1', 'nixDataArray', 'double', [0 1]); |
270 | 271 |
|
271 |
| - %-- ToDo implement test for non existing positions |
272 |
| - %getMultiTag = getBlock.open_multi_tag(getBlock.multiTags{1,1}.id); |
273 |
| - %assert(~getMultiTag.hasPositions); |
274 |
| - disp('Test MultiTag: has no existing positions ... TODO (proper testfile)'); |
275 |
| - |
276 |
| - getMultiTag = getBlock.open_multi_tag(getBlock.multiTags{1,1}.id); |
277 |
| - assert(getMultiTag.has_positions); |
| 272 | + getMTag.add_positions(b.dataArrays{2}.id); |
| 273 | + assert(getMTag.has_positions); |
278 | 274 | end
|
279 | 275 |
|
280 | 276 | %% Test: Open positions
|
281 | 277 | function [] = test_open_positions( varargin )
|
282 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
283 |
| - getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
| 278 | + test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 279 | + b = test_file.createBlock('positionsTest', 'nixBlock'); |
| 280 | + tmp = b.create_data_array('positionsTestDataArray', 'nixDataArray', 'double', [1 2 3 4 5 6]); |
| 281 | + getMTag = b.create_multi_tag('positionstest', 'nixMultiTag', b.dataArrays{1}); |
| 282 | + tmp = b.create_data_array('positionsTest1', 'nixDataArray', 'double', [0 1]); |
284 | 283 |
|
285 |
| - %-- ToDo implement test for non existing positions |
286 |
| - %getMultiTag = getBlock.open_multi_tag(getBlock.multiTags{1,1}.id); |
287 |
| - %assert(isempty(getMultiTag.open_positions)); |
288 |
| - disp('Test MultiTag: open non existing positions ... TODO (proper testfile)'); |
289 |
| - |
290 |
| - getMultiTag = getBlock.open_multi_tag(getBlock.multiTags{1,1}.id); |
291 |
| - assert(~isempty(getMultiTag.open_positions)); |
| 284 | + getMTag.add_positions(b.dataArrays{2}.id); |
| 285 | + assert(~isempty(getMTag.open_positions)); |
292 | 286 | end
|
293 | 287 |
|
294 | 288 | %% Test: Add extents by entity and id
|
295 | 289 | function [] = test_add_extents ( varargin )
|
296 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
297 |
| - b = test_file.createBlock('extentsTest', 'nixBlock'); |
| 290 | +% test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 291 | +% b = test_file.createBlock('extentsTest', 'nixBlock'); |
298 | 292 | % tmp = b.create_data_array('extentsTestDataArray', 'nixDataArray', 'double', [1 2 3 4 5 6; 1 2 3 4 5 6]);
|
299 | 293 | % getMTag = b.create_multi_tag('extentstest', 'nixMultiTag', b.dataArrays{1});
|
300 | 294 |
|
|
0 commit comments