|
26 | 26 |
|
27 | 27 | %% Test: Add sources by entity and id
|
28 | 28 | function [] = test_add_source ( varargin )
|
29 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
30 |
| - getBlock = test_file.createBlock('sourceTest', 'nixBlock'); |
31 |
| - getSource = getBlock.create_source('sourceTest', 'nixSource'); |
32 |
| - tmp = getSource.create_source('nestedSource1', 'nixSource'); |
33 |
| - tmp = getSource.create_source('nestedSource2', 'nixSource'); |
| 29 | + fileName = fullfile(pwd, 'tests', 'testRW.h5'); |
| 30 | + f = nix.File(fileName, nix.FileMode.Overwrite); |
| 31 | + b = f.createBlock('sourceTest', 'nixBlock'); |
| 32 | + s = b.create_source('sourceTest', 'nixSource'); |
| 33 | + tmp = s.create_source('nestedSource1', 'nixSource'); |
| 34 | + tmp = s.create_source('nestedSource2', 'nixSource'); |
34 | 35 | position = [1.0 1.2 1.3 15.9];
|
35 |
| - getTag = getBlock.create_tag('sourcetest', 'nixTag', position); |
| 36 | + t = b.create_tag('sourcetest', 'nixTag', position); |
36 | 37 |
|
37 |
| - assert(isempty(getTag.sources)); |
38 |
| - getTag.add_source(getSource.sources{1}.id); |
39 |
| - getTag.add_source(getSource.sources{2}); |
40 |
| - assert(size(getTag.sources,1) == 2); |
| 38 | + assert(isempty(t.sources)); |
| 39 | + assert(isempty(f.blocks{1}.tags{1}.sources)); |
| 40 | + t.add_source(s.sources{1}.id); |
| 41 | + t.add_source(s.sources{2}); |
| 42 | + assert(size(t.sources, 1) == 2); |
| 43 | + assert(size(f.blocks{1}.tags{1}.sources, 1) == 2); |
| 44 | + |
| 45 | + clear tmp t s b f; |
| 46 | + f = nix.File(fileName, nix.FileMode.ReadOnly); |
| 47 | + assert(size(f.blocks{1}.tags{1}.sources, 1) == 2); |
41 | 48 | end
|
42 | 49 |
|
43 | 50 | %% Test: Remove sources by entity and id
|
|
63 | 70 |
|
64 | 71 | %% Test: Add references by entity and id
|
65 | 72 | function [] = test_add_reference ( varargin )
|
66 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
67 |
| - getBlock = test_file.createBlock('referenceTest', 'nixBlock'); |
68 |
| - tmp = getBlock.create_data_array('referenceTest1', 'nixDataArray', 'double', [1 2]); |
69 |
| - tmp = getBlock.create_data_array('referenceTest2', 'nixDataArray', 'double', [3 4]); |
| 73 | + fileName = fullfile(pwd, 'tests', 'testRW.h5'); |
| 74 | + f = nix.File(fileName, nix.FileMode.Overwrite); |
| 75 | + b = f.createBlock('referenceTest', 'nixBlock'); |
| 76 | + tmp = b.create_data_array('referenceTest1', 'nixDataArray', 'double', [1 2]); |
| 77 | + tmp = b.create_data_array('referenceTest2', 'nixDataArray', 'double', [3 4]); |
70 | 78 |
|
71 | 79 | position = [1.0 1.2 1.3 15.9];
|
72 |
| - getTag = getBlock.create_tag('referenceTest', 'nixTag', position); |
| 80 | + t = b.create_tag('referenceTest', 'nixTag', position); |
73 | 81 |
|
74 |
| - assert(isempty(getTag.references)); |
75 |
| - getTag.add_reference(getBlock.dataArrays{1}.id); |
76 |
| - getTag.add_reference(getBlock.dataArrays{2}); |
77 |
| - assert(size(getTag.references, 1) == 2); |
| 82 | + assert(isempty(t.references)); |
| 83 | + assert(isempty(f.blocks{1}.tags{1}.references)); |
| 84 | + |
| 85 | + t.add_reference(b.dataArrays{1}.id); |
| 86 | + t.add_reference(b.dataArrays{2}); |
| 87 | + assert(size(t.references, 1) == 2); |
| 88 | + assert(size(f.blocks{1}.tags{1}.references, 1) == 2); |
| 89 | + |
| 90 | + clear tmp t b f; |
| 91 | + f = nix.File(fileName, nix.FileMode.ReadOnly); |
| 92 | + assert(size(f.blocks{1}.tags{1}.references, 1) == 2); |
78 | 93 | end
|
79 | 94 |
|
80 | 95 | %% Test: Remove references by entity and id
|
|
100 | 115 |
|
101 | 116 | %% Test: Add features by entity and id
|
102 | 117 | function [] = test_add_feature ( varargin )
|
103 |
| - f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 118 | + fileName = fullfile(pwd, 'tests', 'testRW.h5'); |
| 119 | + f = nix.File(fileName, nix.FileMode.Overwrite); |
104 | 120 | b = f.createBlock('featureTest', 'nixBlock');
|
105 | 121 | tmp = b.create_data_array('featureTestDataArray1', 'nixDataArray', 'double', [1 2]);
|
106 | 122 | tmp = b.create_data_array('featureTestDataArray2', 'nixDataArray', 'double', [3 4]);
|
|
109 | 125 | tmp = b.create_data_array('featureTestDataArray5', 'nixDataArray', 'double', [9 10]);
|
110 | 126 | tmp = b.create_data_array('featureTestDataArray6', 'nixDataArray', 'double', [11 12]);
|
111 | 127 | position = [1.0 1.2 1.3 15.9];
|
112 |
| - getTag = b.create_tag('featureTest', 'nixTag', position); |
| 128 | + t = b.create_tag('featureTest', 'nixTag', position); |
113 | 129 |
|
114 |
| - assert(isempty(getTag.features)); |
115 |
| - tmp = getTag.add_feature(b.dataArrays{1}.id, nix.LinkType.Tagged); |
116 |
| - tmp = getTag.add_feature(b.dataArrays{2}, nix.LinkType.Tagged); |
117 |
| - tmp = getTag.add_feature(b.dataArrays{3}.id, nix.LinkType.Untagged); |
118 |
| - tmp = getTag.add_feature(b.dataArrays{4}, nix.LinkType.Untagged); |
119 |
| - tmp = getTag.add_feature(b.dataArrays{5}.id, nix.LinkType.Indexed); |
120 |
| - tmp = getTag.add_feature(b.dataArrays{6}, nix.LinkType.Indexed); |
121 |
| - assert(size(getTag.features, 1) == 6) |
| 130 | + assert(isempty(t.features)); |
| 131 | + assert(isempty(f.blocks{1}.tags{1}.features)); |
| 132 | + tmp = t.add_feature(b.dataArrays{1}.id, nix.LinkType.Tagged); |
| 133 | + tmp = t.add_feature(b.dataArrays{2}, nix.LinkType.Tagged); |
| 134 | + tmp = t.add_feature(b.dataArrays{3}.id, nix.LinkType.Untagged); |
| 135 | + tmp = t.add_feature(b.dataArrays{4}, nix.LinkType.Untagged); |
| 136 | + tmp = t.add_feature(b.dataArrays{5}.id, nix.LinkType.Indexed); |
| 137 | + tmp = t.add_feature(b.dataArrays{6}, nix.LinkType.Indexed); |
| 138 | + assert(size(t.features, 1) == 6); |
| 139 | + assert(size(f.blocks{1}.tags{1}.features, 1) == 6); |
| 140 | + |
| 141 | + clear tmp t b f; |
| 142 | + f = nix.File(fileName, nix.FileMode.ReadOnly); |
| 143 | + assert(size(f.blocks{1}.tags{1}.features, 1) == 6); |
122 | 144 | end
|
123 | 145 |
|
124 | 146 | %% Test: Remove features by entity and id
|
|
0 commit comments