Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/ao/utp_ao_x.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_AO_X a set of UTPs for the ao/x method | |
2 % | |
3 % M Hewitson 06-08-08 | |
4 % | |
5 % $Id: utp_ao_x.m,v 1.3 2009/07/21 15:57:44 ingo Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The x method of the ao class is a get-function to get the x values of the | |
11 % data object | |
12 % | |
13 % </MethodDescription> | |
14 | |
15 function results = utp_ao_x(varargin) | |
16 | |
17 % Check the inputs | |
18 if nargin == 0 | |
19 | |
20 % Some keywords | |
21 class = 'ao'; | |
22 mthd = 'x'; | |
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 results = [results utp_08]; % Test with additional plist with the key 'axis' | |
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 % SET 'None' | |
105 if ~isempty(io(1).sets), atest = false; end | |
106 if ~isempty(io(1).plists), atest = false; end | |
107 % Check all Sets | |
108 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end | |
109 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end | |
110 % SET 'Default' | |
111 if io(3).plists.nparams ~= 0, atest = false; end | |
112 % Check key | |
113 % Check default value | |
114 % Check options | |
115 end | |
116 % </AlgoCode> | |
117 else | |
118 atest = false; | |
119 end | |
120 | |
121 % Return a result structure | |
122 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
123 end % END UTP_01 | |
124 | |
125 %% UTP_02 | |
126 | |
127 % <TestDescription> | |
128 % | |
129 % Tests that the x method works with a vector of AOs as input. | |
130 % | |
131 % </TestDescription> | |
132 function result = utp_02 | |
133 | |
134 % <SyntaxDescription> | |
135 % | |
136 % The x method doesn't work with a vector of AOs. Nothing to do | |
137 % | |
138 % </SyntaxDescription> | |
139 | |
140 try | |
141 % <SyntaxCode> | |
142 % </SyntaxCode> | |
143 stest = true; | |
144 catch err | |
145 disp(err.message) | |
146 stest = false; | |
147 end | |
148 | |
149 % <AlgoDescription> | |
150 % | |
151 % </AlgoDescription> | |
152 | |
153 atest = true; | |
154 if stest | |
155 % <AlgoCode> | |
156 % </AlgoCode> | |
157 else | |
158 atest = false; | |
159 end | |
160 | |
161 % Return a result structure | |
162 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
163 end % END UTP_02 | |
164 | |
165 %% UTP_03 | |
166 | |
167 % <TestDescription> | |
168 % | |
169 % Tests that the x method works with a matrix of AOs as input. | |
170 % | |
171 % </TestDescription> | |
172 function result = utp_03 | |
173 | |
174 % <SyntaxDescription> | |
175 % | |
176 % The x method doesn't work with a matrix of AOs. Nothing to do | |
177 % | |
178 % </SyntaxDescription> | |
179 | |
180 try | |
181 % <SyntaxCode> | |
182 % </SyntaxCode> | |
183 stest = true; | |
184 catch err | |
185 disp(err.message) | |
186 stest = false; | |
187 end | |
188 | |
189 % <AlgoDescription> | |
190 % | |
191 % </AlgoDescription> | |
192 | |
193 atest = true; | |
194 if stest | |
195 % <AlgoCode> | |
196 % </AlgoCode> | |
197 else | |
198 atest = false; | |
199 end | |
200 | |
201 % Return a result structure | |
202 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
203 end % END UTP_03 | |
204 | |
205 %% UTP_04 | |
206 | |
207 % <TestDescription> | |
208 % | |
209 % Tests that the x method works with a list of AOs as input. | |
210 % | |
211 % </TestDescription> | |
212 function result = utp_04 | |
213 | |
214 % <SyntaxDescription> | |
215 % | |
216 % The x method doesn't work with a list of AOs. Nothing to do | |
217 % | |
218 % </SyntaxDescription> | |
219 | |
220 try | |
221 % <SyntaxCode> | |
222 % </SyntaxCode> | |
223 stest = true; | |
224 catch err | |
225 disp(err.message) | |
226 stest = false; | |
227 end | |
228 | |
229 % <AlgoDescription> | |
230 % | |
231 % </AlgoDescription> | |
232 | |
233 atest = true; | |
234 if stest | |
235 % <AlgoCode> | |
236 % </AlgoCode> | |
237 else | |
238 atest = false; | |
239 end | |
240 | |
241 % Return a result structure | |
242 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
243 end % END UTP_04 | |
244 | |
245 %% UTP_05 | |
246 | |
247 % <TestDescription> | |
248 % | |
249 % Tests that the x method works with a mix of different shaped AOs as | |
250 % input. | |
251 % | |
252 % </TestDescription> | |
253 function result = utp_05 | |
254 | |
255 % <SyntaxDescription> | |
256 % | |
257 % The x method can only return the x values of one AO. Nothing to do | |
258 % | |
259 % </SyntaxDescription> | |
260 | |
261 try | |
262 % <SyntaxCode> | |
263 % </SyntaxCode> | |
264 stest = true; | |
265 catch err | |
266 disp(err.message) | |
267 stest = false; | |
268 end | |
269 | |
270 % <AlgoDescription> | |
271 % | |
272 % </AlgoDescription> | |
273 | |
274 atest = true; | |
275 if stest | |
276 % <AlgoCode> | |
277 % </AlgoCode> | |
278 else | |
279 atest = false; | |
280 end | |
281 | |
282 % Return a result structure | |
283 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
284 end % END UTP_05 | |
285 | |
286 %% UTP_06 | |
287 | |
288 % <TestDescription> | |
289 % | |
290 % Tests that the x method properly applies history. | |
291 % | |
292 % </TestDescription> | |
293 function result = utp_06 | |
294 | |
295 % <SyntaxDescription> | |
296 % | |
297 % The x method doesn't change the AO, thus will no history added. | |
298 % Nothing to do | |
299 % | |
300 % </SyntaxDescription> | |
301 | |
302 try | |
303 % <SyntaxCode> | |
304 % </SyntaxCode> | |
305 stest = true; | |
306 catch err | |
307 disp(err.message) | |
308 stest = false; | |
309 end | |
310 | |
311 % <AlgoDescription> | |
312 % | |
313 % </AlgoDescription> | |
314 | |
315 atest = true; | |
316 if stest | |
317 % <AlgoCode> | |
318 % </AlgoCode> | |
319 else | |
320 atest = false; | |
321 end | |
322 | |
323 % Return a result structure | |
324 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
325 end % END UTP_06 | |
326 | |
327 %% UTP_07 | |
328 | |
329 % <TestDescription> | |
330 % | |
331 % Tests that the x method works for AOs with different data objects. | |
332 % | |
333 % </TestDescription> | |
334 function result = utp_07 | |
335 | |
336 % <SyntaxDescription> | |
337 % | |
338 % Test that the x method returns the x values for AOs with cdata, fsdata, | |
339 % tsdata and xydata objects. | |
340 % | |
341 % </SyntaxDescription> | |
342 | |
343 try | |
344 % <SyntaxCode> | |
345 x1 = at1.x; | |
346 x2 = at2.x; | |
347 x3 = at3.x; | |
348 x4 = at4.x; | |
349 % </SyntaxCode> | |
350 stest = true; | |
351 catch err | |
352 disp(err.message) | |
353 stest = false; | |
354 end | |
355 | |
356 % <AlgoDescription> | |
357 % | |
358 % 1) Check the output. | |
359 % | |
360 % </AlgoDescription> | |
361 | |
362 atest = true; | |
363 if stest | |
364 % <AlgoCode> | |
365 if ~isequal(x1, at1.data.getX), atest = false; end; | |
366 if ~isequal(x2, at2.data.x), atest = false; end; | |
367 if ~isequal(x3, at3.data.x'), atest = false; end; | |
368 if ~isequal(x4, []), atest = false; end; | |
369 % </AlgoCode> | |
370 else | |
371 atest = false; | |
372 end | |
373 | |
374 % Return a result structure | |
375 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
376 end % END UTP_07 | |
377 | |
378 %% UTP_08 | |
379 | |
380 % <TestDescription> | |
381 % | |
382 % Tests that the x method returns the x values of the data object | |
383 % | |
384 % </TestDescription> | |
385 function result = utp_08 | |
386 | |
387 % <SyntaxDescription> | |
388 % | |
389 % Test that the x method returns the x values in a column vector independent | |
390 % form the shape of the values in the data object. | |
391 % | |
392 % </SyntaxDescription> | |
393 | |
394 try | |
395 % <SyntaxCode> | |
396 x1 = at5.x; | |
397 x2 = at6.x; | |
398 % </SyntaxCode> | |
399 stest = true; | |
400 catch err | |
401 disp(err.message) | |
402 stest = false; | |
403 end | |
404 | |
405 % <AlgoDescription> | |
406 % | |
407 % 1) Check that 'x1' and 'x2' are column vectors. | |
408 % | |
409 % </AlgoDescription> | |
410 | |
411 atest = true; | |
412 if stest | |
413 % <AlgoCode> | |
414 if size(x1, 2) ~= 1, atest = false; end; | |
415 if size(x2, 2) ~= 1, atest = false; end; | |
416 % </AlgoCode> | |
417 else | |
418 atest = false; | |
419 end | |
420 | |
421 % Return a result structure | |
422 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
423 end % END UTP_08 | |
424 | |
425 end |