Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/mfir/utp_mfir_rebuild.m @ 45:a59cdb8aaf31 database-connection-manager
Merge
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Tue, 06 Dec 2011 19:07:22 +0100 |
parents | 409a22968d5e |
children |
comparison
equal
deleted
inserted
replaced
42:f90d4f666cc7 | 45:a59cdb8aaf31 |
---|---|
1 % UTP_MFIR_REBUILD a set of UTPs for the mfir/rebuild method | |
2 % | |
3 % M Hewitson 06-08-08 | |
4 % | |
5 % $Id: utp_mfir_rebuild.m,v 1.2 2009/07/23 12:33:00 ingo Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The rebuild method of the mfir class rebuilds the input objects using the | |
11 % history. This method is also intensively tested in the most other UTPs. | |
12 % | |
13 % </MethodDescription> | |
14 | |
15 function results = utp_mfir_rebuild(varargin) | |
16 | |
17 % Check the inputs | |
18 if nargin == 0 | |
19 | |
20 % Some keywords | |
21 class = 'mfir'; | |
22 mthd = 'rebuild'; | |
23 | |
24 results = []; | |
25 disp('******************************************************'); | |
26 disp(['**** Running UTPs for ' class '/' mthd]); | |
27 disp('******************************************************'); | |
28 | |
29 % Test MFIR objects | |
30 [fir1, fir2, fir3, fir4, fir5, fir6, firv, firm] = get_test_objects_mfir; | |
31 | |
32 % Exception list for the UTPs: | |
33 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples(); | |
34 | |
35 % Run the tests | |
36 results = [results utp_01]; % getInfo call | |
37 results = [results utp_02]; % Vector input | |
38 results = [results utp_03]; % Matrix input | |
39 results = [results utp_04]; % List input | |
40 results = [results utp_05]; % Test with mixed input | |
41 results = [results utp_06]; % Test history is working | |
42 results = [results utp_07]; % Test the output | |
43 | |
44 disp('Done.'); | |
45 disp('******************************************************'); | |
46 | |
47 elseif nargin == 1 % Check for UTP functions | |
48 if strcmp(varargin{1}, 'isutp') | |
49 results = 1; | |
50 else | |
51 results = 0; | |
52 end | |
53 else | |
54 error('### Incorrect inputs') | |
55 end | |
56 | |
57 %% UTP_01 | |
58 | |
59 % <TestDescription> | |
60 % | |
61 % Tests that the getInfo call works for this method. | |
62 % | |
63 % </TestDescription> | |
64 function result = utp_01 | |
65 | |
66 | |
67 % <SyntaxDescription> | |
68 % | |
69 % Test that the getInfo call works for no sets, all sets, and each set | |
70 % individually. | |
71 % | |
72 % </SyntaxDescription> | |
73 | |
74 try | |
75 % <SyntaxCode> | |
76 % Call for no sets | |
77 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']); | |
78 % Call for all sets | |
79 io(2) = eval([class '.getInfo(''' mthd ''')']); | |
80 % Call for each set | |
81 for kk=1:numel(io(2).sets) | |
82 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']); | |
83 end | |
84 % </SyntaxCode> | |
85 stest = true; | |
86 catch err | |
87 disp(err.message) | |
88 stest = false; | |
89 end | |
90 | |
91 % <AlgoDescription> | |
92 % | |
93 % 1) Check that getInfo call returned an minfo object in all cases. | |
94 % 2) Check that all plists have the correct parameters. | |
95 % | |
96 % </AlgoDescription> | |
97 | |
98 atest = true; | |
99 if stest | |
100 % <AlgoCode> | |
101 % check we have minfo objects | |
102 if isa(io, 'minfo') | |
103 % SET 'None' | |
104 if ~isempty(io(1).sets), atest = false; end | |
105 if ~isempty(io(1).plists), atest = false; end | |
106 % Check all Sets | |
107 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end | |
108 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end | |
109 % SET 'Default' | |
110 if io(3).plists.nparams ~= 0, atest = false; end | |
111 % Check key | |
112 % Check default value | |
113 % Check options | |
114 end | |
115 % </AlgoCode> | |
116 else | |
117 atest = false; | |
118 end | |
119 | |
120 % Return a result structure | |
121 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
122 end % END UTP_01 | |
123 | |
124 %% UTP_02 | |
125 | |
126 % <TestDescription> | |
127 % | |
128 % Tests that the rebuild method works with a vector of MFIR objects as input. | |
129 % | |
130 % </TestDescription> | |
131 function result = utp_02 | |
132 | |
133 % <SyntaxDescription> | |
134 % | |
135 % Test that the rebuild method works for a vector of MFIR objects as input. | |
136 % | |
137 % </SyntaxDescription> | |
138 | |
139 try | |
140 % <SyntaxCode> | |
141 out = rebuild(firv); | |
142 % </SyntaxCode> | |
143 stest = true; | |
144 catch err | |
145 disp(err.message) | |
146 stest = false; | |
147 end | |
148 | |
149 % <AlgoDescription> | |
150 % | |
151 % 1) Check the rebuilt output. | |
152 % | |
153 % </AlgoDescription> | |
154 | |
155 atest = true; | |
156 if stest | |
157 % <AlgoCode> | |
158 % Check the output | |
159 if ~isa(out, 'mfir'), atest = false; end; | |
160 for kk = 1:numel(firv) | |
161 if eq(out(kk), firv(kk)), atest = false; end | |
162 end | |
163 % </AlgoCode> | |
164 else | |
165 atest = false; | |
166 end | |
167 | |
168 % Return a result structure | |
169 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
170 end % END UTP_02 | |
171 | |
172 %% UTP_03 | |
173 | |
174 % <TestDescription> | |
175 % | |
176 % Tests that the rebuild method works with a matrix of MFIR objects as input. | |
177 % | |
178 % </TestDescription> | |
179 function result = utp_03 | |
180 | |
181 % <SyntaxDescription> | |
182 % | |
183 % Test that the rebuild method works for a matrix of MFIR objects as input. | |
184 % | |
185 % </SyntaxDescription> | |
186 | |
187 try | |
188 % <SyntaxCode> | |
189 out = rebuild(firm); | |
190 % </SyntaxCode> | |
191 stest = true; | |
192 catch err | |
193 disp(err.message) | |
194 stest = false; | |
195 end | |
196 | |
197 % <AlgoDescription> | |
198 % | |
199 % 1) Check the rebuilt output. | |
200 % | |
201 % </AlgoDescription> | |
202 | |
203 atest = true; | |
204 if stest | |
205 % <AlgoCode> | |
206 if ~isa(out, 'mfir'), atest = false; end; | |
207 for kk = 1:numel(firm) | |
208 if eq(out(kk), firm(kk)), atest = false; end | |
209 end | |
210 % </AlgoCode> | |
211 else | |
212 atest = false; | |
213 end | |
214 | |
215 % Return a result structure | |
216 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
217 end % END UTP_03 | |
218 | |
219 %% UTP_04 | |
220 | |
221 % <TestDescription> | |
222 % | |
223 % Tests that the rebuild method works with a list of MFIR objects as input. | |
224 % | |
225 % </TestDescription> | |
226 function result = utp_04 | |
227 | |
228 % <SyntaxDescription> | |
229 % | |
230 % Test that the rebuild method works for a list of MFIR objects as input. | |
231 % | |
232 % </SyntaxDescription> | |
233 | |
234 try | |
235 % <SyntaxCode> | |
236 out = rebuild(fir5,fir4,fir3); | |
237 % </SyntaxCode> | |
238 stest = true; | |
239 catch err | |
240 disp(err.message) | |
241 stest = false; | |
242 end | |
243 | |
244 % <AlgoDescription> | |
245 % | |
246 % 1) Check the rebuilt output. | |
247 % | |
248 % </AlgoDescription> | |
249 | |
250 atest = true; | |
251 firin = [fir5,fir4,fir3]; | |
252 if stest | |
253 % <AlgoCode> | |
254 if ~isa(out, 'mfir'), atest = false; end; | |
255 for kk = 1:numel(firin) | |
256 if eq(out(kk), firin(kk)), atest = false; end | |
257 end | |
258 % </AlgoCode> | |
259 else | |
260 atest = false; | |
261 end | |
262 | |
263 % Return a result structure | |
264 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
265 end % END UTP_04 | |
266 | |
267 %% UTP_05 | |
268 | |
269 % <TestDescription> | |
270 % | |
271 % Tests that the rebuild method works with a mix of different shaped MFIR objects | |
272 % as input. | |
273 % | |
274 % </TestDescription> | |
275 function result = utp_05 | |
276 | |
277 % <SyntaxDescription> | |
278 % | |
279 % Test that the rebuild method works with an input of matrices and vectors | |
280 % and single MFIR objects. | |
281 % | |
282 % </SyntaxDescription> | |
283 | |
284 try | |
285 % <SyntaxCode> | |
286 out = rebuild(fir4,firv,fir2,firm,fir1); | |
287 % </SyntaxCode> | |
288 stest = true; | |
289 catch err | |
290 disp(err.message) | |
291 stest = false; | |
292 end | |
293 | |
294 % <AlgoDescription> | |
295 % | |
296 % 1) Check the rebuilt output. | |
297 % | |
298 % </AlgoDescription> | |
299 | |
300 atest = true; | |
301 firin = [fir4,reshape(firv,1,[]),fir2,reshape(firm,1,[]),fir1]; | |
302 if stest | |
303 % <AlgoCode> | |
304 if ~isa(out, 'mfir'), atest = false; end; | |
305 for kk = 1:numel(firin) | |
306 if eq(out(kk), firin(kk)), atest = false; end | |
307 end | |
308 % </AlgoCode> | |
309 else | |
310 atest = false; | |
311 end | |
312 | |
313 % Return a result structure | |
314 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
315 end % END UTP_05 | |
316 | |
317 %% UTP_06 | |
318 | |
319 % <TestDescription> | |
320 % | |
321 % Tests that the rebuild method properly applies history. | |
322 % | |
323 % </TestDescription> | |
324 function result = utp_06 | |
325 | |
326 % <SyntaxDescription> | |
327 % | |
328 % The method rebuild doesn't change the data, thus it is not possible to check | |
329 % the history. Nothing to do. | |
330 % | |
331 % </SyntaxDescription> | |
332 | |
333 try | |
334 % <SyntaxCode> | |
335 % </SyntaxCode> | |
336 stest = true; | |
337 catch err | |
338 disp(err.message) | |
339 stest = false; | |
340 end | |
341 | |
342 % <AlgoDescription> | |
343 % | |
344 % </AlgoDescription> | |
345 | |
346 atest = true; | |
347 if stest | |
348 % <AlgoCode> | |
349 % </AlgoCode> | |
350 else | |
351 atest = false; | |
352 end | |
353 | |
354 % Return a result structure | |
355 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
356 end % END UTP_06 | |
357 | |
358 %% UTP_07 | |
359 | |
360 % <TestDescription> | |
361 % | |
362 % Check that the rebuild method pass back the output objects to a list of | |
363 % output variables or to a single variable. | |
364 % | |
365 % </TestDescription> | |
366 function result = utp_07 | |
367 | |
368 % <SyntaxDescription> | |
369 % | |
370 % Call the method with a list of output variables and with a single output | |
371 % variable. Additionaly check that the rebuild method works on the output. | |
372 % | |
373 % </SyntaxDescription> | |
374 | |
375 try | |
376 % <SyntaxCode> | |
377 [o1, o2] = rebuild(fir1, fir2); | |
378 o3 = rebuild(fir1, fir2); | |
379 % </SyntaxCode> | |
380 stest = true; | |
381 catch err | |
382 disp(err.message) | |
383 stest = false; | |
384 end | |
385 | |
386 % <AlgoDescription> | |
387 % | |
388 % 1) Check that the output contains the right number of objects | |
389 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
390 % | |
391 % </AlgoDescription> | |
392 | |
393 atest = true; | |
394 if stest | |
395 % <AlgoCode> | |
396 % Check the number of outputs | |
397 if numel(o1) ~=1, atest = false; end | |
398 if numel(o2) ~=1, atest = false; end | |
399 if numel(o3) ~=2, atest = false; end | |
400 % Check the rebuilding of the object | |
401 if ~eq(o1, fir1, ple2), atest = false; end | |
402 if ~eq(o2, fir2, ple2), atest = false; end | |
403 if ~eq(o3, [fir1 fir2], ple2), atest = false; end | |
404 % </AlgoCode> | |
405 else | |
406 atest = false; | |
407 end | |
408 | |
409 % Return a result structure | |
410 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
411 end % END UTP_07 | |
412 | |
413 end |