|
172 | 172 |
|
173 | 173 | %% Test: fetch features
|
174 | 174 | function [] = test_fetch_features( varargin )
|
175 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
176 |
| - getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
177 |
| - getTag = getBlock.open_tag(getBlock.tags{1,1}.id); |
| 175 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 176 | + b = f.createBlock('featureTest', 'nixBlock'); |
| 177 | + tmp = b.create_data_array('featureTestDataArray1', 'nixDataArray', 'double', [1 2]); |
| 178 | + tmp = b.create_data_array('featureTestDataArray2', 'nixDataArray', 'double', [3 4]); |
| 179 | + position = [1.0 1.2 1.3 15.9]; |
| 180 | + getTag = b.create_tag('featureTest', 'nixTag', position); |
| 181 | + |
| 182 | + tmp = getTag.add_feature(b.dataArrays{1}, nix.LinkType.Tagged); |
| 183 | + tmp = getTag.add_feature(b.dataArrays{2}, nix.LinkType.Tagged); |
178 | 184 |
|
179 |
| - %-- ToDo get testfile with tag referencing a source |
180 |
| - assert(size(getTag.features(),1) == 0); |
181 |
| - disp('Test Tag: fetch features ... TODO (proper testfile)'); |
| 185 | + assert(size(getTag.features, 1) == 2); |
182 | 186 | end
|
183 | 187 |
|
184 | 188 | %% Test: Open source by ID or name
|
|
199 | 203 | assert(~isempty(getSourceByName));
|
200 | 204 |
|
201 | 205 | %-- test open non existing source
|
202 |
| - getNonSource = getTag.open_source('I dont exist'); |
| 206 | + getNonSource = getTag.open_source('I do not exist'); |
203 | 207 | assert(isempty(getNonSource));
|
204 | 208 | end
|
205 | 209 |
|
206 | 210 |
|
207 |
| -%% Test: Open feature by ID or name |
| 211 | +%% Test: Open feature by ID |
208 | 212 | function [] = test_open_feature( varargin )
|
209 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
210 |
| - getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
211 |
| - getTag = getBlock.open_tag(getBlock.tags{1,1}.id); |
212 |
| - |
213 |
| - %-- TODO: implement testfile with feature referenced from a tag |
214 |
| - %getFeatByID = getTag.open_feature(getTag.features{1,1}.id); |
215 |
| - %assert(strcmp(getFeatByID.id, '')); |
216 |
| - disp('Test Tag: open feature by ID ... TODO (proper testfile)'); |
| 213 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 214 | + b = f.createBlock('featureTest', 'nixBlock'); |
| 215 | + tmp = b.create_data_array('featureTestDataArray', 'nixDataArray', 'double', [1 2]); |
| 216 | + position = [1.0 1.2 1.3 15.9]; |
| 217 | + getTag = b.create_tag('featureTest', 'nixTag', position); |
| 218 | + tmp = getTag.add_feature(b.dataArrays{1}, nix.LinkType.Tagged); |
| 219 | + |
| 220 | + assert(~isempty(getTag.open_feature(getTag.features{1}.id))); |
217 | 221 |
|
218 |
| - %getFeatByName = getTag.open_feature(getTag.features{1,1}.name); |
219 |
| - %assert(strcmp(getFeatByName.id, '')); |
220 |
| - disp('Test Tag: open feature by name ... TODO (proper testfile)'); |
221 |
| - |
222 | 222 | %-- test open non existing feature
|
223 |
| - getFeat = getTag.open_feature('I dont exist'); |
| 223 | + getFeat = getTag.open_feature('I do not exist'); |
224 | 224 | assert(isempty(getFeat));
|
225 | 225 | end
|
226 | 226 |
|
|
241 | 241 | assert(~isempty(getRefByName));
|
242 | 242 |
|
243 | 243 | %-- test open non existing source
|
244 |
| - getNonRef = getTag.open_reference('I dont exist'); |
| 244 | + getNonRef = getTag.open_reference('I do not exist'); |
245 | 245 | assert(isempty(getNonRef));
|
246 | 246 | end
|
247 | 247 |
|
|
0 commit comments