Mercurial > hg > ltpda
view 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 |
line wrap: on
line source
% <TestDescription> % % Test that bode works on this model. % % </TestDescription> % % $Id: utp_920.m,v 1.2 2010/07/27 07:37:28 hewitson Exp $ % function result = utp_920(cl, model_name, pl) % <SyntaxDescription> % % Test that bode works on this model. % % </SyntaxDescription> try % <SyntaxCode> pl = combine(pl, plist('built-in', model_name)); mdl = feval(cl, pl); outs = bode(mdl); % </SyntaxCode> stest = true; catch err disp(err.message) msg = [err.message ' - ' err.stack(1).name ' - line ' num2str(err.stack(1).line)]; stest = false; end % <AlgoDescription> % % 1) Test that bode produces the correct number of AOs. % 2) Compare each output AO against validated outputs. % % </AlgoDescription> atest = true; if stest msg = ''; % <AlgoCode> % Check the correct number of outputs if numel(outs) ~= (sum(mdl.inputsizes) * sum(mdl.outputsizes)) atest = false; msg = sprintf('bode produced the wrong number of outputs for model %s', model_name); end % Load references refs = ao(sprintf('utps/%s/reference_files/ref_bode_%s.mat', cl, model_name)); for kk=1:numel(refs) ref = refs(kk); out = outs(kk); if ~isequal(ref.y, out.y) atest = false; msg = sprintf('bode resp for %s element %d [%s] doesn''t match the reference', model_name, kk, out.name); end end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename, msg); end % END UTP_920