comparison testing/utp_1.1/utps/plist/utp_plist_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_PLIST_DISPLAY a set of UTPs for the plist/display method
2 %
3 % M Hewitson 06-08-08
4 %
5 % $Id: utp_plist_display.m,v 1.2 2009/07/22 14:02:26 ingo Exp $
6 %
7
8 % <MethodDescription>
9 %
10 % The display method of the plist class prints defined values of an PLIST 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_plist_display(varargin)
17
18 % Check the inputs
19 if nargin == 0
20
21 % Some keywords
22 class = 'plist';
23 mthd = 'display';
24
25 results = [];
26 disp('******************************************************');
27 disp(['**** Running UTPs for ' class '/' mthd]);
28 disp('******************************************************');
29
30 % Test PLIST objects
31 [pl1, pl2, pl3, pl4, plv, plm] = get_test_objects_plist;
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
43 disp('Done.');
44 disp('******************************************************');
45
46 elseif nargin == 1 % Check for UTP functions
47 if strcmp(varargin{1}, 'isutp')
48 results = 1;
49 else
50 results = 0;
51 end
52 else
53 error('### Incorrect inputs')
54 end
55
56 %% UTP_01
57
58 % <TestDescription>
59 %
60 % Tests that the getInfo call works for this method.
61 %
62 % </TestDescription>
63 function result = utp_01
64
65
66 % <SyntaxDescription>
67 %
68 % Test that the getInfo call works for no sets, all sets, and each set
69 % individually.
70 %
71 % </SyntaxDescription>
72
73 try
74 % <SyntaxCode>
75 % Call for no sets
76 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
77 % Call for all sets
78 io(2) = eval([class '.getInfo(''' mthd ''')']);
79 % Call for each set
80 for kk=1:numel(io(2).sets)
81 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
82 end
83 % </SyntaxCode>
84 stest = true;
85 catch err
86 disp(err.message)
87 stest = false;
88 end
89
90 % <AlgoDescription>
91 %
92 % 1) Check that getInfo call returned an minfo object in all cases.
93 % 2) Check that all plists have the correct parameters.
94 %
95 % </AlgoDescription>
96
97 atest = true;
98 if stest
99 % <AlgoCode>
100 % check we have minfo objects
101 if isa(io, 'minfo')
102 % SET 'None'
103 if ~isempty(io(1).sets), atest = false; end
104 if ~isempty(io(1).plists), atest = false; end
105 % Check all Sets
106 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end
107 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end
108 % SET 'Default'
109 if io(3).plists.nparams ~= 0, atest = false; end
110 % Check key
111 % Check default value
112 % Check options
113 end
114 % </AlgoCode>
115 else
116 atest = false;
117 end
118
119 % Return a result structure
120 result = utp_prepare_result(atest, stest, dbstack, mfilename);
121 end % END UTP_01
122
123 %% UTP_02
124
125 % <TestDescription>
126 %
127 % Tests that the display method works with a vector of PLIST objects as input.
128 %
129 % </TestDescription>
130 function result = utp_02
131
132 % <SyntaxDescription>
133 %
134 % Test that the display method works for a vector of PLIST objects as input.
135 %
136 % </SyntaxDescription>
137
138 try
139 % <SyntaxCode>
140 plv
141 out = display(plv);
142 % </SyntaxCode>
143 stest = true;
144 catch err
145 disp(err.message)
146 stest = false;
147 end
148
149 % <AlgoDescription>
150 %
151 % 1) Check that the output contain at least each object name
152 %
153 % </AlgoDescription>
154
155 atest = true;
156 if stest
157 % <AlgoCode>
158 % Check the output
159 if ~iscell(out), atest = false; end;
160 for kk = 1:numel(plv)
161 if isempty(strfind(out, plv(kk).name)), atest = false; end
162 end
163 % </AlgoCode>
164 else
165 atest = false;
166 end
167
168 % Return a result structure
169 result = utp_prepare_result(atest, stest, dbstack, mfilename);
170 end % END UTP_02
171
172 %% UTP_03
173
174 % <TestDescription>
175 %
176 % Tests that the display method works with a matrix of PLIST objects as input.
177 %
178 % </TestDescription>
179 function result = utp_03
180
181 % <SyntaxDescription>
182 %
183 % Test that the display method works for a matrix of PLIST objects as input.
184 %
185 % </SyntaxDescription>
186
187 try
188 % <SyntaxCode>
189 plm
190 out = display(plm);
191 % </SyntaxCode>
192 stest = true;
193 catch err
194 disp(err.message)
195 stest = false;
196 end
197
198 % <AlgoDescription>
199 %
200 % 1) Check that the output contain at least each object name
201 %
202 % </AlgoDescription>
203
204 atest = true;
205 if stest
206 % <AlgoCode>
207 if ~iscell(out), atest = false; end;
208 for kk = 1:numel(plm)
209 if isempty(strfind(out, plm(kk).name)), atest = false; end
210 end
211 % </AlgoCode>
212 else
213 atest = false;
214 end
215
216 % Return a result structure
217 result = utp_prepare_result(atest, stest, dbstack, mfilename);
218 end % END UTP_03
219
220 %% UTP_04
221
222 % <TestDescription>
223 %
224 % Tests that the display method works with a list of PLIST objects as input.
225 %
226 % </TestDescription>
227 function result = utp_04
228
229 % <SyntaxDescription>
230 %
231 % Test that the display method works for a list of PLIST objects as input.
232 %
233 % </SyntaxDescription>
234
235 try
236 % <SyntaxCode>
237 pl1,pl2,pl3, pl4
238 out = display(pl1,pl2,pl3, pl4);
239 % </SyntaxCode>
240 stest = true;
241 catch err
242 disp(err.message)
243 stest = false;
244 end
245
246 % <AlgoDescription>
247 %
248 % 1) Check that the output contain at least each object name
249 %
250 % </AlgoDescription>
251
252 atest = true;
253 plin = [pl1,pl2,pl3, pl4];
254 if stest
255 % <AlgoCode>
256 if ~iscell(out), atest = false; end;
257 for kk = 1:numel(plin)
258 if isempty(strfind(out, plin(kk).name)), atest = false; end
259 end
260 % </AlgoCode>
261 else
262 atest = false;
263 end
264
265 % Return a result structure
266 result = utp_prepare_result(atest, stest, dbstack, mfilename);
267 end % END UTP_04
268
269 %% UTP_05
270
271 % <TestDescription>
272 %
273 % Tests that the display method works with a mix of different shaped
274 % PLIST objects as input.
275 %
276 % </TestDescription>
277 function result = utp_05
278
279 % <SyntaxDescription>
280 %
281 % Test that the display method works with an input of matrices and vectors
282 % and single PLIST objects as.
283 %
284 % </SyntaxDescription>
285
286 try
287 % <SyntaxCode>
288 out = display(pl4,plv,pl3,plm,pl2);
289 % </SyntaxCode>
290 stest = true;
291 catch err
292 disp(err.message)
293 stest = false;
294 end
295
296 % <AlgoDescription>
297 %
298 % 1) Check that the output contain at least each object name
299 %
300 % </AlgoDescription>
301
302 atest = true;
303 plin = [pl4,reshape(plv,1,[]),pl3,reshape(plm,1,[]),pl2];
304 if stest
305 % <AlgoCode>
306 if ~iscell(out), atest = false; end;
307 for kk = 1:numel(plin)
308 if isempty(strfind(out, plin(kk).name)), atest = false; end
309 end
310 % </AlgoCode>
311 else
312 atest = false;
313 end
314
315 % Return a result structure
316 result = utp_prepare_result(atest, stest, dbstack, mfilename);
317 end % END UTP_05
318
319 end