comparison testing/utp_1.1/utps/pzmodel/utp_pzmodel_getupperFreq.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_pzmodel_GETUPPERFREQ a set of UTPs for the pzmodel/getupperFreq method
2 %
3 % M Hewitson 06-08-08
4 %
5 % $Id: utp_pzmodel_getupperFreq.m,v 1.2 2009/07/23 18:56:38 ingo Exp $
6 %
7
8 % <MethodDescription>
9 %
10 % The getupperFreq method of the pzmodel class gets the frequency of the lowest
11 % pole or zero in the model. This is a very simple method which accepts only one
12 % pzmodel as input thus are the most general units test not possible.
13 %
14 % </MethodDescription>
15
16 function results = utp_pzmodel_getupperFreq(varargin)
17
18 % Check the inputs
19 if nargin == 0
20
21 % Some keywords
22 class = 'pzmodel';
23 mthd = 'getupperFreq';
24
25 results = [];
26 disp('******************************************************');
27 disp(['**** Running UTPs for ' class '/' mthd]);
28 disp('******************************************************');
29
30 % Exception list for the UTPs:
31 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
32
33 % Run the tests
34 results = [results utp_01]; % getInfo call
35 results = [results utp_02]; % Algorithm test
36 results = [results utp_03]; % Negative test with more than one pzmodel
37
38 disp('Done.');
39 disp('******************************************************');
40
41 elseif nargin == 1 % Check for UTP functions
42 if strcmp(varargin{1}, 'isutp')
43 results = 1;
44 else
45 results = 0;
46 end
47 else
48 error('### Incorrect inputs')
49 end
50
51 %% UTP_01
52
53 % <TestDescription>
54 %
55 % Tests that the getInfo call works for this method.
56 %
57 % </TestDescription>
58 function result = utp_01
59
60
61 % <SyntaxDescription>
62 %
63 % Test that the getInfo call works for no sets, all sets, and each set
64 % individually.
65 %
66 % </SyntaxDescription>
67
68 try
69 % <SyntaxCode>
70 % Call for no sets
71 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
72 % Call for all sets
73 io(2) = eval([class '.getInfo(''' mthd ''')']);
74 % Call for each set
75 for kk=1:numel(io(2).sets)
76 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
77 end
78 % </SyntaxCode>
79 stest = true;
80 catch err
81 disp(err.message)
82 stest = false;
83 end
84
85 % <AlgoDescription>
86 %
87 % 1) Check that getInfo call returned an minfo object in all cases.
88 % 2) Check that all plists have the correct parameters.
89 %
90 % </AlgoDescription>
91
92 atest = true;
93 if stest
94 % <AlgoCode>
95 % check we have minfo objects
96 if isa(io, 'minfo')
97 % SET 'None'
98 if ~isempty(io(1).sets), atest = false; end
99 if ~isempty(io(1).plists), atest = false; end
100 % Check all Sets
101 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end
102 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end
103 % SET 'Default'
104 if io(3).plists.nparams ~= 0, atest = false; end
105 % Check key
106 % Check default value
107 % Check options
108 end
109 % </AlgoCode>
110 else
111 atest = false;
112 end
113
114 % Return a result structure
115 result = utp_prepare_result(atest, stest, dbstack, mfilename);
116 end % END UTP_01
117
118 %% UTP_02
119
120 % <TestDescription>
121 %
122 % Tests the getupperFreq method of the pzmodel class.
123 %
124 % </TestDescription>
125 function result = utp_02
126
127 % <SyntaxDescription>
128 %
129 % Test that the getupperFreq returns the lowest frequence of the lowest
130 % pole or zero in the model.
131 %
132 % </SyntaxDescription>
133
134 try
135 % <SyntaxCode>
136 p=[pz(3,2) pz(40)]; %f=3,40
137 z=[pz(2,3) pz(100)]; %f=2,100
138 pzm = pzmodel(10, p, z);
139 out = getupperFreq(pzm);
140 % </SyntaxCode>
141 stest = true;
142 catch err
143 disp(err.message)
144 stest = false;
145 end
146
147 % <AlgoDescription>
148 %
149 % 1) Check the output
150 %
151 % </AlgoDescription>
152
153 atest = true;
154 if stest
155 % <AlgoCode>
156 if out ~= 100, atest = false; end
157 % </AlgoCode>
158 else
159 atest = false;
160 end
161
162 % Return a result structure
163 result = utp_prepare_result(atest, stest, dbstack, mfilename);
164 end % END UTP_02
165
166 %% UTP_03
167
168 % <TestDescription>
169 %
170 % Tests the getupperFreq method of the pzmodel class.
171 %
172 % </TestDescription>
173 function result = utp_03
174
175 % <SyntaxDescription>
176 %
177 % Test that the getupperFreq throws an error if the input are more than one
178 % pzmodel.
179 %
180 % </SyntaxDescription>
181
182 try
183 % <SyntaxCode>
184 p=[pz(3,2) pz(40)]; %f=3,40
185 z=[pz(2,3) pz(100)]; %f=2,100
186 pzm = pzmodel(10, p, z);
187 out = getupperFreq([pzm, pzm]);
188 stest = false;
189 % </SyntaxCode>
190 catch err
191 stest = true;
192 end
193
194 % <AlgoDescription>
195 %
196 % 1) Nothing to test
197 %
198 % </AlgoDescription>
199
200 atest = true;
201 if stest
202 % <AlgoCode>
203 % </AlgoCode>
204 else
205 atest = false;
206 end
207
208 % Return a result structure
209 result = utp_prepare_result(atest, stest, dbstack, mfilename);
210 end % END UTP_03
211
212 end