comparison testing/utp_1.1/generic_utps/utp_920.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 % <TestDescription>
2 %
3 % Test that bode works on this model.
4 %
5 % </TestDescription>
6 %
7 % $Id: utp_920.m,v 1.2 2010/07/27 07:37:28 hewitson Exp $
8 %
9
10 function result = utp_920(cl, model_name, pl)
11
12 % <SyntaxDescription>
13 %
14 % Test that bode works on this model.
15 %
16 % </SyntaxDescription>
17
18 try
19 % <SyntaxCode>
20 pl = combine(pl, plist('built-in', model_name));
21 mdl = feval(cl, pl);
22 outs = bode(mdl);
23 % </SyntaxCode>
24 stest = true;
25 catch err
26 disp(err.message)
27 msg = [err.message ' - ' err.stack(1).name ' - line ' num2str(err.stack(1).line)];
28 stest = false;
29 end
30
31 % <AlgoDescription>
32 %
33 % 1) Test that bode produces the correct number of AOs.
34 % 2) Compare each output AO against validated outputs.
35 %
36 % </AlgoDescription>
37
38 atest = true;
39 if stest
40 msg = '';
41 % <AlgoCode>
42 % Check the correct number of outputs
43 if numel(outs) ~= (sum(mdl.inputsizes) * sum(mdl.outputsizes))
44 atest = false;
45 msg = sprintf('bode produced the wrong number of outputs for model %s', model_name);
46 end
47
48 % Load references
49 refs = ao(sprintf('utps/%s/reference_files/ref_bode_%s.mat', cl, model_name));
50
51 for kk=1:numel(refs)
52 ref = refs(kk);
53 out = outs(kk);
54 if ~isequal(ref.y, out.y)
55 atest = false;
56 msg = sprintf('bode resp for %s element %d [%s] doesn''t match the reference', model_name, kk, out.name);
57 end
58 end
59
60 % </AlgoCode>
61 else
62 atest = false;
63 end
64
65 % Return a result structure
66 result = utp_prepare_result(atest, stest, dbstack, mfilename, msg);
67
68 end % END UTP_920