Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/ao/utp_ao_demux.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_DEMUX a set of UTPs for the ao/demux method | |
2 % | |
3 % M Hewitson 06-08-08 | |
4 % | |
5 % $Id: utp_ao_demux.m,v 1.2 2009/07/20 16:50:08 ingo Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The demux method of the ao class splits the input vector of AOs into a | |
11 % number of output AOs. This is a very simple method thus most of standard | |
12 % test are not possible. | |
13 % | |
14 % </MethodDescription> | |
15 | |
16 function results = utp_ao_demux(varargin) | |
17 | |
18 % Check the inputs | |
19 if nargin == 0 | |
20 | |
21 % Some keywords | |
22 class = 'ao'; | |
23 mthd = 'demux'; | |
24 | |
25 results = []; | |
26 disp('******************************************************'); | |
27 disp(['**** Running UTPs for ' class '/' mthd]); | |
28 disp('******************************************************'); | |
29 | |
30 [at1,at2,at3,at4,at5,at6,atvec,atmat] = get_test_objects_ao; | |
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]; % Test with non complex data | |
38 results = [results utp_03]; % Negative test: Too few outputs | |
39 results = [results utp_04]; % Negative test: Too many outputs | |
40 | |
41 disp('Done.'); | |
42 disp('******************************************************'); | |
43 | |
44 elseif nargin == 1 % Check for UTP functions | |
45 if strcmp(varargin{1}, 'isutp') | |
46 results = 1; | |
47 else | |
48 results = 0; | |
49 end | |
50 else | |
51 error('### Incorrect inputs') | |
52 end | |
53 | |
54 %% UTP_01 | |
55 | |
56 % <TestDescription> | |
57 % | |
58 % Tests that the getInfo call works for this method. | |
59 % | |
60 % </TestDescription> | |
61 function result = utp_01 | |
62 | |
63 | |
64 % <SyntaxDescription> | |
65 % | |
66 % Test that the getInfo call works for no sets, all sets, and each set | |
67 % individually. | |
68 % | |
69 % </SyntaxDescription> | |
70 | |
71 try | |
72 % <SyntaxCode> | |
73 % Call for no sets | |
74 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']); | |
75 % Call for all sets | |
76 io(2) = eval([class '.getInfo(''' mthd ''')']); | |
77 % Call for each set | |
78 for kk=1:numel(io(2).sets) | |
79 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']); | |
80 end | |
81 % </SyntaxCode> | |
82 stest = true; | |
83 catch err | |
84 disp(err.message) | |
85 stest = false; | |
86 end | |
87 | |
88 % <AlgoDescription> | |
89 % | |
90 % 1) Check that getInfo call returned an minfo object in all cases. | |
91 % 2) Check that all plists have the correct parameters. | |
92 % | |
93 % </AlgoDescription> | |
94 | |
95 atest = true; | |
96 if stest | |
97 % <AlgoCode> | |
98 % check we have minfo objects | |
99 if isa(io, 'minfo') | |
100 % SET 'None' | |
101 if ~isempty(io(1).sets), atest = false; end | |
102 if ~isempty(io(1).plists), atest = false; end | |
103 % Check all Sets | |
104 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end | |
105 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end | |
106 % SET 'Default' | |
107 if io(3).plists.nparams ~= 0, atest = false; end | |
108 % Check key | |
109 % Check default value | |
110 % Check options | |
111 end | |
112 % </AlgoCode> | |
113 else | |
114 atest = false; | |
115 end | |
116 | |
117 % Return a result structure | |
118 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
119 end % END UTP_01 | |
120 | |
121 %% UTP_02 | |
122 | |
123 % <TestDescription> | |
124 % | |
125 % Tests that the demux method works with a mix of different shaped AOs as | |
126 % input. | |
127 % | |
128 % </TestDescription> | |
129 function result = utp_02 | |
130 | |
131 % <SyntaxDescription> | |
132 % | |
133 % Tests that the demux method works with a mix of different shaped AOs | |
134 % as input. | |
135 % | |
136 % </SyntaxDescription> | |
137 | |
138 try | |
139 % <SyntaxCode> | |
140 % Singme AO as input | |
141 o1 = demux(at1); | |
142 % Vector of AOs as input | |
143 [ov1,ov2,ov3] = demux(atvec); | |
144 % Matrix of AOs as input | |
145 [om1,om2,om3,om4,om5,om6] = demux(atmat); | |
146 % List of AOs as input | |
147 [ol1,ol2,ol3] = demux(at1, at2, at3); | |
148 % List mixed AOs as input | |
149 [os1,os2,os3,os4] = demux(at1, atvec); | |
150 % </SyntaxCode> | |
151 stest = true; | |
152 catch err | |
153 disp(err.message) | |
154 stest = false; | |
155 end | |
156 | |
157 % <AlgoDescription> | |
158 % | |
159 % 1) Check the output objects. | |
160 % | |
161 % </AlgoDescription> | |
162 | |
163 atest = true; | |
164 if stest | |
165 % <AlgoCode> | |
166 % Check single object | |
167 if ~eq(o1, at1), atest = false; end | |
168 % Check vector object | |
169 if ~eq(ov1, atvec(1)), atest = false; end | |
170 if ~eq(ov2, atvec(2)), atest = false; end | |
171 if ~eq(ov3, atvec(3)), atest = false; end | |
172 % Check matrix object | |
173 if ~eq(om1, atmat(1)), atest = false; end | |
174 if ~eq(om2, atmat(2)), atest = false; end | |
175 if ~eq(om3, atmat(3)), atest = false; end | |
176 if ~eq(om4, atmat(4)), atest = false; end | |
177 if ~eq(om5, atmat(5)), atest = false; end | |
178 if ~eq(om6, atmat(6)), atest = false; end | |
179 % Check list object | |
180 if ~eq(ol1, at1), atest = false; end | |
181 if ~eq(ol2, at2), atest = false; end | |
182 if ~eq(ol3, at3), atest = false; end | |
183 % Check mixed object | |
184 if ~eq(os1, at1), atest = false; end | |
185 if ~eq(os2, atvec(1)), atest = false; end | |
186 if ~eq(os3, atvec(2)), atest = false; end | |
187 if ~eq(os4, atvec(3)), atest = false; end | |
188 % </AlgoCode> | |
189 else | |
190 atest = false; | |
191 end | |
192 | |
193 % Return a result structure | |
194 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
195 end % END UTP_02 | |
196 | |
197 %% UTP_03 | |
198 | |
199 % <TestDescription> | |
200 % | |
201 % Negative test. | |
202 % Check that the demux method throwns an error for too few output | |
203 % variables. | |
204 % | |
205 % </TestDescription> | |
206 function result = utp_03 | |
207 | |
208 % <SyntaxDescription> | |
209 % | |
210 % Check that the demux method throwns an error for too few output | |
211 % variables. | |
212 % | |
213 % </SyntaxDescription> | |
214 | |
215 try | |
216 % <SyntaxCode> | |
217 o1 = demux(atvec); | |
218 % </SyntaxCode> | |
219 stest = false; | |
220 catch | |
221 stest = true; | |
222 end | |
223 | |
224 % <AlgoDescription> | |
225 % | |
226 % 1) Nothing to check. | |
227 % | |
228 % </AlgoDescription> | |
229 | |
230 atest = true; | |
231 if stest | |
232 % <AlgoCode> | |
233 % </AlgoCode> | |
234 else | |
235 atest = false; | |
236 end | |
237 | |
238 % Return a result structure | |
239 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
240 end % END UTP_03 | |
241 | |
242 %% UTP_04 | |
243 | |
244 % <TestDescription> | |
245 % | |
246 % Negative test. | |
247 % Check that the demux method throwns an error for too many output | |
248 % variables. | |
249 % | |
250 % </TestDescription> | |
251 function result = utp_04 | |
252 | |
253 % <SyntaxDescription> | |
254 % | |
255 % Check that the demux method throwns an error for too few output | |
256 % variables. | |
257 % | |
258 % </SyntaxDescription> | |
259 | |
260 try | |
261 % <SyntaxCode> | |
262 [o1,o2,o3,o4,o5] = demux(atvec); | |
263 % </SyntaxCode> | |
264 stest = false; | |
265 catch | |
266 stest = true; | |
267 end | |
268 | |
269 % <AlgoDescription> | |
270 % | |
271 % 1) Nothing to check. | |
272 % | |
273 % </AlgoDescription> | |
274 | |
275 atest = true; | |
276 if stest | |
277 % <AlgoCode> | |
278 % </AlgoCode> | |
279 else | |
280 atest = false; | |
281 end | |
282 | |
283 % Return a result structure | |
284 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
285 end % END UTP_04 | |
286 | |
287 end |