Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/ao/utp_ao_t0.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_T0 a set of UTPs for the ao/t0 method | |
2 % | |
3 % M Hewitson 06-08-08 | |
4 % | |
5 % $Id: utp_ao_t0.m,v 1.3 2011/03/23 10:25:20 mauro Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The t0 method of the ao class is a get-function to get the t0 value | |
11 % of the data object | |
12 % | |
13 % </MethodDescription> | |
14 | |
15 function results = utp_ao_t0(varargin) | |
16 | |
17 % Check the inputs | |
18 if nargin == 0 | |
19 | |
20 % Some keywords | |
21 class = 'ao'; | |
22 mthd = 't0'; | |
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 with all data objects | |
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 t0 method works with a vector of AOs as input. | |
129 % | |
130 % </TestDescription> | |
131 function result = utp_02 | |
132 | |
133 % <SyntaxDescription> | |
134 % | |
135 % The t0 method doesn't work with a vector of AOs. Nothing to do | |
136 % | |
137 % </SyntaxDescription> | |
138 | |
139 try | |
140 % <SyntaxCode> | |
141 % </SyntaxCode> | |
142 stest = true; | |
143 catch err | |
144 disp(err.message) | |
145 stest = false; | |
146 end | |
147 | |
148 % <AlgoDescription> | |
149 % | |
150 % </AlgoDescription> | |
151 | |
152 atest = true; | |
153 if stest | |
154 % <AlgoCode> | |
155 % </AlgoCode> | |
156 else | |
157 atest = false; | |
158 end | |
159 | |
160 % Return a result structure | |
161 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
162 end % END UTP_02 | |
163 | |
164 %% UTP_03 | |
165 | |
166 % <TestDescription> | |
167 % | |
168 % Tests that the t0 method works with a matrix of AOs as input. | |
169 % | |
170 % </TestDescription> | |
171 function result = utp_03 | |
172 | |
173 % <SyntaxDescription> | |
174 % | |
175 % The t0 method doesn't work with a matrix of AOs. Nothing to do | |
176 % | |
177 % </SyntaxDescription> | |
178 | |
179 try | |
180 % <SyntaxCode> | |
181 % </SyntaxCode> | |
182 stest = true; | |
183 catch err | |
184 disp(err.message) | |
185 stest = false; | |
186 end | |
187 | |
188 % <AlgoDescription> | |
189 % | |
190 % </AlgoDescription> | |
191 | |
192 atest = true; | |
193 if stest | |
194 % <AlgoCode> | |
195 % </AlgoCode> | |
196 else | |
197 atest = false; | |
198 end | |
199 | |
200 % Return a result structure | |
201 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
202 end % END UTP_03 | |
203 | |
204 %% UTP_04 | |
205 | |
206 % <TestDescription> | |
207 % | |
208 % Tests that the t0 method works with a list of AOs as input. | |
209 % | |
210 % </TestDescription> | |
211 function result = utp_04 | |
212 | |
213 % <SyntaxDescription> | |
214 % | |
215 % The t0 method doesn't work with a list of AOs. Nothing to do | |
216 % | |
217 % </SyntaxDescription> | |
218 | |
219 try | |
220 % <SyntaxCode> | |
221 % </SyntaxCode> | |
222 stest = true; | |
223 catch err | |
224 disp(err.message) | |
225 stest = false; | |
226 end | |
227 | |
228 % <AlgoDescription> | |
229 % | |
230 % </AlgoDescription> | |
231 | |
232 atest = true; | |
233 if stest | |
234 % <AlgoCode> | |
235 % </AlgoCode> | |
236 else | |
237 atest = false; | |
238 end | |
239 | |
240 % Return a result structure | |
241 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
242 end % END UTP_04 | |
243 | |
244 %% UTP_05 | |
245 | |
246 % <TestDescription> | |
247 % | |
248 % Tests that the t0 method works with a mix of different shaped AOs as | |
249 % input. | |
250 % | |
251 % </TestDescription> | |
252 function result = utp_05 | |
253 | |
254 % <SyntaxDescription> | |
255 % | |
256 % The t0 method can only return the t0 value of one AO. Nothing to do | |
257 % | |
258 % </SyntaxDescription> | |
259 | |
260 try | |
261 % <SyntaxCode> | |
262 % </SyntaxCode> | |
263 stest = true; | |
264 catch err | |
265 disp(err.message) | |
266 stest = false; | |
267 end | |
268 | |
269 % <AlgoDescription> | |
270 % | |
271 % </AlgoDescription> | |
272 | |
273 atest = true; | |
274 if stest | |
275 % <AlgoCode> | |
276 % </AlgoCode> | |
277 else | |
278 atest = false; | |
279 end | |
280 | |
281 % Return a result structure | |
282 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
283 end % END UTP_05 | |
284 | |
285 %% UTP_06 | |
286 | |
287 % <TestDescription> | |
288 % | |
289 % Tests that the t0 method properly applies history. | |
290 % | |
291 % </TestDescription> | |
292 function result = utp_06 | |
293 | |
294 % <SyntaxDescription> | |
295 % | |
296 % The t0 method doesn't change the AO, thus will no history added. | |
297 % Nothing to do | |
298 % | |
299 % </SyntaxDescription> | |
300 | |
301 try | |
302 % <SyntaxCode> | |
303 % </SyntaxCode> | |
304 stest = true; | |
305 catch err | |
306 disp(err.message) | |
307 stest = false; | |
308 end | |
309 | |
310 % <AlgoDescription> | |
311 % | |
312 % </AlgoDescription> | |
313 | |
314 atest = true; | |
315 if stest | |
316 % <AlgoCode> | |
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_06 | |
325 | |
326 %% UTP_07 | |
327 | |
328 % <TestDescription> | |
329 % | |
330 % Tests that the t0 method works for AOs with different data objects. | |
331 % | |
332 % </TestDescription> | |
333 function result = utp_07 | |
334 | |
335 % <SyntaxDescription> | |
336 % | |
337 % Test that the t0 method returns the t0 value for AOs with cdata, | |
338 % fsdata, tsdata and xydata objects. | |
339 % | |
340 % </SyntaxDescription> | |
341 | |
342 try | |
343 % <SyntaxCode> | |
344 t01 = at1.t0; | |
345 t02 = at2.t0; | |
346 t03 = at3.t0; | |
347 t04 = at4.t0; | |
348 % </SyntaxCode> | |
349 stest = true; | |
350 catch err | |
351 disp(err.message) | |
352 stest = false; | |
353 end | |
354 | |
355 % <AlgoDescription> | |
356 % | |
357 % 1) Check the output. | |
358 % | |
359 % </AlgoDescription> | |
360 | |
361 atest = true; | |
362 if stest | |
363 % <AlgoCode> | |
364 if ~eq(t01, at1.data.t0), atest = false; end; | |
365 if ~eq(t02, at2.data.t0), atest = false; end; | |
366 if ~isequalwithequalnans(t03, time(NaN)), atest = false; end; | |
367 if ~isequalwithequalnans(t04, time(NaN)), atest = false; end; | |
368 % </AlgoCode> | |
369 else | |
370 atest = false; | |
371 end | |
372 | |
373 % Return a result structure | |
374 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
375 end % END UTP_07 | |
376 | |
377 end |