|
37 | 37 | funcs{end+1} = @test_source_count;
|
38 | 38 | funcs{end+1} = @test_set_metadata;
|
39 | 39 | funcs{end+1} = @test_open_metadata;
|
| 40 | + funcs{end+1} = @test_open_data_array_idx; |
| 41 | + funcs{end+1} = @test_open_tag_idx; |
| 42 | + funcs{end+1} = @test_open_multi_tag_idx; |
| 43 | + funcs{end+1} = @test_open_source_idx; |
40 | 44 | end
|
41 | 45 |
|
42 | 46 | %% Test: Access nix.Group attributes
|
|
780 | 784 |
|
781 | 785 | assert(strcmp(g.open_metadata.name, 'testSection'));
|
782 | 786 | end
|
| 787 | + |
| 788 | +function [] = test_open_data_array_idx( varargin ) |
| 789 | +%% Test Open DataArray by index |
| 790 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 791 | + b = f.create_block('testBlock', 'nixBlock'); |
| 792 | + g = b.create_group('testGroup', 'nixGroup'); |
| 793 | + d1 = b.create_data_array('testDataArray1', 'nixDataArray', nix.DataType.Double, [3 2]); |
| 794 | + d2 = b.create_data_array('testDataArray2', 'nixDataArray', nix.DataType.Double, [6 2]); |
| 795 | + d3 = b.create_data_array('testDataArray3', 'nixDataArray', nix.DataType.Double, [9 2]); |
| 796 | + g.add_data_array(d1); |
| 797 | + g.add_data_array(d2); |
| 798 | + g.add_data_array(d3); |
| 799 | + |
| 800 | + assert(strcmp(f.blocks{1}.groups{1}.open_data_array_idx(0).name, d1.name)); |
| 801 | + assert(strcmp(f.blocks{1}.groups{1}.open_data_array_idx(1).name, d2.name)); |
| 802 | + assert(strcmp(f.blocks{1}.groups{1}.open_data_array_idx(2).name, d3.name)); |
| 803 | +end |
| 804 | + |
| 805 | +function [] = test_open_tag_idx( varargin ) |
| 806 | +%% Test Open Tag by index |
| 807 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 808 | + b = f.create_block('testBlock', 'nixBlock'); |
| 809 | + g = b.create_group('testGroup', 'nixGroup'); |
| 810 | + t1 = b.create_tag('testTag1', 'nixTag', [1 2]); |
| 811 | + t2 = b.create_tag('testTag2', 'nixTag', [1 2]); |
| 812 | + t3 = b.create_tag('testTag3', 'nixTag', [1 2]); |
| 813 | + g.add_tag(t1); |
| 814 | + g.add_tag(t2); |
| 815 | + g.add_tag(t3); |
| 816 | + |
| 817 | + assert(strcmp(f.blocks{1}.groups{1}.open_tag_idx(0).name, t1.name)); |
| 818 | + assert(strcmp(f.blocks{1}.groups{1}.open_tag_idx(1).name, t2.name)); |
| 819 | + assert(strcmp(f.blocks{1}.groups{1}.open_tag_idx(2).name, t3.name)); |
| 820 | +end |
| 821 | + |
| 822 | +function [] = test_open_multi_tag_idx( varargin ) |
| 823 | +%% Test Open MultiTag by index |
| 824 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 825 | + b = f.create_block('testBlock', 'nixBlock'); |
| 826 | + g = b.create_group('testGroup', 'nixGroup'); |
| 827 | + d = b.create_data_array('testDataArray', 'nixDataArray', nix.DataType.Bool, [2 3]); |
| 828 | + t1 = b.create_multi_tag('testMultiTag1', 'nixMultiTag', d); |
| 829 | + t2 = b.create_multi_tag('testMultiTag2', 'nixMultiTag', d); |
| 830 | + t3 = b.create_multi_tag('testMultiTag3', 'nixMultiTag', d); |
| 831 | + g.add_multi_tag(t1); |
| 832 | + g.add_multi_tag(t2); |
| 833 | + g.add_multi_tag(t3); |
| 834 | + |
| 835 | + assert(strcmp(f.blocks{1}.groups{1}.open_multi_tag_idx(0).name, t1.name)); |
| 836 | + assert(strcmp(f.blocks{1}.groups{1}.open_multi_tag_idx(1).name, t2.name)); |
| 837 | + assert(strcmp(f.blocks{1}.groups{1}.open_multi_tag_idx(2).name, t3.name)); |
| 838 | +end |
| 839 | + |
| 840 | +function [] = test_open_source_idx( varargin ) |
| 841 | +%% Test Open Source by index |
| 842 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 843 | + b = f.create_block('testBlock', 'nixBlock'); |
| 844 | + g = b.create_group('testGroup', 'nixGroup'); |
| 845 | + s1 = b.create_source('testSource1', 'nixSource'); |
| 846 | + s2 = b.create_source('testSource2', 'nixSource'); |
| 847 | + s3 = b.create_source('testSource3', 'nixSource'); |
| 848 | + g.add_source(s1); |
| 849 | + g.add_source(s2); |
| 850 | + g.add_source(s3); |
| 851 | + |
| 852 | + assert(strcmp(f.blocks{1}.groups{1}.open_source_idx(0).name, s1.name)); |
| 853 | + assert(strcmp(f.blocks{1}.groups{1}.open_source_idx(1).name, s2.name)); |
| 854 | + assert(strcmp(f.blocks{1}.groups{1}.open_source_idx(2).name, s3.name)); |
| 855 | +end |
0 commit comments