comparison testing/utp_1.1/utps/ao/utp_ao_rebuild.m @ 44:409a22968d5e default

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