comparison testing/utp_1.1/utps/ssm/utp_ssm_ssm.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_SSM_SSM a set of UTPs for the ssm/ssm method
2 %
3 % M Hewitson 06-08-08
4 %
5 % $Id: utp_ssm_ssm.m,v 1.14 2011/09/29 13:46:19 ingo Exp $
6 %
7
8 % <MethodDescription>
9 %
10 % The ssm method of the ssm class constructs SSM objects.
11 %
12 % </MethodDescription>
13
14 function results = utp_ssm_ssm(varargin)
15
16 % Check the inputs
17 if nargin == 0
18
19 % Some keywords
20 class = 'ssm';
21 mthd = 'ssm';
22
23 results = [];
24 disp('******************************************************');
25 disp(['**** Running UTPs for ' class '/' mthd]);
26 disp('******************************************************');
27
28 % Test objects
29 [sys1, sys2] = get_test_objects_ssm;
30
31 % Exception list for the UTPs:
32 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
33
34 % Run the general tests
35 results = [results utp_01]; % getInfo call
36 results = [results utp_02(mthd, [sys1 sys2], [], [], ple3)]; % Vector input
37 results = [results utp_03(mthd, [sys1 sys2 sys1; sys2 sys2 sys1], [], [], ple3)]; % Matrix input
38 results = [results utp_04(mthd, sys1, sys2, sys1, [], [], ple3)]; % List input
39 results = [results utp_05(mthd, sys1, [sys1 sys2], [sys1 sys2 sys1; sys2 sys2 sys1], [], [], ple3)]; % Test with mixed input
40 results = [results utp_06(mthd, sys1, [], ple1)]; % Test history is working
41
42 % constructor specific tests
43 results = [results utp_60(class, sys1, ple1)]; % Test history is properly handled with MAT file constructor
44 results = [results utp_61(class, sys1, ple1)]; % Test history is properly handled with XML file constructor
45 results = [results utp_62(class, sys1, sys2, ple2)]; % Test history is working with struct constructor
46 results = [results utp_63(class, ple1)]; % Test history is working with pzmodel-object constructor
47 results = [results utp_64(class, sys1, ple1, ple2)]; % Test history is working with plist(filename) constructor
48 results = [results utp_65(class, sys2, ple3)]; % Test history is working with plist(hostname) constructor
49 results = [results utp_66(class, ple1)]; % Test history is working with plist(pzmodel) constructor
50 results = [results utp_67(class, ple1)]; % Test history is working with pzmodel + plist constructor
51 results = [results utp_68(class, sys1, ple3)]; % Test history is working with conn+Id constructor
52
53 disp('Done.');
54 disp('******************************************************');
55
56 elseif nargin == 1 % Check for UTP functions
57 if strcmp(varargin{1}, 'isutp')
58 results = 1;
59 elseif strcmpi(varargin{1}, 'needs repository')
60 results = 2;
61 else
62 results = 0;
63 end
64 else
65 error('### Incorrect inputs')
66 end
67
68 %% UTP_01
69
70 % <TestDescription>
71 %
72 % Tests that the getInfo call works for this method.
73 %
74 % </TestDescription>
75 function result = utp_01
76
77
78 % <SyntaxDescription>
79 %
80 % Test that the getInfo call works for no sets, all sets, and each set
81 % individually.
82 %
83 % </SyntaxDescription>
84
85 try
86 % <SyntaxCode>
87 % Call for no sets
88 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
89 % Call for all sets
90 io(2) = eval([class '.getInfo(''' mthd ''')']);
91 % Call for each set
92 for kk=1:numel(io(2).sets)
93 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
94 end
95 % </SyntaxCode>
96 stest = true;
97 catch err
98 disp(err.message)
99 stest = false;
100 end
101
102 % <AlgoDescription>
103 %
104 % 1) Check that getInfo call returned an minfo object in all cases.
105 % 2) Check that all plists have the correct parameters.
106 %
107 % </AlgoDescription>
108
109 atest = true;
110 if stest
111 % <AlgoCode>
112 % check we have minfo objects
113 if isa(io, 'minfo')
114 %%% SET 'None'
115 if ~isempty(io(1).sets), atest = false; end
116 if ~isempty(io(1).plists), atest = false; end
117 %%% Check all Sets
118 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end
119 if ~any(strcmpi(io(2).sets, 'From MAT File')), atest = false; end
120 if ~any(strcmpi(io(2).sets, 'From XML File')), atest = false; end
121 if ~any(strcmpi(io(2).sets, 'From Repository')), atest = false; end
122 if ~any(strcmpi(io(2).sets, 'From Built-in Model')), atest = false; end
123 if ~any(strcmpi(io(2).sets, 'From Description')), atest = false; end
124 if ~any(strcmpi(io(2).sets, 'From Pzmodel')), atest = false; end
125 if ~any(strcmpi(io(2).sets, 'From Miir')), atest = false; end
126 if ~any(strcmpi(io(2).sets, 'From Rational')), atest = false; end
127 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end
128 %%%%%%%%%% SET 'Default'
129 pn = 3;
130 if io(pn).plists.nparams ~= 12, atest = false; end
131 % Check key
132 if ~io(pn).plists.isparam('name'), atest = false; end
133 if ~io(pn).plists.isparam('description'), atest = false; end
134 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
135 if ~io(pn).plists.isparam('states'), atest = false; end
136 if ~io(pn).plists.isparam('outputs'), atest = false; end
137 if ~io(pn).plists.isparam('inputs'), atest = false; end
138 if ~io(pn).plists.isparam('timestep'), atest = false; end
139 if ~io(pn).plists.isparam('amats'), atest = false; end
140 if ~io(pn).plists.isparam('bmats'), atest = false; end
141 if ~io(pn).plists.isparam('cmats'), atest = false; end
142 if ~io(pn).plists.isparam('dmats'), atest = false; end
143 if ~io(pn).plists.isparam('params'), atest = false; end
144 % Check default value
145 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
146 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
147 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
148 %%%%%%%%%% SET 'From MAT File'
149 pn = 4;
150 if io(pn).plists.nparams ~= 4, atest = false; end
151 % Check key
152 if ~io(pn).plists.isparam('name'), atest = false; end
153 if ~io(pn).plists.isparam('description'), atest = false; end
154 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
155 if ~io(pn).plists.isparam('filename'), atest = false; end
156 % Check default value
157 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
158 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
159 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
160 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end
161 %%%%%%%%%% SET 'From XML File'
162 pn = 5;
163 if io(pn).plists.nparams ~= 4, atest = false; end
164 % Check key
165 if ~io(pn).plists.isparam('name'), atest = false; end
166 if ~io(pn).plists.isparam('description'), atest = false; end
167 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
168 if ~io(pn).plists.isparam('filename'), atest = false; end
169 % Check default value
170 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
171 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
172 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
173 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end
174 %%%%%%%%%% SET 'From Repository'
175 pn = 6;
176 if io(pn).plists.nparams ~= 10, atest = false; end
177 % Check key
178 if ~io(pn).plists.isparam('name'), atest = false; end
179 if ~io(pn).plists.isparam('description'), atest = false; end
180 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
181 if ~io(pn).plists.isparam('hostname'), atest = false; end
182 if ~io(pn).plists.isparam('id'), atest = false; end
183 if ~io(pn).plists.isparam('cid'), atest = false; end
184 if ~io(pn).plists.isparam('database'), atest = false; end
185 if ~io(pn).plists.isparam('binary'), atest = false; end
186 if ~io(pn).plists.isparam('username'), atest = false; end
187 if ~io(pn).plists.isparam('password'), atest = false; end
188 % Check default value
189 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
190 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
191 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
192 if ~isEmptyDouble(io(pn).plists.find('id')), atest = false; end
193 if ~isEmptyDouble(io(pn).plists.find('cid')), atest = false; end
194 if ~isequal(io(pn).plists.find('binary'), 'yes'), atest = false; end
195 %%%%%%%%%% SET 'From Built-in Model'
196 pn = 7;
197 if io(pn).plists.nparams ~= 4, atest = false; end
198 % Check key
199 if ~io(pn).plists.isparam('built-in'), atest = false; end
200 if ~io(pn).plists.isparam('symbolic params'), atest = false; end
201 if ~io(pn).plists.isparam('param names'), atest = false; end
202 if ~io(pn).plists.isparam('param values'), atest = false; end
203 % Check default value
204 if ~isEmptyChar(io(pn).plists.find('built-in')), atest = false; end
205 %%%%%%%%%% SET 'From Description'
206 pn = 8;
207 if io(pn).plists.nparams ~= 12, atest = false; end
208 % Check key
209 if ~io(pn).plists.isparam('name'), atest = false; end
210 if ~io(pn).plists.isparam('description'), atest = false; end
211 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
212 if ~io(pn).plists.isparam('states'), atest = false; end
213 if ~io(pn).plists.isparam('outputs'), atest = false; end
214 if ~io(pn).plists.isparam('inputs'), atest = false; end
215 if ~io(pn).plists.isparam('timestep'), atest = false; end
216 if ~io(pn).plists.isparam('amats'), atest = false; end
217 if ~io(pn).plists.isparam('bmats'), atest = false; end
218 if ~io(pn).plists.isparam('cmats'), atest = false; end
219 if ~io(pn).plists.isparam('dmats'), atest = false; end
220 if ~io(pn).plists.isparam('params'), atest = false; end
221 % Check default value
222 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
223 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
224 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
225 %%%%%%%%%% SET 'From Pzmodel'
226 pn = 9;
227 if io(pn).plists.nparams ~= 4, atest = false; end
228 % Check key
229 if ~io(pn).plists.isparam('name'), atest = false; end
230 if ~io(pn).plists.isparam('description'), atest = false; end
231 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
232 if ~io(pn).plists.isparam('pzmodel'), atest = false; end
233 % Check default value
234 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
235 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
236 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
237 if ~eq(io(pn).plists.find('pzmodel'), pzmodel(), ple1), atest = false; end
238 %%%%%%%%%% SET 'From MIIR'
239 pn = 10;
240 if io(pn).plists.nparams ~= 4, atest = false; end
241 % Check key
242 if ~io(pn).plists.isparam('name'), atest = false; end
243 if ~io(pn).plists.isparam('description'), atest = false; end
244 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
245 if ~io(pn).plists.isparam('miir'), atest = false; end
246 % Check default value
247 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
248 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
249 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
250 if ~eq(io(pn).plists.find('miir'), miir(), ple1), atest = false; end
251 %%%%%%%%%% SET 'From rational'
252 pn = 11;
253 if io(pn).plists.nparams ~= 4, atest = false; end
254 % Check key
255 if ~io(pn).plists.isparam('name'), atest = false; end
256 if ~io(pn).plists.isparam('description'), atest = false; end
257 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
258 if ~io(pn).plists.isparam('rational'), atest = false; end
259 % Check default value
260 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
261 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
262 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
263 if ~eq(io(pn).plists.find('rational'), rational(), ple1), atest = false; end
264 end
265 % </AlgoCode>
266 else
267 atest = false;
268 end
269
270 % Return a result structure
271 result = utp_prepare_result(atest, stest, dbstack, mfilename);
272 end % END UTP_01
273
274
275 end