|
29 | 29 | funcs{end+1} = @test_open_tag;
|
30 | 30 | funcs{end+1} = @test_open_multitag;
|
31 | 31 | funcs{end+1} = @test_open_source;
|
| 32 | + funcs{end+1} = @test_open_group_idx; |
| 33 | + funcs{end+1} = @test_open_data_array_idx; |
| 34 | + funcs{end+1} = @test_open_tag_idx; |
| 35 | + funcs{end+1} = @test_open_multi_tag_idx; |
| 36 | + funcs{end+1} = @test_open_source_idx; |
32 | 37 | funcs{end+1} = @test_has_data_array;
|
33 | 38 | funcs{end+1} = @test_has_source;
|
34 | 39 | funcs{end+1} = @test_has_multitag;
|
|
417 | 422 | assert(isempty(getSource));
|
418 | 423 | end
|
419 | 424 |
|
| 425 | +function [] = test_open_group_idx( varargin ) |
| 426 | +%% Test Open Group by index |
| 427 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 428 | + b = f.create_block('testBlock', 'nixBlock'); |
| 429 | + g1 = b.create_group('testGroup1', 'nixGroup'); |
| 430 | + g2 = b.create_group('testGroup2', 'nixGroup'); |
| 431 | + g3 = b.create_group('testGroup3', 'nixGroup'); |
| 432 | + |
| 433 | + assert(strcmp(f.blocks{1}.open_group_idx(0).name, g1.name)); |
| 434 | + assert(strcmp(f.blocks{1}.open_group_idx(1).name, g2.name)); |
| 435 | + assert(strcmp(f.blocks{1}.open_group_idx(2).name, g3.name)); |
| 436 | +end |
| 437 | + |
| 438 | +function [] = test_open_data_array_idx( varargin ) |
| 439 | +%% Test Open DataArray by index |
| 440 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 441 | + b = f.create_block('testBlock', 'nixBlock'); |
| 442 | + d1 = b.create_data_array('testDataArray1', 'nixDataArray', nix.DataType.Double, [3 2]); |
| 443 | + d2 = b.create_data_array('testDataArray2', 'nixDataArray', nix.DataType.Double, [6 2]); |
| 444 | + d3 = b.create_data_array('testDataArray3', 'nixDataArray', nix.DataType.Double, [9 2]); |
| 445 | + |
| 446 | + assert(strcmp(f.blocks{1}.open_data_array_idx(0).name, d1.name)); |
| 447 | + assert(strcmp(f.blocks{1}.open_data_array_idx(1).name, d2.name)); |
| 448 | + assert(strcmp(f.blocks{1}.open_data_array_idx(2).name, d3.name)); |
| 449 | +end |
| 450 | + |
| 451 | +function [] = test_open_tag_idx( varargin ) |
| 452 | +%% Test Open Tag by index |
| 453 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 454 | + b = f.create_block('testBlock', 'nixBlock'); |
| 455 | + t1 = b.create_tag('testTag1', 'nixTag', [1 2]); |
| 456 | + t2 = b.create_tag('testTag2', 'nixTag', [1 2]); |
| 457 | + t3 = b.create_tag('testTag3', 'nixTag', [1 2]); |
| 458 | + |
| 459 | + assert(strcmp(f.blocks{1}.open_tag_idx(0).name, t1.name)); |
| 460 | + assert(strcmp(f.blocks{1}.open_tag_idx(1).name, t2.name)); |
| 461 | + assert(strcmp(f.blocks{1}.open_tag_idx(2).name, t3.name)); |
| 462 | +end |
| 463 | + |
| 464 | +function [] = test_open_multi_tag_idx( varargin ) |
| 465 | +%% Test Open MultiTag by index |
| 466 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 467 | + b = f.create_block('testBlock', 'nixBlock'); |
| 468 | + d = b.create_data_array('testDataArray', 'nixDataArray', nix.DataType.Bool, [2 3]); |
| 469 | + t1 = b.create_multi_tag('testMultiTag1', 'nixMultiTag', d); |
| 470 | + t2 = b.create_multi_tag('testMultiTag2', 'nixMultiTag', d); |
| 471 | + t3 = b.create_multi_tag('testMultiTag3', 'nixMultiTag', d); |
| 472 | + |
| 473 | + assert(strcmp(f.blocks{1}.open_multi_tag_idx(0).name, t1.name)); |
| 474 | + assert(strcmp(f.blocks{1}.open_multi_tag_idx(1).name, t2.name)); |
| 475 | + assert(strcmp(f.blocks{1}.open_multi_tag_idx(2).name, t3.name)); |
| 476 | +end |
| 477 | + |
| 478 | +function [] = test_open_source_idx( varargin ) |
| 479 | +%% Test Open Source by index |
| 480 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 481 | + b = f.create_block('testBlock', 'nixBlock'); |
| 482 | + s1 = b.create_source('testSource1', 'nixSource'); |
| 483 | + s2 = b.create_source('testSource2', 'nixSource'); |
| 484 | + s3 = b.create_source('testSource3', 'nixSource'); |
| 485 | + |
| 486 | + assert(strcmp(f.blocks{1}.open_source_idx(0).name, s1.name)); |
| 487 | + assert(strcmp(f.blocks{1}.open_source_idx(1).name, s2.name)); |
| 488 | + assert(strcmp(f.blocks{1}.open_source_idx(2).name, s3.name)); |
| 489 | +end |
| 490 | + |
420 | 491 | function [] = test_has_multitag( varargin )
|
421 | 492 | %% Test: Block has multi tag by ID or name
|
422 | 493 | f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
|
|
0 commit comments