|
6 | 6 | funcs{end+1} = @test_add_source;
|
7 | 7 | funcs{end+1} = @test_remove_source;
|
8 | 8 | funcs{end+1} = @test_add_reference;
|
| 9 | + funcs{end+1} = @test_has_reference; |
9 | 10 | funcs{end+1} = @test_remove_reference;
|
10 | 11 | funcs{end+1} = @test_add_feature;
|
| 12 | + funcs{end+1} = @test_has_feature; |
11 | 13 | funcs{end+1} = @test_remove_feature;
|
12 | 14 | funcs{end+1} = @test_fetch_references;
|
13 | 15 | funcs{end+1} = @test_fetch_sources;
|
|
18 | 20 | funcs{end+1} = @test_add_positions;
|
19 | 21 | funcs{end+1} = @test_has_positions;
|
20 | 22 | funcs{end+1} = @test_open_positions;
|
21 |
| - funcs{end+1} = @test_add_extents; |
22 |
| - funcs{end+1} = @test_open_extents; |
| 23 | + funcs{end+1} = @test_set_open_extents; |
23 | 24 | funcs{end+1} = @test_set_metadata;
|
24 | 25 | funcs{end+1} = @test_open_metadata;
|
25 | 26 | funcs{end+1} = @test_retrieve_data;
|
26 | 27 | funcs{end+1} = @test_retrieve_feature_data;
|
| 28 | + funcs{end+1} = @test_set_units; |
27 | 29 | end
|
28 | 30 |
|
29 | 31 | %% Test: Add sources by entity and id
|
|
286 | 288 | assert(~isempty(getMTag.open_positions));
|
287 | 289 | end
|
288 | 290 |
|
289 |
| -%% Test: Add extents by entity and id |
290 |
| -function [] = test_add_extents ( varargin ) |
291 |
| -% test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
292 |
| -% b = test_file.createBlock('extentsTest', 'nixBlock'); |
293 |
| -% tmp = b.create_data_array('extentsTestDataArray', 'nixDataArray', 'double', [1 2 3 4 5 6; 1 2 3 4 5 6]); |
294 |
| -% getMTag = b.create_multi_tag('extentstest', 'nixMultiTag', b.dataArrays{1}); |
| 291 | +%% Test: Set extents by entity and ID, open and reset extents |
| 292 | +function [] = test_set_open_extents ( varargin ) |
| 293 | + fileName = 'testRW.h5'; |
| 294 | + f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.Overwrite); |
| 295 | + b = f.createBlock('extentsTest', 'nixBlock'); |
| 296 | + da = b.create_data_array('extentsTestDataArray', 'nixDataArray', 'double', [1 2 3 4 5 6; 1 2 3 4 5 6]); |
| 297 | + getMTag = b.create_multi_tag('extentstest', 'nixMultiTag', da); |
295 | 298 |
|
296 |
| -% tmp = b.create_data_array('positionsTest1', 'nixDataArray', 'double', [1, 1]); |
297 |
| -% tmp = b.create_data_array('positionsTest2', 'nixDataArray', 'double', [1, 3]); |
| 299 | + tmp = b.create_data_array('positionsTest1', 'nixDataArray', 'double', [1, 1]); |
| 300 | + tmp = b.create_data_array('positionsTest2', 'nixDataArray', 'double', [1, 3]); |
298 | 301 |
|
299 |
| -% tmp = b.create_data_array('extentsTest1', 'nixDataArray', 'double', [1, 1]); |
300 |
| -% tmp = b.create_data_array('extentsTest2', 'nixDataArray', 'double', [1, 1]); |
| 302 | + extName1 = 'extentsTest1'; |
| 303 | + extName2 = 'extentsTest2'; |
| 304 | + tmp = b.create_data_array(extName1, 'nixDataArray', 'double', [1, 1]); |
| 305 | + tmp = b.create_data_array(extName2, 'nixDataArray', 'double', [1, 3]); |
301 | 306 |
|
302 |
| -% getMTag.add_positions(b.dataArrays{2}); |
303 |
| -% getMTag.add_extents(b.dataArrays{4}.id); |
304 |
| -% assert(strcmp(getMTag.open_extents.name, 'extentsTest1')); |
305 |
| - |
306 |
| -% getMTag.add_positions(b.dataArrays{3}); |
307 |
| -% getMTag.add_extents(b.dataArrays{5}); |
308 |
| -% assert(strcmp(getMTag.open_extents.name, 'extentsTest2')); |
309 |
| - disp('Test MultiTag: add extents ... TODO (add dimensions required)'); |
310 |
| -end |
| 307 | + assert(isempty(getMTag.open_extents)); |
| 308 | + |
| 309 | + getMTag.add_positions(b.dataArrays{2}); |
| 310 | + getMTag.set_extents(b.dataArrays{4}.id); |
| 311 | + assert(strcmp(getMTag.open_extents.name, extName1)); |
311 | 312 |
|
312 |
| -%% Test: Open extents |
313 |
| -function [] = test_open_extents( varargin ) |
314 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
315 |
| - getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
316 |
| - |
317 |
| - getMultiTag = getBlock.open_multi_tag(getBlock.multiTags{1,1}.id); |
318 |
| - assert(isempty(getMultiTag.open_extents)); |
319 |
| - |
320 |
| - %-- ToDo implement test for existing extents |
321 |
| - %getMultiTag = getBlock.open_multi_tag(getBlock.multiTags{1,1}.id); |
322 |
| - %assert(~isempty(getMultiTag.open_positions)); |
323 |
| - disp('Test MultiTag: open existing extents ... TODO (proper testfile)'); |
| 313 | + getMTag.set_extents(''); |
| 314 | + assert(isempty(getMTag.open_extents)); |
| 315 | + |
| 316 | + getMTag.add_positions(b.dataArrays{3}); |
| 317 | + getMTag.set_extents(b.dataArrays{5}); |
| 318 | + |
| 319 | + clear tmp getMTag da b f; |
| 320 | + f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.ReadOnly); |
| 321 | + assert(strcmp(f.blocks{1}.multiTags{1}.open_extents.name, extName2)); |
324 | 322 | end
|
325 | 323 |
|
326 | 324 | %% Test: Set metadata
|
|
368 | 366 | % TODO
|
369 | 367 | disp('Test MultiTag: retrieve feature ... TODO (proper testfile)');
|
370 | 368 | end
|
| 369 | + |
| 370 | +%% Test: nix.MultiTag has feature by ID |
| 371 | +function [] = test_has_feature( varargin ) |
| 372 | + fileName = 'testRW.h5'; |
| 373 | + f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.Overwrite); |
| 374 | + b = f.createBlock('featureTest', 'nixBlock'); |
| 375 | + da = b.create_data_array('featureTestDataArray', 'nixDataArray', 'double', [1 2]); |
| 376 | + t = b.create_multi_tag('featureTest', 'nixMultiTag', da); |
| 377 | + daf = b.create_data_array('featTestDA', 'nixDataArray', 'double', [1 2]); |
| 378 | + feature = t.add_feature(daf, nix.LinkType.Tagged); |
| 379 | + featureID = feature.id; |
| 380 | + |
| 381 | + assert(~t.has_feature('I do not exist')); |
| 382 | + assert(t.has_feature(featureID)); |
| 383 | + |
| 384 | + clear feature daf t da b f; |
| 385 | + f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.ReadOnly); |
| 386 | + assert(f.blocks{1}.multiTags{1}.has_feature(featureID)); |
| 387 | +end |
| 388 | + |
| 389 | +%% Test: nix.MultiTag has reference by ID or name |
| 390 | +function [] = test_has_reference( varargin ) |
| 391 | + fileName = 'testRW.h5'; |
| 392 | + daName = 'refTestDataArray'; |
| 393 | + f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.Overwrite); |
| 394 | + b = f.createBlock('referenceTestBlock', 'nixBlock'); |
| 395 | + da = b.create_data_array(daName, 'nixDataArray', 'double', [1 2]); |
| 396 | + t = b.create_multi_tag('referenceTest', 'nixMultiTag', da); |
| 397 | + refName = 'referenceTest'; |
| 398 | + daRef = b.create_data_array(refName, 'nixDataArray', 'double', [3 4]); |
| 399 | + t.add_reference(daRef.id); |
| 400 | + |
| 401 | + assert(~t.has_reference('I do not exist')); |
| 402 | + assert(t.has_reference(daRef.id)); |
| 403 | + |
| 404 | + clear t daRef da b f; |
| 405 | + f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.ReadOnly); |
| 406 | + assert(f.blocks{1}.multiTags{1}.has_reference(refName)); |
| 407 | +end |
| 408 | + |
| 409 | +%% Test: Set units |
| 410 | +function [] = test_set_units( varargin ) |
| 411 | + fileName = 'testRW.h5'; |
| 412 | + daName = 'testDataArray'; |
| 413 | + f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.Overwrite); |
| 414 | + b = f.createBlock('testBlock', 'nixBlock'); |
| 415 | + da = b.create_data_array(daName, 'nixDataArray', 'double', [1 2]); |
| 416 | + t = b.create_multi_tag('unitsTest', 'nixMultiTag', da); |
| 417 | + |
| 418 | + assert(isempty(t.units)); |
| 419 | + units = {'mV'}; |
| 420 | + t.units = {'mV'}; |
| 421 | + assert(isequal(t.units,units)); |
| 422 | + t.units = {}; |
| 423 | + assert(isempty(t.units)); |
| 424 | + newUnits = {'mV', 'uA'}; |
| 425 | + t.units = newUnits; |
| 426 | + |
| 427 | + clear t da b f; |
| 428 | + f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.ReadOnly); |
| 429 | + assert(isequal(f.blocks{1}.multiTags{1}.units, newUnits)); |
| 430 | +end |
0 commit comments