|
30 | 30 |
|
31 | 31 | %% Test: Add sources by entity and id
|
32 | 32 | function [] = test_add_source ( varargin )
|
33 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
34 |
| - b = test_file.createBlock('sourceTest', 'nixBlock'); |
| 33 | + fileName = fullfile(pwd, 'tests', 'testRW.h5'); |
| 34 | + f = nix.File(fileName, nix.FileMode.Overwrite); |
| 35 | + b = f.createBlock('sourceTest', 'nixBlock'); |
35 | 36 | tmp = b.create_data_array('sourceTestDataArray', 'nixDataArray', 'double', [1 2]);
|
36 |
| - getSource = b.create_source('sourceTest', 'nixSource'); |
37 |
| - tmp = getSource.create_source('nestedSource1', 'nixSource'); |
38 |
| - tmp = getSource.create_source('nestedSource2', 'nixSource'); |
39 |
| - getMTag = b.create_multi_tag('sourcetest', 'nixMultiTag', b.dataArrays{1}); |
| 37 | + s = b.create_source('sourceTest', 'nixSource'); |
| 38 | + tmp = s.create_source('nestedSource1', 'nixSource'); |
| 39 | + tmp = s.create_source('nestedSource2', 'nixSource'); |
| 40 | + mTag = b.create_multi_tag('sourcetest', 'nixMultiTag', b.dataArrays{1}); |
40 | 41 |
|
41 |
| - assert(isempty(getMTag.sources)); |
42 |
| - getMTag.add_source(getSource.sources{1}.id); |
43 |
| - getMTag.add_source(getSource.sources{2}); |
44 |
| - assert(size(getMTag.sources, 1) == 2); |
| 42 | + assert(isempty(mTag.sources)); |
| 43 | + assert(isempty(f.blocks{1}.multiTags{1}.sources)); |
| 44 | + |
| 45 | + mTag.add_source(s.sources{1}.id); |
| 46 | + assert(size(mTag.sources, 1) == 1); |
| 47 | + assert(size(f.blocks{1}.multiTags{1}.sources, 1) == 1); |
| 48 | + |
| 49 | + mTag.add_source(s.sources{2}); |
| 50 | + assert(size(mTag.sources, 1) == 2); |
| 51 | + assert(size(f.blocks{1}.multiTags{1}.sources, 1) == 2); |
| 52 | + |
| 53 | + clear tmp mTag s b f; |
| 54 | + f = nix.File(fileName, nix.FileMode.ReadOnly); |
| 55 | + assert(size(f.blocks{1}.multiTags{1}.sources, 1) == 2); |
45 | 56 | end
|
46 | 57 |
|
47 | 58 | %% Test: Remove sources by entity and id
|
|
67 | 78 |
|
68 | 79 | %% Test: Add references by entity and id
|
69 | 80 | function [] = test_add_reference ( varargin )
|
70 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
71 |
| - b = test_file.createBlock('referenceTest', 'nixBlock'); |
| 81 | + fileName = fullfile(pwd, 'tests', 'testRW.h5'); |
| 82 | + f = nix.File(fileName, nix.FileMode.Overwrite); |
| 83 | + b = f.createBlock('referenceTest', 'nixBlock'); |
72 | 84 | tmp = b.create_data_array('referenceTestDataArray', 'nixDataArray', 'double', [1 2]);
|
73 |
| - getMTag = b.create_multi_tag('referencetest', 'nixMultiTag', b.dataArrays{1}); |
| 85 | + mTag = b.create_multi_tag('referencetest', 'nixMultiTag', b.dataArrays{1}); |
74 | 86 |
|
75 | 87 | tmp = b.create_data_array('referenceTest1', 'nixDataArray', 'double', [3 4]);
|
76 | 88 | tmp = b.create_data_array('referenceTest2', 'nixDataArray', 'double', [5 6]);
|
77 | 89 |
|
78 |
| - assert(isempty(getMTag.references)); |
79 |
| - getMTag.add_reference(b.dataArrays{2}.id); |
80 |
| - getMTag.add_reference(b.dataArrays{3}); |
81 |
| - assert(size(getMTag.references, 1) == 2); |
| 90 | + assert(isempty(mTag.references)); |
| 91 | + assert(isempty(f.blocks{1}.multiTags{1}.references)); |
| 92 | + |
| 93 | + mTag.add_reference(b.dataArrays{2}.id); |
| 94 | + assert(size(mTag.references, 1) == 1); |
| 95 | + assert(size(f.blocks{1}.multiTags{1}.references, 1) == 1); |
| 96 | + |
| 97 | + mTag.add_reference(b.dataArrays{3}); |
| 98 | + assert(size(mTag.references, 1) == 2); |
| 99 | + assert(size(f.blocks{1}.multiTags{1}.references, 1) == 2); |
| 100 | + |
| 101 | + clear tmp mTag b f; |
| 102 | + f = nix.File(fileName, nix.FileMode.ReadOnly); |
| 103 | + assert(size(f.blocks{1}.multiTags{1}.references, 1) == 2); |
82 | 104 | end
|
83 | 105 |
|
84 | 106 | %% Test: Remove references by entity and id
|
|
103 | 125 |
|
104 | 126 | %% Test: Add features by entity and id
|
105 | 127 | function [] = test_add_feature ( varargin )
|
106 |
| - f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 128 | + fileName = fullfile(pwd, 'tests', 'testRW.h5'); |
| 129 | + f = nix.File(fileName, nix.FileMode.Overwrite); |
107 | 130 | b = f.createBlock('featureTest', 'nixBlock');
|
108 | 131 | tmp = b.create_data_array('featureTestDataArray', 'nixDataArray', 'double', [1 2]);
|
109 |
| - getMTag = b.create_multi_tag('featuretest', 'nixMultiTag', b.dataArrays{1}); |
| 132 | + mTag = b.create_multi_tag('featuretest', 'nixMultiTag', b.dataArrays{1}); |
110 | 133 |
|
111 | 134 | tmp = b.create_data_array('featTestDA1', 'nixDataArray', 'double', [1 2]);
|
112 | 135 | tmp = b.create_data_array('featTestDA2', 'nixDataArray', 'double', [3 4]);
|
|
115 | 138 | tmp = b.create_data_array('featTestDA5', 'nixDataArray', 'double', [9 10]);
|
116 | 139 | tmp = b.create_data_array('featTestDA6', 'nixDataArray', 'double', [11 12]);
|
117 | 140 |
|
118 |
| - assert(isempty(getMTag.features)); |
119 |
| - tmp = getMTag.add_feature(b.dataArrays{2}.id, nix.LinkType.Tagged); |
120 |
| - tmp = getMTag.add_feature(b.dataArrays{3}, nix.LinkType.Tagged); |
121 |
| - tmp = getMTag.add_feature(b.dataArrays{4}.id, nix.LinkType.Untagged); |
122 |
| - tmp = getMTag.add_feature(b.dataArrays{5}, nix.LinkType.Untagged); |
123 |
| - tmp = getMTag.add_feature(b.dataArrays{6}.id, nix.LinkType.Indexed); |
124 |
| - tmp = getMTag.add_feature(b.dataArrays{7}, nix.LinkType.Indexed); |
125 |
| - assert(size(getMTag.features, 1) == 6); |
| 141 | + assert(isempty(mTag.features)); |
| 142 | + assert(isempty(f.blocks{1}.multiTags{1}.features)); |
| 143 | + tmp = mTag.add_feature(b.dataArrays{2}.id, nix.LinkType.Tagged); |
| 144 | + tmp = mTag.add_feature(b.dataArrays{3}, nix.LinkType.Tagged); |
| 145 | + tmp = mTag.add_feature(b.dataArrays{4}.id, nix.LinkType.Untagged); |
| 146 | + tmp = mTag.add_feature(b.dataArrays{5}, nix.LinkType.Untagged); |
| 147 | + tmp = mTag.add_feature(b.dataArrays{6}.id, nix.LinkType.Indexed); |
| 148 | + tmp = mTag.add_feature(b.dataArrays{7}, nix.LinkType.Indexed); |
| 149 | + assert(size(mTag.features, 1) == 6); |
| 150 | + assert(size(f.blocks{1}.multiTags{1}.features, 1) == 6); |
| 151 | + |
| 152 | + clear tmp mTag b f; |
| 153 | + f = nix.File(fileName, nix.FileMode.ReadOnly); |
| 154 | + assert(size(f.blocks{1}.multiTags{1}.features, 1) == 6); |
126 | 155 | end
|
127 | 156 |
|
128 | 157 | %% Test: Remove features by entity and id
|
|
249 | 278 |
|
250 | 279 | %% Test: Add positions by entity and id
|
251 | 280 | function [] = test_add_positions ( varargin )
|
252 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
253 |
| - b = test_file.createBlock('positionsTest', 'nixBlock'); |
| 281 | + fileName = fullfile(pwd, 'tests', 'testRW.h5'); |
| 282 | + posName1 = 'positionsTest1'; |
| 283 | + posName2 = 'positionsTest2'; |
| 284 | + |
| 285 | + f = nix.File(fileName, nix.FileMode.Overwrite); |
| 286 | + b = f.createBlock('positionsTest', 'nixBlock'); |
254 | 287 | tmp = b.create_data_array('positionsTestDataArray', 'nixDataArray', 'double', [1 2 3 4 5 6]);
|
255 |
| - getMTag = b.create_multi_tag('positionstest', 'nixMultiTag', b.dataArrays{1}); |
| 288 | + mTag = b.create_multi_tag('positionstest', 'nixMultiTag', b.dataArrays{1}); |
256 | 289 |
|
257 |
| - tmp = b.create_data_array('positionsTest1', 'nixDataArray', 'double', [0 1]); |
258 |
| - tmp = b.create_data_array('positionsTest2', 'nixDataArray', 'double', [2 4]); |
| 290 | + tmp = b.create_data_array(posName1, 'nixDataArray', 'double', [0 1]); |
| 291 | + tmp = b.create_data_array(posName2, 'nixDataArray', 'double', [2 4]); |
259 | 292 |
|
260 |
| - getMTag.add_positions(b.dataArrays{2}.id); |
261 |
| - assert(strcmp(getMTag.open_positions.name, 'positionsTest1')); |
| 293 | + mTag.add_positions(b.dataArrays{2}.id); |
| 294 | + assert(strcmp(mTag.open_positions.name, posName1)); |
| 295 | + assert(strcmp(f.blocks{1}.multiTags{1}.open_positions.name, posName1)); |
262 | 296 |
|
263 |
| - getMTag.add_positions(b.dataArrays{3}); |
264 |
| - assert(strcmp(getMTag.open_positions.name, 'positionsTest2')); |
| 297 | + mTag.add_positions(b.dataArrays{3}); |
| 298 | + assert(strcmp(mTag.open_positions.name, posName2)); |
| 299 | + assert(strcmp(f.blocks{1}.multiTags{1}.open_positions.name, posName2)); |
| 300 | + |
| 301 | + clear tmp mTag b f; |
| 302 | + f = nix.File(fileName, nix.FileMode.ReadOnly); |
| 303 | + assert(strcmp(f.blocks{1}.multiTags{1}.open_positions.name, posName2)); |
265 | 304 | end
|
266 | 305 |
|
267 | 306 | %% Test: Has positions
|
|
305 | 344 | tmp = b.create_data_array(extName2, 'nixDataArray', 'double', [1, 3]);
|
306 | 345 |
|
307 | 346 | assert(isempty(getMTag.open_extents));
|
| 347 | + assert(isempty(f.blocks{1}.multiTags{1}.open_extents)); |
308 | 348 |
|
309 | 349 | getMTag.add_positions(b.dataArrays{2});
|
310 | 350 | getMTag.set_extents(b.dataArrays{4}.id);
|
311 | 351 | assert(strcmp(getMTag.open_extents.name, extName1));
|
| 352 | + assert(strcmp(f.blocks{1}.multiTags{1}.open_extents.name, extName1)); |
312 | 353 |
|
313 | 354 | getMTag.set_extents('');
|
314 | 355 | assert(isempty(getMTag.open_extents));
|
| 356 | + assert(isempty(f.blocks{1}.multiTags{1}.open_extents)); |
315 | 357 |
|
316 | 358 | getMTag.add_positions(b.dataArrays{3});
|
317 | 359 | getMTag.set_extents(b.dataArrays{5});
|
|
0 commit comments