Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/ao/utp_ao_display.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_DISPLAY a set of UTPs for the ao/display method | |
2 % | |
3 % M Hewitson 06-08-08 | |
4 % | |
5 % $Id: utp_ao_display.m,v 1.3 2009/07/20 16:50:08 ingo Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The display method of the ao class prints defined values of an AO. | |
11 % MATLAB calls display when it interprets an object that is not terminated | |
12 % by a semicolon. | |
13 % | |
14 % </MethodDescription> | |
15 | |
16 function results = utp_ao_display(varargin) | |
17 | |
18 % Check the inputs | |
19 if nargin == 0 | |
20 | |
21 % Some keywords | |
22 class = 'ao'; | |
23 mthd = 'display'; | |
24 | |
25 results = []; | |
26 disp('******************************************************'); | |
27 disp(['**** Running UTPs for ' class '/' mthd]); | |
28 disp('******************************************************'); | |
29 | |
30 % Test AOs | |
31 [at1,at2,at3,at4,at5,at6,atvec,atmat] = eval(['get_test_objects_' class]); | |
32 | |
33 % Exception list for the UTPs: | |
34 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples(); | |
35 | |
36 % Run the tests | |
37 results = [results utp_01]; % getInfo call | |
38 results = [results utp_02]; % Vector input | |
39 results = [results utp_03]; % Matrix input | |
40 results = [results utp_04]; % List input | |
41 results = [results utp_05]; % Test with mixed input | |
42 results = [results utp_06]; % Test history is working | |
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 display method works with a vector of AOs as input. | |
129 % | |
130 % </TestDescription> | |
131 function result = utp_02 | |
132 | |
133 % <SyntaxDescription> | |
134 % | |
135 % Test that the display method works for a vector of AOs as input. | |
136 % | |
137 % </SyntaxDescription> | |
138 | |
139 try | |
140 % <SyntaxCode> | |
141 atvec | |
142 out = display(atvec); | |
143 % </SyntaxCode> | |
144 stest = true; | |
145 catch err | |
146 disp(err.message) | |
147 stest = false; | |
148 end | |
149 | |
150 % <AlgoDescription> | |
151 % | |
152 % 1) Check that the output contain at least each object name | |
153 % | |
154 % </AlgoDescription> | |
155 | |
156 atest = true; | |
157 if stest | |
158 % <AlgoCode> | |
159 % Check the output | |
160 if ~iscell(out), atest = false; end; | |
161 for kk = 1:numel(atvec) | |
162 if isempty(strfind(out, atvec(kk).name)), atest = false; end | |
163 end | |
164 % </AlgoCode> | |
165 else | |
166 atest = false; | |
167 end | |
168 | |
169 % Return a result structure | |
170 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
171 end % END UTP_02 | |
172 | |
173 %% UTP_03 | |
174 | |
175 % <TestDescription> | |
176 % | |
177 % Tests that the display method works with a matrix of AOs as input. | |
178 % | |
179 % </TestDescription> | |
180 function result = utp_03 | |
181 | |
182 % <SyntaxDescription> | |
183 % | |
184 % Test that the display method works for a matrix of AOs as input. | |
185 % | |
186 % </SyntaxDescription> | |
187 | |
188 try | |
189 % <SyntaxCode> | |
190 atmat | |
191 out = display(atmat); | |
192 % </SyntaxCode> | |
193 stest = true; | |
194 catch err | |
195 disp(err.message) | |
196 stest = false; | |
197 end | |
198 | |
199 % <AlgoDescription> | |
200 % | |
201 % 1) Check that the output contain at least each object name | |
202 % | |
203 % </AlgoDescription> | |
204 | |
205 atest = true; | |
206 if stest | |
207 % <AlgoCode> | |
208 if ~iscell(out), atest = false; end; | |
209 for kk = 1:numel(atmat) | |
210 if isempty(strfind(out, atmat(kk).name)), 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 display method works with a list of AOs as input. | |
226 % | |
227 % </TestDescription> | |
228 function result = utp_04 | |
229 | |
230 % <SyntaxDescription> | |
231 % | |
232 % Test that the display method works for a list of AOs as input. | |
233 % | |
234 % </SyntaxDescription> | |
235 | |
236 try | |
237 % <SyntaxCode> | |
238 at1,at2,at3 | |
239 out = display(at1,at2,at3); | |
240 % </SyntaxCode> | |
241 stest = true; | |
242 catch err | |
243 disp(err.message) | |
244 stest = false; | |
245 end | |
246 | |
247 % <AlgoDescription> | |
248 % | |
249 % 1) Check that the output contain at least each object name | |
250 % | |
251 % </AlgoDescription> | |
252 | |
253 atest = true; | |
254 aoin = [at1,at2,at3]; | |
255 if stest | |
256 % <AlgoCode> | |
257 if ~iscell(out), atest = false; end; | |
258 for kk = 1:numel(aoin) | |
259 if isempty(strfind(out, aoin(kk).name)), atest = false; end | |
260 end | |
261 % </AlgoCode> | |
262 else | |
263 atest = false; | |
264 end | |
265 | |
266 % Return a result structure | |
267 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
268 end % END UTP_04 | |
269 | |
270 %% UTP_05 | |
271 | |
272 % <TestDescription> | |
273 % | |
274 % Tests that the display method works with a mix of different shaped AOs as | |
275 % input. | |
276 % | |
277 % </TestDescription> | |
278 function result = utp_05 | |
279 | |
280 % <SyntaxDescription> | |
281 % | |
282 % Test that the display method works with an input of matrices and vectors | |
283 % and single AOs. | |
284 % | |
285 % </SyntaxDescription> | |
286 | |
287 try | |
288 % <SyntaxCode> | |
289 out = display(at1,atvec,at2,atmat,at3); | |
290 % </SyntaxCode> | |
291 stest = true; | |
292 catch err | |
293 disp(err.message) | |
294 stest = false; | |
295 end | |
296 | |
297 % <AlgoDescription> | |
298 % | |
299 % 1) Check that the output contain at least each object name | |
300 % | |
301 % </AlgoDescription> | |
302 | |
303 atest = true; | |
304 aoin = [at1,reshape(atvec,1,[]),at2,reshape(atmat,1,[]),at3]; | |
305 if stest | |
306 % <AlgoCode> | |
307 if ~iscell(out), atest = false; end; | |
308 for kk = 1:numel(aoin) | |
309 if isempty(strfind(out, aoin(kk).name)), atest = false; end | |
310 end | |
311 % </AlgoCode> | |
312 else | |
313 atest = false; | |
314 end | |
315 | |
316 % Return a result structure | |
317 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
318 end % END UTP_05 | |
319 | |
320 %% UTP_06 | |
321 | |
322 % <TestDescription> | |
323 % | |
324 % Tests that the display method properly applies history. | |
325 % | |
326 % </TestDescription> | |
327 function result = utp_06 | |
328 | |
329 % <SyntaxDescription> | |
330 % | |
331 % The method display doesn't change the data, thus it is not possible to | |
332 % check the history. Nothing to do. | |
333 % | |
334 % </SyntaxDescription> | |
335 | |
336 try | |
337 % <SyntaxCode> | |
338 % </SyntaxCode> | |
339 stest = true; | |
340 catch err | |
341 disp(err.message) | |
342 stest = false; | |
343 end | |
344 | |
345 % <AlgoDescription> | |
346 % | |
347 % </AlgoDescription> | |
348 | |
349 atest = true; | |
350 if stest | |
351 % <AlgoCode> | |
352 % </AlgoCode> | |
353 else | |
354 atest = false; | |
355 end | |
356 | |
357 % Return a result structure | |
358 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
359 end % END UTP_06 | |
360 | |
361 end |