Mercurial > hg > ltpda
view testing/utp_1.1/generic_utps/utp_04.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> % % Tests that the <METHOD> method works with a list of objects as input. % % </TestDescription> function result = utp_04(method, obj1, obj2, obj3, algo, pli, ple3) % <SyntaxDescription> % % Test that the <METHOD> method works for a list of objects as input. % % </SyntaxDescription> try % <SyntaxCode> if isempty(pli) out = feval(method, obj1, obj2, obj3); else out = feval(method, obj1, obj2, obj3, pli); end % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the number of elements in 'out' is the same as in 'mat' % 2) Check that each output object contains the correct data. % % </AlgoDescription> atest = true; if stest obj_in = [obj1 obj2 obj3]; % <AlgoCode> % Check we have the correct number of outputs if ~isequal(size(out), size(obj_in)), atest = false; end % Check each output against the correct value for kk=1:numel(obj_in) % extra tests for constructors if utils.helper.ismember(method, utils.helper.ltpda_userclasses) % Check that the output is the same except the history if ~eq(obj_in(kk), out(kk), ple3), atest = false; end % Check the history if ~eq(obj_in(kk).hist, out(kk).hist.inhists), atest = false; end % Change the output to make sure that it is a 'real' copy out(kk).setDescription('my desc'); if eq(obj_in(kk), out(kk), ple3), atest = false; end else atest = algo(obj_in(kk), out(kk), pli); if ~atest break; end end end % </AlgoCode> else atest = false; end % Return a result structure dd = dbstack; mfilename = dd(2).file(1:end-2); result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_02