|
28 | 28 | funcs{end+1} = @test_link;
|
29 | 29 | funcs{end+1} = @test_inherited_properties;
|
30 | 30 | funcs{end+1} = @test_referring_data_arrays;
|
| 31 | + funcs{end+1} = @test_referring_block_data_arrays; |
31 | 32 | funcs{end+1} = @test_referring_tags;
|
32 | 33 | funcs{end+1} = @test_referring_block_tags;
|
33 | 34 | funcs{end+1} = @test_referring_multi_tags;
|
|
351 | 352 | assert(isempty(s.referring_data_arrays));
|
352 | 353 | end
|
353 | 354 |
|
| 355 | +%% Test: referring block data arrays |
| 356 | +function [] = test_referring_block_data_arrays( varargin ) |
| 357 | + err = 'Provide either empty arguments or a single Block entity'; |
| 358 | + testName = 'testDataArray1'; |
| 359 | + |
| 360 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 361 | + b1 = f.create_block('testBlock1', 'nixBlock'); |
| 362 | + d1 = b1.create_data_array(testName, 'nixDataArray', nix.DataType.Double, [1 2]); |
| 363 | + b2 = f.create_block('testBlock2', 'nixBlock'); |
| 364 | + d2 = b2.create_data_array('testDataArray2', 'nixDataArray', nix.DataType.Double, [1 2]); |
| 365 | + s = f.create_section('testSection', 'nixSection'); |
| 366 | + |
| 367 | + d1.set_metadata(s); |
| 368 | + d2.set_metadata(s); |
| 369 | + |
| 370 | + % test multiple arguments fail |
| 371 | + try |
| 372 | + s.referring_data_arrays('a', 'b'); |
| 373 | + catch ME |
| 374 | + assert(strcmp(ME.message, err)); |
| 375 | + end |
| 376 | + |
| 377 | + % test non block entity argument fail |
| 378 | + try |
| 379 | + s.referring_data_arrays(s); |
| 380 | + catch ME |
| 381 | + assert(strcmp(ME.message, err)); |
| 382 | + end |
| 383 | + |
| 384 | + % test return only tags from block 1 |
| 385 | + testDataArray = s.referring_data_arrays(b1); |
| 386 | + assert(size(testDataArray, 2) == 1); |
| 387 | + assert(strcmp(testDataArray{1}.name, testName)); |
| 388 | +end |
| 389 | + |
354 | 390 | %% Test: referring tags
|
355 | 391 | function [] = test_referring_tags( varargin )
|
356 | 392 | f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
|
|
0 commit comments