Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/ao/utp_ao_kstest.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_KSTEST a set of UTPs for the ao/kstest method | |
2 % | |
3 % M Hewitson 06-08-08 | |
4 % | |
5 % $Id: utp_ao_kstest.m,v 1.2 2011/07/14 07:11:00 mauro Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The ifft method of the ao class computes the inverse fast fourier | |
11 % transform of time-series AOs. | |
12 % | |
13 % </MethodDescription> | |
14 | |
15 function results = utp_ao_kstest(varargin) | |
16 | |
17 % Check the inputs | |
18 if nargin == 0 | |
19 | |
20 % Some keywords | |
21 class = 'ao'; | |
22 mthd = 'kstest'; | |
23 | |
24 results = []; | |
25 disp('******************************************************'); | |
26 disp(['**** Running UTPs for ' class '/' mthd]); | |
27 disp('******************************************************'); | |
28 | |
29 % Test AOs | |
30 [at1,at2,at3,at4,at5,at6,atvec,atmat] = eval(['get_test_objects_' class]); | |
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 modify call does not work | |
43 results = [results utp_09]; % Test output of the data | |
44 | |
45 disp('Done.'); | |
46 disp('******************************************************'); | |
47 | |
48 elseif nargin == 1 % Check for UTP functions | |
49 if strcmp(varargin{1}, 'isutp') | |
50 results = 1; | |
51 else | |
52 results = 0; | |
53 end | |
54 else | |
55 error('### Incorrect inputs') | |
56 end | |
57 | |
58 %% UTP_01 | |
59 | |
60 % <TestDescription> | |
61 % | |
62 % Tests that the getInfo call works for this method. | |
63 % | |
64 % </TestDescription> | |
65 function result = utp_01 | |
66 | |
67 | |
68 % <SyntaxDescription> | |
69 % | |
70 % Test that the getInfo call works for no sets, all sets, and each set | |
71 % individually. | |
72 % | |
73 % </SyntaxDescription> | |
74 | |
75 try | |
76 % <SyntaxCode> | |
77 % Call for no sets | |
78 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']); | |
79 % Call for all sets | |
80 io(2) = eval([class '.getInfo(''' mthd ''')']); | |
81 % Call for each set | |
82 for kk=1:numel(io(2).sets) | |
83 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']); | |
84 end | |
85 % </SyntaxCode> | |
86 stest = true; | |
87 catch err | |
88 disp(err.message) | |
89 stest = false; | |
90 end | |
91 | |
92 % <AlgoDescription> | |
93 % | |
94 % 1) Check that getInfo call returned an minfo object in all cases. | |
95 % 2) Check that all plists have the correct parameters. | |
96 % | |
97 % </AlgoDescription> | |
98 | |
99 atest = true; | |
100 if stest | |
101 % <AlgoCode> | |
102 % check we have minfo objects | |
103 if isa(io, 'minfo') | |
104 | |
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, 'empirical')), atest = false; end | |
110 if ~any(strcmpi(io(2).sets, 'normal')), atest = false; end | |
111 if ~any(strcmpi(io(2).sets, 'chi2')), atest = false; end | |
112 if ~any(strcmpi(io(2).sets, 'f')), atest = false; end | |
113 if ~any(strcmpi(io(2).sets, 'gamma')), atest = false; end | |
114 | |
115 %%%%%%%%%% SET 'empirical' | |
116 pn = 3; | |
117 if io(pn).plists.nparams ~= 4, atest = false; end | |
118 % Check key | |
119 if ~io(pn).plists.isparam('TESTDISTRIBUTION'), atest = false; end | |
120 if ~io(pn).plists.isparam('ALPHA'), atest = false; end | |
121 if ~io(pn).plists.isparam('SHAPEPARAM'), atest = false; end | |
122 if ~io(pn).plists.isparam('CRITICALVALUE'), atest = false; end | |
123 | |
124 % Check default value | |
125 if ~isequal(io(pn).plists.find('TESTDISTRIBUTION'), 'EMPIRICAL'), atest = false; end | |
126 if ~isequal(io(pn).plists.find('ALPHA'), 0.05), atest = false; end | |
127 if ~isequal(io(pn).plists.find('SHAPEPARAM'), 1), atest = false; end | |
128 if ~isequal(io(pn).plists.find('CRITICALVALUE'), []), atest = false; end | |
129 | |
130 | |
131 % Check options | |
132 if ~isequal(io(pn).plists.getOptionsForParam('TESTDISTRIBUTION'),... | |
133 {'EMPIRICAL','NORMAL','CHI2','F','GAMMA'}), atest = false; end | |
134 if ~isequal(io(pn).plists.getOptionsForParam('ALPHA'), {0.05}), atest = false; end | |
135 if ~isequal(io(pn).plists.getOptionsForParam('SHAPEPARAM'), {1}), atest = false; end | |
136 if ~isequal(io(pn).plists.getOptionsForParam('CRITICALVALUE'), {[]}), atest = false; end | |
137 | |
138 %%%%%%%%%% SET 'normal' | |
139 pn = 4; | |
140 if io(pn).plists.nparams ~= 6, atest = false; end | |
141 % Check key | |
142 if ~io(pn).plists.isparam('TESTDISTRIBUTION'), atest = false; end | |
143 if ~io(pn).plists.isparam('ALPHA'), atest = false; end | |
144 if ~io(pn).plists.isparam('SHAPEPARAM'), atest = false; end | |
145 if ~io(pn).plists.isparam('CRITICALVALUE'), atest = false; end | |
146 if ~io(pn).plists.isparam('MEAN'), atest = false; end | |
147 if ~io(pn).plists.isparam('STD'), atest = false; end | |
148 | |
149 % Check default value | |
150 if ~isequal(io(pn).plists.find('TESTDISTRIBUTION'), 'EMPIRICAL'), atest = false; end | |
151 if ~isequal(io(pn).plists.find('ALPHA'), 0.05), atest = false; end | |
152 if ~isequal(io(pn).plists.find('SHAPEPARAM'), 1), atest = false; end | |
153 if ~isequal(io(pn).plists.find('CRITICALVALUE'), []), atest = false; end | |
154 if ~isequal(io(pn).plists.find('MEAN'), 0), atest = false; end | |
155 if ~isequal(io(pn).plists.find('STD'), 1), atest = false; end | |
156 | |
157 | |
158 % Check options | |
159 if ~isequal(io(pn).plists.getOptionsForParam('TESTDISTRIBUTION'),... | |
160 {'EMPIRICAL','NORMAL','CHI2','F','GAMMA'}), atest = false; end | |
161 if ~isequal(io(pn).plists.getOptionsForParam('ALPHA'), {0.05}), atest = false; end | |
162 if ~isequal(io(pn).plists.getOptionsForParam('SHAPEPARAM'), {1}), atest = false; end | |
163 if ~isequal(io(pn).plists.getOptionsForParam('CRITICALVALUE'), {[]}), atest = false; end | |
164 if ~isequal(io(pn).plists.getOptionsForParam('MEAN'), {0}), atest = false; end | |
165 if ~isequal(io(pn).plists.getOptionsForParam('STD'), {1}), atest = false; end | |
166 | |
167 %%%%%%%%%% SET 'chi2' | |
168 pn = 5; | |
169 if io(pn).plists.nparams ~= 5, atest = false; end | |
170 % Check key | |
171 if ~io(pn).plists.isparam('TESTDISTRIBUTION'), atest = false; end | |
172 if ~io(pn).plists.isparam('ALPHA'), atest = false; end | |
173 if ~io(pn).plists.isparam('SHAPEPARAM'), atest = false; end | |
174 if ~io(pn).plists.isparam('CRITICALVALUE'), atest = false; end | |
175 if ~io(pn).plists.isparam('DOF'), atest = false; end | |
176 | |
177 % Check default value | |
178 if ~isequal(io(pn).plists.find('TESTDISTRIBUTION'), 'EMPIRICAL'), atest = false; end | |
179 if ~isequal(io(pn).plists.find('ALPHA'), 0.05), atest = false; end | |
180 if ~isequal(io(pn).plists.find('SHAPEPARAM'), 1), atest = false; end | |
181 if ~isequal(io(pn).plists.find('CRITICALVALUE'), []), atest = false; end | |
182 if ~isequal(io(pn).plists.find('DOF'), 2), atest = false; end | |
183 | |
184 | |
185 % Check options | |
186 if ~isequal(io(pn).plists.getOptionsForParam('TESTDISTRIBUTION'),... | |
187 {'EMPIRICAL','NORMAL','CHI2','F','GAMMA'}), atest = false; end | |
188 if ~isequal(io(pn).plists.getOptionsForParam('ALPHA'), {0.05}), atest = false; end | |
189 if ~isequal(io(pn).plists.getOptionsForParam('SHAPEPARAM'), {1}), atest = false; end | |
190 if ~isequal(io(pn).plists.getOptionsForParam('CRITICALVALUE'), {[]}), atest = false; end | |
191 if ~isequal(io(pn).plists.getOptionsForParam('DOF'), {2}), atest = false; end | |
192 | |
193 %%%%%%%%%% SET 'f' | |
194 pn = 6; | |
195 if io(pn).plists.nparams ~= 6, atest = false; end | |
196 % Check key | |
197 if ~io(pn).plists.isparam('TESTDISTRIBUTION'), atest = false; end | |
198 if ~io(pn).plists.isparam('ALPHA'), atest = false; end | |
199 if ~io(pn).plists.isparam('SHAPEPARAM'), atest = false; end | |
200 if ~io(pn).plists.isparam('CRITICALVALUE'), atest = false; end | |
201 if ~io(pn).plists.isparam('DOF1'), atest = false; end | |
202 if ~io(pn).plists.isparam('DOF2'), atest = false; end | |
203 | |
204 % Check default value | |
205 if ~isequal(io(pn).plists.find('TESTDISTRIBUTION'), 'EMPIRICAL'), atest = false; end | |
206 if ~isequal(io(pn).plists.find('ALPHA'), 0.05), atest = false; end | |
207 if ~isequal(io(pn).plists.find('SHAPEPARAM'), 1), atest = false; end | |
208 if ~isequal(io(pn).plists.find('CRITICALVALUE'), []), atest = false; end | |
209 if ~isequal(io(pn).plists.find('DOF1'), 2), atest = false; end | |
210 if ~isequal(io(pn).plists.find('DOF2'), 2), atest = false; end | |
211 | |
212 | |
213 % Check options | |
214 if ~isequal(io(pn).plists.getOptionsForParam('TESTDISTRIBUTION'),... | |
215 {'EMPIRICAL','NORMAL','CHI2','F','GAMMA'}), atest = false; end | |
216 if ~isequal(io(pn).plists.getOptionsForParam('ALPHA'), {0.05}), atest = false; end | |
217 if ~isequal(io(pn).plists.getOptionsForParam('SHAPEPARAM'), {1}), atest = false; end | |
218 if ~isequal(io(pn).plists.getOptionsForParam('CRITICALVALUE'), {[]}), atest = false; end | |
219 if ~isequal(io(pn).plists.getOptionsForParam('DOF1'), {2}), atest = false; end | |
220 if ~isequal(io(pn).plists.getOptionsForParam('DOF2'), {2}), atest = false; end | |
221 | |
222 %%%%%%%%%% SET 'gamma' | |
223 pn = 7; | |
224 if io(pn).plists.nparams ~= 6, atest = false; end | |
225 % Check key | |
226 if ~io(pn).plists.isparam('TESTDISTRIBUTION'), atest = false; end | |
227 if ~io(pn).plists.isparam('ALPHA'), atest = false; end | |
228 if ~io(pn).plists.isparam('SHAPEPARAM'), atest = false; end | |
229 if ~io(pn).plists.isparam('CRITICALVALUE'), atest = false; end | |
230 if ~io(pn).plists.isparam('SHAPE'), atest = false; end | |
231 if ~io(pn).plists.isparam('SCALE'), atest = false; end | |
232 | |
233 % Check default value | |
234 if ~isequal(io(pn).plists.find('TESTDISTRIBUTION'), 'EMPIRICAL'), atest = false; end | |
235 if ~isequal(io(pn).plists.find('ALPHA'), 0.05), atest = false; end | |
236 if ~isequal(io(pn).plists.find('SHAPEPARAM'), 1), atest = false; end | |
237 if ~isequal(io(pn).plists.find('CRITICALVALUE'), []), atest = false; end | |
238 if ~isequal(io(pn).plists.find('SHAPE'), 2), atest = false; end | |
239 if ~isequal(io(pn).plists.find('SCALE'), 2), atest = false; end | |
240 | |
241 | |
242 % Check options | |
243 if ~isequal(io(pn).plists.getOptionsForParam('TESTDISTRIBUTION'),... | |
244 {'EMPIRICAL','NORMAL','CHI2','F','GAMMA'}), atest = false; end | |
245 if ~isequal(io(pn).plists.getOptionsForParam('ALPHA'), {0.05}), atest = false; end | |
246 if ~isequal(io(pn).plists.getOptionsForParam('SHAPEPARAM'), {1}), atest = false; end | |
247 if ~isequal(io(pn).plists.getOptionsForParam('CRITICALVALUE'), {[]}), atest = false; end | |
248 if ~isequal(io(pn).plists.getOptionsForParam('SHAPE'), {2}), atest = false; end | |
249 if ~isequal(io(pn).plists.getOptionsForParam('SCALE'), {2}), atest = false; end | |
250 | |
251 end | |
252 % </AlgoCode> | |
253 else | |
254 atest = false; | |
255 end | |
256 | |
257 % Return a result structure | |
258 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
259 end % END UTP_01 | |
260 | |
261 %% UTP_02 | |
262 | |
263 % <TestDescription> | |
264 % | |
265 % Tests that the kstest method works with a vector of AOs as input. | |
266 % | |
267 % </TestDescription> | |
268 function result = utp_02 | |
269 | |
270 % <SyntaxDescription> | |
271 % | |
272 % Test that the kstest method works for a vector of AOs as input. | |
273 % | |
274 % </SyntaxDescription> | |
275 | |
276 try | |
277 % <SyntaxCode> | |
278 avec = [at5 at5]; | |
279 out1 = kstest(avec); | |
280 out2 = kstest(avec, plist('testdistribution', 'normal')); | |
281 % </SyntaxCode> | |
282 stest = true; | |
283 catch err | |
284 disp(err.message) | |
285 stest = false; | |
286 end | |
287 | |
288 % <AlgoDescription> | |
289 % | |
290 % 1) Check that the number of elements in 'out1' is one less of the input. | |
291 % 2) Check that the number of elements in 'out2' is the same of the | |
292 % number in the input. | |
293 % 3) Check that each output AO contains the correct data. | |
294 % | |
295 % </AlgoDescription> | |
296 | |
297 atest = true; | |
298 if stest | |
299 % <AlgoCode> | |
300 % Check we have the correct number of outputs | |
301 if numel(out1) ~= numel(avec) - 1, atest = false; end | |
302 if numel(out2) ~= numel(avec), atest = false; end | |
303 % Check each output: class | |
304 for kk = 1:numel(out1) | |
305 if ~isa(out1(kk).data, 'cdata'), atest = false; end | |
306 end | |
307 for kk = 1:numel(out2) | |
308 if ~isa(out2(kk).data, 'cdata'), atest = false; end | |
309 end | |
310 % Check each output: content | |
311 for kk = 1:numel(out1) | |
312 if ~isequal(out1(kk).data.y, false), atest = false; end | |
313 end | |
314 for kk = 1:numel(out2) | |
315 if ~isequal(out2(kk).data.y, false), atest = false; end | |
316 end | |
317 % </AlgoCode> | |
318 else | |
319 atest = false; | |
320 end | |
321 | |
322 % Return a result structure | |
323 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
324 end % END UTP_02 | |
325 | |
326 %% UTP_03 | |
327 | |
328 % <TestDescription> | |
329 % | |
330 % Tests that the kstest method works with a matrix of AOs as input. | |
331 % | |
332 % </TestDescription> | |
333 function result = utp_03 | |
334 | |
335 % <SyntaxDescription> | |
336 % | |
337 % Test that the kstest method works for a matrix of AOs as input. | |
338 % | |
339 % </SyntaxDescription> | |
340 | |
341 try | |
342 % <SyntaxCode> | |
343 amat = [at5 at5 at5; at5 at5 at5]; | |
344 out1 = kstest(amat); | |
345 out2 = kstest(amat, plist('testdistribution', 'normal')); | |
346 | |
347 % </SyntaxCode> | |
348 stest = true; | |
349 catch err | |
350 disp(err.message) | |
351 stest = false; | |
352 end | |
353 | |
354 % <AlgoDescription> | |
355 % | |
356 % 1) Check that the number of elements in 'out1' is one less of the input. | |
357 % 2) Check that the number of elements in 'out2' is the same of the | |
358 % number in the input. | |
359 % 3) Check that each output AO contains the correct data. | |
360 % | |
361 % </AlgoDescription> | |
362 | |
363 atest = true; | |
364 if stest | |
365 % <AlgoCode> | |
366 % Check we have the correct number of outputs | |
367 if numel(out1) ~= numel(amat)-1, atest = false; end | |
368 if numel(out2) ~= numel(amat), atest = false; end | |
369 % Check each output: class | |
370 for kk = 1:numel(out1) | |
371 if ~isa(out1(kk).data, 'cdata'), atest = false; end | |
372 end | |
373 for kk = 1:numel(out2) | |
374 if ~isa(out2(kk).data, 'cdata'), atest = false; end | |
375 end | |
376 % Check each output: content | |
377 for kk = 1:numel(out1) | |
378 if ~isequal(out1(kk).data.y, false), atest = false; end | |
379 end | |
380 for kk = 1:numel(out2) | |
381 if ~isequal(out2(kk).data.y, false), atest = false; end | |
382 end | |
383 % </AlgoCode> | |
384 else | |
385 atest = false; | |
386 end | |
387 | |
388 % Return a result structure | |
389 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
390 end % END UTP_03 | |
391 | |
392 %% UTP_04 | |
393 | |
394 % <TestDescription> | |
395 % | |
396 % Tests that the kstest method works with a list of AOs as input. | |
397 % | |
398 % </TestDescription> | |
399 function result = utp_04 | |
400 | |
401 % <SyntaxDescription> | |
402 % | |
403 % Test that the kstest method works for a list of AOs as input. | |
404 % | |
405 % </SyntaxDescription> | |
406 | |
407 try | |
408 % <SyntaxCode> | |
409 out1 = kstest(at5, at5, at5); | |
410 out2 = kstest(at5, at5, at5, plist('testdistribution', 'normal')); | |
411 % </SyntaxCode> | |
412 stest = true; | |
413 catch err | |
414 disp(err.message) | |
415 stest = false; | |
416 end | |
417 | |
418 % <AlgoDescription> | |
419 % | |
420 % 1) Check that the number of elements in 'out1' is one less of the input. | |
421 % 2) Check that the number of elements in 'out2' is the same of the | |
422 % number in the input. | |
423 % 3) Check that each output AO contains the correct data. | |
424 % | |
425 % </AlgoDescription> | |
426 | |
427 atest = true; | |
428 if stest | |
429 % <AlgoCode> | |
430 % Check we have the correct number of outputs | |
431 if numel(out1) ~= 2, atest = false; end | |
432 if numel(out2) ~= 3, atest = false; end | |
433 % Check each output: class | |
434 for kk = 1:numel(out1) | |
435 if ~isa(out1(kk).data, 'cdata'), atest = false; end | |
436 end | |
437 for kk = 1:numel(out2) | |
438 if ~isa(out2(kk).data, 'cdata'), atest = false; end | |
439 end | |
440 % Check each output: content | |
441 for kk = 1:numel(out1) | |
442 if ~isequal(out1(kk).data.y, false), atest = false; end | |
443 end | |
444 for kk = 1:numel(out2) | |
445 if ~isequal(out2(kk).data.y, false), atest = false; end | |
446 end | |
447 | |
448 % </AlgoCode> | |
449 else | |
450 atest = false; | |
451 end | |
452 | |
453 % Return a result structure | |
454 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
455 end % END UTP_04 | |
456 | |
457 %% UTP_05 | |
458 | |
459 % <TestDescription> | |
460 % | |
461 % Tests that the kstest method works with a mix of different shaped AOs as | |
462 % input. | |
463 % | |
464 % </TestDescription> | |
465 function result = utp_05 | |
466 | |
467 % <SyntaxDescription> | |
468 % | |
469 % Test that the kstest method works with an input of matrices and vectors | |
470 % and single AOs. | |
471 % | |
472 % </SyntaxDescription> | |
473 | |
474 try | |
475 % <SyntaxCode> | |
476 out1 = kstest(at5,[at6 at6],at5,[at5 at5; at5 at5],at6); | |
477 % </SyntaxCode> | |
478 stest = true; | |
479 catch err | |
480 disp(err.message) | |
481 stest = false; | |
482 end | |
483 | |
484 % <AlgoDescription> | |
485 % | |
486 % 1) Check that the number of elements in 'out' is the same as in | |
487 % input. | |
488 % 2) Check that each output AO contains the correct data. | |
489 % | |
490 % </AlgoDescription> | |
491 | |
492 atest = true; | |
493 % aoin = [at1, reshape([at1 at1], 1, []), at1, reshape([at1 at1; at1 at1], 1, []), at1]; | |
494 if stest | |
495 % <AlgoCode> | |
496 % Check we have the correct number of outputs | |
497 if numel(out1) ~= 8, atest = false; end | |
498 % Check each output | |
499 | |
500 % </AlgoCode> | |
501 else | |
502 atest = false; | |
503 end | |
504 | |
505 % Return a result structure | |
506 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
507 end % END UTP_05 | |
508 | |
509 %% UTP_06 | |
510 | |
511 % <TestDescription> | |
512 % | |
513 % Tests that the kstest method properly applies history. | |
514 % | |
515 % </TestDescription> | |
516 function result = utp_06 | |
517 | |
518 % <SyntaxDescription> | |
519 % | |
520 % Test that the result of applying the kstest method can be processed back | |
521 % to an m-file. | |
522 % | |
523 % </SyntaxDescription> | |
524 | |
525 try | |
526 % <SyntaxCode> | |
527 out1 = kstest(at5, at6); | |
528 mout1 = rebuild(out1); | |
529 % </SyntaxCode> | |
530 stest = true; | |
531 catch err | |
532 disp(err.message) | |
533 stest = false; | |
534 end | |
535 | |
536 % <AlgoDescription> | |
537 % | |
538 % 1) Check that the last entry in the history of 'out' corresponds to | |
539 % 'kstest'. | |
540 % 2) % Check that the re-built object is the same object as 'out'. | |
541 % | |
542 % </AlgoDescription> | |
543 | |
544 atest = true; | |
545 if stest | |
546 % <AlgoCode> | |
547 % Check the last step in the history of 'out' | |
548 if ~strcmp(out1.hist.methodInfo.mname, 'kstest'), atest = false; end | |
549 % Check the re-built object | |
550 if ~eq(mout1, out1, ple2), atest = false; end | |
551 % </AlgoCode> | |
552 else | |
553 atest = false; | |
554 end | |
555 | |
556 % Return a result structure | |
557 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
558 end % END UTP_06 | |
559 | |
560 %% UTP_07 | |
561 | |
562 % <TestDescription> | |
563 % | |
564 % Tests that the kstest method cannot modify the input AO. | |
565 % | |
566 % </TestDescription> | |
567 function result = utp_07 | |
568 | |
569 % <SyntaxDescription> | |
570 % | |
571 % Test that the kstest method cannot modify the input AO by calling with no | |
572 % output. | |
573 % | |
574 % </SyntaxDescription> | |
575 | |
576 try | |
577 % <SyntaxCode> | |
578 % copy at2 to work with | |
579 ain1 = ao(at5); | |
580 ain2 = ao(at6); | |
581 ainv = [ain1 ain2]; | |
582 % modify ain | |
583 out1 = kstest(ainv); | |
584 ainv.kstest(); | |
585 % </SyntaxCode> | |
586 stest = false; | |
587 catch err | |
588 disp(err.message) | |
589 stest = true; | |
590 end | |
591 | |
592 % <AlgoDescription> | |
593 % | |
594 % | |
595 % </AlgoDescription> | |
596 | |
597 atest = true; | |
598 | |
599 | |
600 % Return a result structure | |
601 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
602 end % END UTP_07 | |
603 | |
604 | |
605 %% UTP_09 | |
606 | |
607 % <TestDescription> | |
608 % | |
609 % Check that the kstest method pass back the output objects to a list of | |
610 % output variables or to a single variable. | |
611 % | |
612 % </TestDescription> | |
613 function result = utp_09 | |
614 | |
615 % <SyntaxDescription> | |
616 % | |
617 % Call the method with a list of output variables and with a single output | |
618 % variable. Additionaly check that the rebuild method works on the output. | |
619 % | |
620 % </SyntaxDescription> | |
621 | |
622 try | |
623 % <SyntaxCode> | |
624 [o11, o12] = kstest(at5, at6, at6); | |
625 no1 = kstest(at5, at6, at6); | |
626 mout11 = rebuild(o11); | |
627 mout12 = rebuild(o12); | |
628 moutn1 = rebuild(no1); | |
629 | |
630 % </SyntaxCode> | |
631 stest = true; | |
632 catch err | |
633 disp(err.message) | |
634 stest = false; | |
635 end | |
636 | |
637 % <AlgoDescription> | |
638 % | |
639 % 1) Check that the output contains the right number of objects | |
640 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
641 % | |
642 % </AlgoDescription> | |
643 | |
644 atest = true; | |
645 if stest | |
646 % <AlgoCode> | |
647 % Check the number of outputs | |
648 if numel(o11) ~=1, atest = false; end | |
649 if numel(o12) ~=1, atest = false; end | |
650 if numel(no1) ~=2, atest = false; end | |
651 % Check the rebuilding of the object | |
652 if ~eq(o11, mout11, ple2), atest = false; end | |
653 if ~eq(o12, mout12, ple2), atest = false; end | |
654 if ~eq(no1, moutn1, ple2), atest = false; end | |
655 % </AlgoCode> | |
656 else | |
657 atest = false; | |
658 end | |
659 | |
660 % Return a result structure | |
661 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
662 end % END UTP_09 | |
663 | |
664 | |
665 | |
666 end |