|
12 | 12 |
|
13 | 13 | funcs = {};
|
14 | 14 | funcs{end+1} = @test_add_source;
|
| 15 | + funcs{end+1} = @test_add_sources; |
15 | 16 | funcs{end+1} = @test_remove_source;
|
16 | 17 | funcs{end+1} = @test_add_reference;
|
| 18 | + funcs{end+1} = @test_add_references; |
17 | 19 | funcs{end+1} = @test_remove_reference;
|
18 | 20 | funcs{end+1} = @test_add_feature;
|
19 | 21 | funcs{end+1} = @test_remove_feature;
|
|
59 | 61 | assert(size(f.blocks{1}.tags{1}.sources, 1) == 2);
|
60 | 62 | end
|
61 | 63 |
|
| 64 | +%% Test: Add sources by entity cell array |
| 65 | +function [] = test_add_sources ( varargin ) |
| 66 | + testFile = fullfile(pwd, 'tests', 'testRW.h5'); |
| 67 | + f = nix.File(testFile, nix.FileMode.Overwrite); |
| 68 | + b = f.create_block('testBlock', 'nixBlock'); |
| 69 | + t = b.create_tag('testTag', 'nixTag', [1 2]); |
| 70 | + tmp = b.create_source('testSource1', 'nixSource'); |
| 71 | + tmp = b.create_source('testSource2', 'nixSource'); |
| 72 | + tmp = b.create_source('testSource3', 'nixSource'); |
| 73 | + |
| 74 | + assert(isempty(t.sources)); |
| 75 | + |
| 76 | + try |
| 77 | + t.add_sources('hurra'); |
| 78 | + catch ME |
| 79 | + assert(strcmp(ME.message, 'Expected cell array')); |
| 80 | + end; |
| 81 | + assert(isempty(t.sources)); |
| 82 | + |
| 83 | + try |
| 84 | + t.add_sources({12, 13}); |
| 85 | + catch ME |
| 86 | + assert(~isempty(strfind(ME.message, 'not a nix.Source'))); |
| 87 | + end; |
| 88 | + assert(isempty(t.sources)); |
| 89 | + |
| 90 | + t.add_sources(b.sources()); |
| 91 | + assert(size(t.sources, 1) == 3); |
| 92 | + |
| 93 | + clear t tmp b f; |
| 94 | + f = nix.File(testFile, nix.FileMode.ReadOnly); |
| 95 | + assert(size(f.blocks{1}.tags{1}.sources, 1) == 3); |
| 96 | +end |
| 97 | + |
62 | 98 | %% Test: Remove sources by entity and id
|
63 | 99 | function [] = test_remove_source ( varargin )
|
64 | 100 | test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
|
|
104 | 140 | assert(size(f.blocks{1}.tags{1}.references, 1) == 2);
|
105 | 141 | end
|
106 | 142 |
|
| 143 | +%% Test: Add references by entity cell array |
| 144 | +function [] = test_add_references ( varargin ) |
| 145 | + testFile = fullfile(pwd, 'tests', 'testRW.h5'); |
| 146 | + f = nix.File(testFile, nix.FileMode.Overwrite); |
| 147 | + b = f.create_block('testBlock', 'nixBlock'); |
| 148 | + t = b.create_tag('testTag', 'nixTag', [1 2]); |
| 149 | + tmp = b.create_data_array('referenceTest1', 'nixDataArray', nix.DataType.Double, [1 2]); |
| 150 | + tmp = b.create_data_array('referenceTest2', 'nixDataArray', nix.DataType.Double, [3 4]); |
| 151 | + tmp = b.create_data_array('referenceTest3', 'nixDataArray', nix.DataType.Double, [3 4]); |
| 152 | + |
| 153 | + assert(isempty(t.references)); |
| 154 | + |
| 155 | + try |
| 156 | + t.add_references('hurra'); |
| 157 | + catch ME |
| 158 | + assert(strcmp(ME.message, 'Expected cell array')); |
| 159 | + end; |
| 160 | + assert(isempty(t.references)); |
| 161 | + |
| 162 | + try |
| 163 | + t.add_references({12, 13}); |
| 164 | + catch ME |
| 165 | + assert(~isempty(strfind(ME.message, 'not a nix.DataArray'))); |
| 166 | + end; |
| 167 | + assert(isempty(t.references)); |
| 168 | + |
| 169 | + t.add_references(b.dataArrays); |
| 170 | + assert(size(t.references, 1) == 3); |
| 171 | + |
| 172 | + clear t tmp b f; |
| 173 | + f = nix.File(testFile, nix.FileMode.ReadOnly); |
| 174 | + assert(size(f.blocks{1}.tags{1}.references, 1) == 3); |
| 175 | +end |
| 176 | + |
107 | 177 | %% Test: Remove references by entity and id
|
108 | 178 | function [] = test_remove_reference ( varargin )
|
109 | 179 | test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
|
|
0 commit comments