Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/miir/utp_miir_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_MIIR_DISPLAY a set of UTPs for the miir/display method | |
2 % | |
3 % M Hewitson 06-08-08 | |
4 % | |
5 % $Id: utp_miir_display.m,v 1.3 2009/07/23 14:12:01 ingo Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The display method of the miir class prints defined values of an MIIR object. | |
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_miir_display(varargin) | |
17 | |
18 % Check the inputs | |
19 if nargin == 0 | |
20 | |
21 % Some keywords | |
22 class = 'miir'; | |
23 mthd = 'display'; | |
24 | |
25 results = []; | |
26 disp('******************************************************'); | |
27 disp(['**** Running UTPs for ' class '/' mthd]); | |
28 disp('******************************************************'); | |
29 | |
30 % Test MIIR objects | |
31 [iirhp,iirlp,iirbp,iirbr,iirpzm,iirab,iirv,iirm] = get_test_objects_miir; | |
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 MIIR objects as | |
129 % input. | |
130 % | |
131 % </TestDescription> | |
132 function result = utp_02 | |
133 | |
134 % <SyntaxDescription> | |
135 % | |
136 % Test that the display method works for a vector of MIIR objects as | |
137 % input. | |
138 % | |
139 % </SyntaxDescription> | |
140 | |
141 try | |
142 % <SyntaxCode> | |
143 iirv | |
144 out = display(iirv); | |
145 % </SyntaxCode> | |
146 stest = true; | |
147 catch err | |
148 disp(err.message) | |
149 stest = false; | |
150 end | |
151 | |
152 % <AlgoDescription> | |
153 % | |
154 % 1) Check that the output contain at least each object name | |
155 % | |
156 % </AlgoDescription> | |
157 | |
158 atest = true; | |
159 if stest | |
160 % <AlgoCode> | |
161 % Check the output | |
162 if ~iscell(out), atest = false; end; | |
163 for kk = 1:numel(iirv) | |
164 if isempty(strfind(out, iirv(kk).name)), atest = false; end | |
165 end | |
166 % </AlgoCode> | |
167 else | |
168 atest = false; | |
169 end | |
170 | |
171 % Return a result structure | |
172 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
173 end % END UTP_02 | |
174 | |
175 %% UTP_03 | |
176 | |
177 % <TestDescription> | |
178 % | |
179 % Tests that the display method works with a matrix of MIIR objects as | |
180 % input. | |
181 % | |
182 % </TestDescription> | |
183 function result = utp_03 | |
184 | |
185 % <SyntaxDescription> | |
186 % | |
187 % Test that the display method works for a matrix of MIIR objects as | |
188 % input. | |
189 % | |
190 % </SyntaxDescription> | |
191 | |
192 try | |
193 % <SyntaxCode> | |
194 iirm | |
195 out = display(iirm); | |
196 % </SyntaxCode> | |
197 stest = true; | |
198 catch err | |
199 disp(err.message) | |
200 stest = false; | |
201 end | |
202 | |
203 % <AlgoDescription> | |
204 % | |
205 % 1) Check that the output contain at least each object name | |
206 % | |
207 % </AlgoDescription> | |
208 | |
209 atest = true; | |
210 if stest | |
211 % <AlgoCode> | |
212 if ~iscell(out), atest = false; end; | |
213 for kk = 1:numel(iirm) | |
214 if isempty(strfind(out, iirm(kk).name)), atest = false; end | |
215 end | |
216 % </AlgoCode> | |
217 else | |
218 atest = false; | |
219 end | |
220 | |
221 % Return a result structure | |
222 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
223 end % END UTP_03 | |
224 | |
225 %% UTP_04 | |
226 | |
227 % <TestDescription> | |
228 % | |
229 % Tests that the display method works with a list of MIIR objects as | |
230 % input. | |
231 % | |
232 % </TestDescription> | |
233 function result = utp_04 | |
234 | |
235 % <SyntaxDescription> | |
236 % | |
237 % Test that the display method works for a list of MIIR objects as | |
238 % input. | |
239 % | |
240 % </SyntaxDescription> | |
241 | |
242 try | |
243 % <SyntaxCode> | |
244 iirlp,iirbp,iirab | |
245 out = display(iirlp,iirbp,iirab); | |
246 % </SyntaxCode> | |
247 stest = true; | |
248 catch err | |
249 disp(err.message) | |
250 stest = false; | |
251 end | |
252 | |
253 % <AlgoDescription> | |
254 % | |
255 % 1) Check that the output contain at least each object name | |
256 % | |
257 % </AlgoDescription> | |
258 | |
259 atest = true; | |
260 iirin = [iirlp,iirbp,iirab]; | |
261 if stest | |
262 % <AlgoCode> | |
263 if ~iscell(out), atest = false; end; | |
264 for kk = 1:numel(iirin) | |
265 if isempty(strfind(out, iirin(kk).name)), atest = false; end | |
266 end | |
267 % </AlgoCode> | |
268 else | |
269 atest = false; | |
270 end | |
271 | |
272 % Return a result structure | |
273 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
274 end % END UTP_04 | |
275 | |
276 %% UTP_05 | |
277 | |
278 % <TestDescription> | |
279 % | |
280 % Tests that the display method works with a mix of different shaped | |
281 % MIIR objects as input. | |
282 % | |
283 % </TestDescription> | |
284 function result = utp_05 | |
285 | |
286 % <SyntaxDescription> | |
287 % | |
288 % Test that the display method works with an input of matrices and | |
289 % vectors and single MIIR objects as. | |
290 % | |
291 % </SyntaxDescription> | |
292 | |
293 try | |
294 % <SyntaxCode> | |
295 out = display(iirhp,iirv,iirbr,iirm,iirpzm); | |
296 % </SyntaxCode> | |
297 stest = true; | |
298 catch err | |
299 disp(err.message) | |
300 stest = false; | |
301 end | |
302 | |
303 % <AlgoDescription> | |
304 % | |
305 % 1) Check that the output contain at least each object name | |
306 % | |
307 % </AlgoDescription> | |
308 | |
309 atest = true; | |
310 iirin = [iirhp,reshape(iirv,1,[]),iirbr,reshape(iirm,1,[]),iirpzm]; | |
311 if stest | |
312 % <AlgoCode> | |
313 if ~iscell(out), atest = false; end; | |
314 for kk = 1:numel(iirin) | |
315 if isempty(strfind(out, iirin(kk).name)), 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_05 | |
325 | |
326 %% UTP_06 | |
327 | |
328 % <TestDescription> | |
329 % | |
330 % Tests that the display method properly applies history. | |
331 % | |
332 % </TestDescription> | |
333 function result = utp_06 | |
334 | |
335 % <SyntaxDescription> | |
336 % | |
337 % The method display doesn't change the data, thus it is not possible | |
338 % to check the history. Nothing to do. | |
339 % | |
340 % </SyntaxDescription> | |
341 | |
342 try | |
343 % <SyntaxCode> | |
344 % </SyntaxCode> | |
345 stest = true; | |
346 catch err | |
347 disp(err.message) | |
348 stest = false; | |
349 end | |
350 | |
351 % <AlgoDescription> | |
352 % | |
353 % </AlgoDescription> | |
354 | |
355 atest = true; | |
356 if stest | |
357 % <AlgoCode> | |
358 % </AlgoCode> | |
359 else | |
360 atest = false; | |
361 end | |
362 | |
363 % Return a result structure | |
364 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
365 end % END UTP_06 | |
366 | |
367 end |