|
21 | 21 | funcs{end+1} = @test_open_tag;
|
22 | 22 | funcs{end+1} = @test_open_multitag;
|
23 | 23 | funcs{end+1} = @test_open_source;
|
| 24 | + funcs{end+1} = @test_has_data_array; |
| 25 | + funcs{end+1} = @test_has_source; |
24 | 26 | funcs{end+1} = @test_has_multitag;
|
25 | 27 | funcs{end+1} = @test_has_tag;
|
26 | 28 | funcs{end+1} = @test_set_metadata;
|
|
371 | 373 |
|
372 | 374 | assert(strcmp(b.open_metadata.name, 'testSection'));
|
373 | 375 | end
|
| 376 | + |
| 377 | +%% Test: nix.Block has nix.DataArray by ID or name |
| 378 | +function [] = test_has_data_array( varargin ) |
| 379 | + fileName = 'testRW.h5'; |
| 380 | + daName = 'hasDataArrayTest'; |
| 381 | + f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.Overwrite); |
| 382 | + b = f.createBlock('testblock', 'nixBlock'); |
| 383 | + da = b.create_data_array(daName, 'nixDataArray', 'double', [1 2]); |
| 384 | + daID = da.id; |
| 385 | + |
| 386 | + assert(~b.has_data_array('I do not exist')); |
| 387 | + assert(b.has_data_array(daName)); |
| 388 | + |
| 389 | + clear da b f; |
| 390 | + f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.ReadOnly); |
| 391 | + assert(f.blocks{1}.has_data_array(daID)); |
| 392 | +end |
| 393 | + |
| 394 | +%% Test: nix.Block has nix.Source by ID or name |
| 395 | +function [] = test_has_source( varargin ) |
| 396 | + fileName = 'testRW.h5'; |
| 397 | + sName = 'sourcetest1'; |
| 398 | + f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.Overwrite); |
| 399 | + b = f.createBlock('testblock', 'nixBlock'); |
| 400 | + s = b.create_source(sName, 'nixSource'); |
| 401 | + sID = s.id; |
| 402 | + |
| 403 | + assert(~b.has_source('I do not exist')); |
| 404 | + assert(b.has_source(sName)); |
| 405 | + |
| 406 | + clear s b f; |
| 407 | + f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.ReadOnly); |
| 408 | + assert(f.blocks{1}.has_source(sID)); |
| 409 | +end |
0 commit comments