|
7 | 7 | funcs{end+1} = @test_remove_source;
|
8 | 8 | funcs{end+1} = @test_add_reference;
|
9 | 9 | funcs{end+1} = @test_remove_reference;
|
10 |
| - funcs{end+1} = @test_list_fetch_references; |
11 |
| - funcs{end+1} = @test_list_fetch_sources; |
12 |
| - funcs{end+1} = @test_list_fetch_features; |
| 10 | + funcs{end+1} = @test_fetch_references; |
| 11 | + funcs{end+1} = @test_fetch_sources; |
| 12 | + funcs{end+1} = @test_fetch_features; |
13 | 13 | funcs{end+1} = @test_open_source;
|
14 | 14 | funcs{end+1} = @test_open_feature;
|
15 | 15 | funcs{end+1} = @test_open_reference;
|
|
21 | 21 | %% Test: Add sources by entity and id
|
22 | 22 | function [] = test_add_source ( varargin )
|
23 | 23 | test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
|
24 |
| - getBlock = test_file.createBlock('sourcetest', 'nixblock'); |
25 |
| - getSource = getBlock.create_source('sourcetest','nixsource'); |
26 |
| - createSource1 = getSource.create_source('nestedsource1','nixsource'); |
27 |
| - createSource2 = getSource.create_source('nestedsource2','nixsource'); |
| 24 | + getBlock = test_file.createBlock('sourceTest', 'nixBlock'); |
| 25 | + getSource = getBlock.create_source('sourceTest', 'nixSource'); |
| 26 | + tmp = getSource.create_source('nestedSource1', 'nixSource'); |
| 27 | + tmp = getSource.create_source('nestedSource2', 'nixSource'); |
28 | 28 | position = [1.0 1.2 1.3 15.9];
|
29 |
| - getTag = getBlock.create_tag('foo', 'bar', position); |
| 29 | + getTag = getBlock.create_tag('sourcetest', 'nixTag', position); |
30 | 30 |
|
31 | 31 | assert(isempty(getTag.sources));
|
32 | 32 | getTag.add_source(getSource.sources{1}.id);
|
|
37 | 37 | %% Test: Remove sources by entity and id
|
38 | 38 | function [] = test_remove_source ( varargin )
|
39 | 39 | test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
|
40 |
| - getBlock = test_file.createBlock('sourcetest', 'nixblock'); |
41 |
| - getSource = getBlock.create_source('sourcetest','nixsource'); |
42 |
| - createSource1 = getSource.create_source('nestedsource1','nixsource'); |
43 |
| - createSource2 = getSource.create_source('nestedsource2','nixsource'); |
| 40 | + getBlock = test_file.createBlock('test', 'nixBlock'); |
| 41 | + getSource = getBlock.create_source('test', 'nixSource'); |
| 42 | + tmp = getSource.create_source('nestedSource1', 'nixSource'); |
| 43 | + tmp = getSource.create_source('nestedSource2', 'nixSource'); |
44 | 44 | position = [1.0 1.2 1.3 15.9];
|
45 |
| - getTag = getBlock.create_tag('foo', 'bar', position); |
| 45 | + getTag = getBlock.create_tag('sourcetest', 'nixTag', position); |
46 | 46 | getTag.add_source(getSource.sources{1}.id);
|
47 | 47 | getTag.add_source(getSource.sources{2});
|
48 | 48 |
|
|
58 | 58 | %% Test: Add references by entity and id
|
59 | 59 | function [] = test_add_reference ( varargin )
|
60 | 60 | test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
|
61 |
| - getBlock = test_file.createBlock('referenceTest', 'nixblock'); |
62 |
| - getRefDA1 = getBlock.create_data_array('referenceTest1', 'nixDataArray', 'double', [1 2]); |
63 |
| - getRefDA2 = getBlock.create_data_array('referenceTest2', 'nixDataArray', 'double', [3 4]); |
| 61 | + getBlock = test_file.createBlock('referenceTest', 'nixBlock'); |
| 62 | + tmp = getBlock.create_data_array('referenceTest1', 'nixDataArray', 'double', [1 2]); |
| 63 | + tmp = getBlock.create_data_array('referenceTest2', 'nixDataArray', 'double', [3 4]); |
64 | 64 |
|
65 | 65 | position = [1.0 1.2 1.3 15.9];
|
66 | 66 | getTag = getBlock.create_tag('referenceTest', 'nixTag', position);
|
|
74 | 74 | %% Test: Remove references by entity and id
|
75 | 75 | function [] = test_remove_reference ( varargin )
|
76 | 76 | test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
|
77 |
| - getBlock = test_file.createBlock('referenceTest', 'nixblock'); |
| 77 | + getBlock = test_file.createBlock('referenceTest', 'nixBlock'); |
78 | 78 | getRefDA1 = getBlock.create_data_array('referenceTest1', 'nixDataArray', 'double', [1 2]);
|
79 | 79 | getRefDA2 = getBlock.create_data_array('referenceTest2', 'nixDataArray', 'double', [3 4]);
|
80 | 80 |
|
|
92 | 92 | assert(size(getBlock.dataArrays, 1) == 2);
|
93 | 93 | end
|
94 | 94 |
|
95 |
| -%% Test: List/fetch references |
96 |
| -function [] = test_list_fetch_references( varargin ) |
97 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
98 |
| - getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
99 |
| - getTag = getBlock.open_tag(getBlock.tags{1,1}.id); |
| 95 | +%% Test: fetch references |
| 96 | +function [] = test_fetch_references( varargin ) |
| 97 | + test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 98 | + getBlock = test_file.createBlock('referenceTest', 'nixBlock'); |
| 99 | + tmp = getBlock.create_data_array('referenceTest1', 'nixDataArray', 'double', [1 2]); |
| 100 | + tmp = getBlock.create_data_array('referenceTest2', 'nixDataArray', 'double', [3 4]); |
| 101 | + tmp = getBlock.create_data_array('referenceTest3', 'nixDataArray', 'double', [5 6]); |
| 102 | + position = [1.0 1.2 1.3 15.9]; |
| 103 | + getTag = getBlock.create_tag('referenceTest', 'nixTag', position); |
100 | 104 |
|
101 |
| - assert(size(getTag.references(), 1) == 1); |
| 105 | + getTag.add_reference(getBlock.dataArrays{1}); |
| 106 | + getTag.add_reference(getBlock.dataArrays{2}); |
| 107 | + getTag.add_reference(getBlock.dataArrays{3}); |
| 108 | + assert(size(getTag.references, 1) == 3); |
102 | 109 | end
|
103 | 110 |
|
104 |
| -%% Test: List/fetch sources |
105 |
| -function [] = test_list_fetch_sources( varargin ) |
106 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
107 |
| - getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
108 |
| - getTag = getBlock.open_tag(getBlock.tags{1,1}.id); |
109 |
| - |
110 |
| - %-- ToDo get testfile with tag referencing a source |
111 |
| - assert(size(getTag.sources(),1) == 0); |
112 |
| - disp('Test Tag: fetch sources ... TODO (proper testfile)'); |
| 111 | +%% Test: fetch sources |
| 112 | +function [] = test_fetch_sources( varargin ) |
| 113 | + test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 114 | + getBlock = test_file.createBlock('test', 'nixBlock'); |
| 115 | + getSource = getBlock.create_source('test','nixSource'); |
| 116 | + tmp = getSource.create_source('nestedsource1', 'nixSource'); |
| 117 | + tmp = getSource.create_source('nestedsource2', 'nixSource'); |
| 118 | + tmp = getSource.create_source('nestedsource3', 'nixSource'); |
| 119 | + position = [1.0 1.2 1.3 15.9]; |
| 120 | + getTag = getBlock.create_tag('tagtest', 'nixTag', position); |
| 121 | + |
| 122 | + getTag.add_source(getSource.sources{1}); |
| 123 | + getTag.add_source(getSource.sources{2}); |
| 124 | + getTag.add_source(getSource.sources{3}); |
| 125 | + assert(size(getTag.sources, 1) == 3); |
113 | 126 | end
|
114 | 127 |
|
115 | 128 |
|
116 |
| -%% Test: List/fetch features |
117 |
| -function [] = test_list_fetch_features( varargin ) |
| 129 | +%% Test: fetch features |
| 130 | +function [] = test_fetch_features( varargin ) |
118 | 131 | test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly);
|
119 | 132 | getBlock = test_file.openBlock(test_file.blocks{1,1}.name);
|
120 | 133 | getTag = getBlock.open_tag(getBlock.tags{1,1}.id);
|
|
126 | 139 |
|
127 | 140 | %% Test: Open source by ID or name
|
128 | 141 | function [] = test_open_source( varargin )
|
129 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
130 |
| - getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
131 |
| - getTag = getBlock.open_tag(getBlock.tags{1,1}.id); |
| 142 | + test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 143 | + getBlock = test_file.createBlock('test', 'nixBlock'); |
| 144 | + getSource = getBlock.create_source('test', 'nixSource'); |
| 145 | + sourceName = 'nestedsource'; |
| 146 | + createSource = getSource.create_source(sourceName, 'nixSource'); |
| 147 | + position = [1.0 1.2 1.3 15.9]; |
| 148 | + getTag = getBlock.create_tag('tagtest', 'nixTag', position); |
| 149 | + getTag.add_source(getSource.sources{1}); |
| 150 | + |
| 151 | + getSourceByID = getTag.open_source(createSource.id); |
| 152 | + assert(~isempty(getSourceByID)); |
132 | 153 |
|
133 |
| - %-- TODO: implement testfile with source referenced from a tag |
134 |
| - %getSourceByID = getTag.open_source(getTag.sources{1,1}.id); |
135 |
| - %assert(strcmp(getSourceByID.id, '')); |
136 |
| - disp('Test Tag: open source by ID ... TODO (proper testfile)'); |
137 |
| - |
138 |
| - %getSourceByName = getTag.open_source(getTag.sources{1,1}.name); |
139 |
| - %assert(strcmp(getSourceByName.id, '')); |
140 |
| - disp('Test Tag: open source by name ... TODO (proper testfile)'); |
| 154 | + getSourceByName = getTag.open_source(sourceName); |
| 155 | + assert(~isempty(getSourceByName)); |
141 | 156 |
|
142 | 157 | %-- test open non existing source
|
143 |
| - getSource = getTag.open_source('I dont exist'); |
144 |
| - assert(isempty(getSource)); |
| 158 | + getNonSource = getTag.open_source('I dont exist'); |
| 159 | + assert(isempty(getNonSource)); |
145 | 160 | end
|
146 | 161 |
|
147 | 162 |
|
|
168 | 183 |
|
169 | 184 | %% Test: Open reference by ID or name
|
170 | 185 | function [] = test_open_reference( varargin )
|
171 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
172 |
| - getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
173 |
| - getTag = getBlock.open_tag(getBlock.tags{1,1}.id); |
174 |
| - |
175 |
| - getRefByID = getTag.open_reference(getTag.references{1,1}.id); |
176 |
| - assert(strcmp(getRefByID.id, '75138768-edc3-482e-894d-301f1dd66f8d')); |
| 186 | + test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 187 | + getBlock = test_file.createBlock('referenceTest', 'nixBlock'); |
| 188 | + tmp = getBlock.create_data_array('referenceTest', 'nixDataArray', 'double', [1 2]); |
| 189 | + position = [1.0 1.2 1.3 15.9]; |
| 190 | + getTag = getBlock.create_tag('referenceTest', 'nixTag', position); |
| 191 | + getTag.add_reference(getBlock.dataArrays{1}); |
177 | 192 |
|
| 193 | + getRefByID = getTag.open_reference(getTag.references{1,1}.id); |
| 194 | + assert(~isempty(getRefByID)); |
| 195 | + |
178 | 196 | getRefByName = getTag.open_reference(getTag.references{1,1}.name);
|
179 |
| - assert(strcmp(getRefByName.id, '75138768-edc3-482e-894d-301f1dd66f8d')); |
| 197 | + assert(~isempty(getRefByName)); |
180 | 198 |
|
181 | 199 | %-- test open non existing source
|
182 |
| - getRef = getTag.open_reference('I dont exist'); |
183 |
| - assert(isempty(getRef)); |
| 200 | + getNonRef = getTag.open_reference('I dont exist'); |
| 201 | + assert(isempty(getNonRef)); |
184 | 202 | end
|
185 | 203 |
|
186 | 204 |
|
|
0 commit comments