Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/ao/utp_ao_cat.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_CAT a set of UTPs for the ao/cat method | |
2 % | |
3 % M Hewitson 06-08-08 | |
4 % | |
5 % $Id: utp_ao_cat.m,v 1.3 2009/08/07 10:05:38 hewitson Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The cat method of the ao class concatenate AOs into a row vector. | |
11 % | |
12 % </MethodDescription> | |
13 | |
14 function results = utp_ao_cat(varargin) | |
15 | |
16 % Check the inputs | |
17 if nargin == 0 | |
18 | |
19 % Some keywords | |
20 class = 'ao'; | |
21 mthd = 'cat'; | |
22 | |
23 results = []; | |
24 disp('******************************************************'); | |
25 disp(['**** Running UTPs for ' class '/' mthd]); | |
26 disp('******************************************************'); | |
27 | |
28 % Test AOs | |
29 [at1,at2,at3,at4,at5,at6,atvec,atmat] = get_test_objects_ao; | |
30 | |
31 % Exception list for the UTPs: | |
32 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples(); | |
33 | |
34 % Run the tests | |
35 results = [results utp_01]; % getInfo call | |
36 results = [results utp_02(mthd, atvec, @algo_test_y, [], ple3)]; % Vector input | |
37 results = [results utp_03(mthd, atmat, @algo_test_y, [], ple3)]; % Matrix input | |
38 results = [results utp_04(mthd, at1, at2, at3, @algo_test_y, [], ple3)]; % List input | |
39 results = [results utp_05(mthd, at1, atvec, atmat, @algo_test_y, [], ple3)]; % Test with mixed input | |
40 results = [results utp_06]; % Test history is working | |
41 results = [results utp_07]; % Test the modify call works not | |
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 %% Algorithm test for UTP 02,03,04,05 | |
57 | |
58 function atest = algo_test_y(in, out, pli) | |
59 atest = true; | |
60 if ~isequal(in.data.getY, out.data.getY) | |
61 atest = false; | |
62 end | |
63 end | |
64 | |
65 %% UTP_01 | |
66 | |
67 % <TestDescription> | |
68 % | |
69 % Tests that the getInfo call works for this method. | |
70 % | |
71 % </TestDescription> | |
72 function result = utp_01 | |
73 | |
74 | |
75 % <SyntaxDescription> | |
76 % | |
77 % Test that the getInfo call works for no sets, all sets, and each set | |
78 % individually. | |
79 % | |
80 % </SyntaxDescription> | |
81 | |
82 try | |
83 % <SyntaxCode> | |
84 % Call for no sets | |
85 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']); | |
86 % Call for all sets | |
87 io(2) = eval([class '.getInfo(''' mthd ''')']); | |
88 % Call for each set | |
89 for kk=1:numel(io(2).sets) | |
90 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']); | |
91 end | |
92 % </SyntaxCode> | |
93 stest = true; | |
94 catch err | |
95 disp(err.message) | |
96 stest = false; | |
97 end | |
98 | |
99 % <AlgoDescription> | |
100 % | |
101 % 1) Check that getInfo call returned an minfo object in all cases. | |
102 % 2) Check that all plists have the correct parameters. | |
103 % | |
104 % </AlgoDescription> | |
105 | |
106 atest = true; | |
107 if stest | |
108 % <AlgoCode> | |
109 % check we have minfo objects | |
110 if isa(io, 'minfo') | |
111 % SET 'None' | |
112 if ~isempty(io(1).sets), atest = false; end | |
113 if ~isempty(io(1).plists), atest = false; end | |
114 % Check all Sets | |
115 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end | |
116 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end | |
117 % SET 'Default' | |
118 if io(3).plists.nparams ~= 0, atest = false; end | |
119 % Check key | |
120 % Check default value | |
121 % Check options | |
122 end | |
123 % </AlgoCode> | |
124 else | |
125 atest = false; | |
126 end | |
127 | |
128 % Return a result structure | |
129 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
130 end % END UTP_01 | |
131 | |
132 %% UTP_06 | |
133 | |
134 % <TestDescription> | |
135 % | |
136 % The cat method doesn't apply history. | |
137 % | |
138 % </TestDescription> | |
139 function result = utp_06 | |
140 | |
141 % <SyntaxDescription> | |
142 % | |
143 % The cat method doesn't apply history. | |
144 % | |
145 % </SyntaxDescription> | |
146 | |
147 try | |
148 % <SyntaxCode> | |
149 % </SyntaxCode> | |
150 stest = true; | |
151 catch err | |
152 disp(err.message) | |
153 stest = false; | |
154 end | |
155 | |
156 % <AlgoDescription> | |
157 % | |
158 % 1) Nothing to test | |
159 % | |
160 % </AlgoDescription> | |
161 | |
162 atest = true; | |
163 if stest | |
164 % <AlgoCode> | |
165 % </AlgoCode> | |
166 else | |
167 atest = false; | |
168 end | |
169 | |
170 % Return a result structure | |
171 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
172 end % END UTP_06 | |
173 | |
174 %% UTP_07 | |
175 | |
176 % <TestDescription> | |
177 % | |
178 % The cat method can not be used as a modifer method. | |
179 % | |
180 % </TestDescription> | |
181 function result = utp_07 | |
182 | |
183 % <SyntaxDescription> | |
184 % | |
185 % The cat method can not be used as a modifer method. In this case | |
186 % throws the method an error. | |
187 % | |
188 % </SyntaxDescription> | |
189 | |
190 try | |
191 % <SyntaxCode> | |
192 % copy at1 to work with | |
193 amodi = ao(at1); | |
194 aeq = ao(at1); | |
195 out = aeq.cat(); | |
196 amodi.cat(); | |
197 stest = false; | |
198 % </SyntaxCode> | |
199 catch | |
200 stest = true; | |
201 end | |
202 | |
203 % <AlgoDescription> | |
204 % | |
205 % 1) Nothing to test. | |
206 % | |
207 % </AlgoDescription> | |
208 | |
209 atest = true; | |
210 if stest | |
211 % <AlgoCode> | |
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_07 | |
220 | |
221 end |