Mercurial > hg > ltpda
view testing/utp_1.1/generic_utps/utp_genericOutput.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> % % Check that the <METHOD> method pass back the output objects to a list of % output variables or to a single variable. % % </TestDescription> function result = utp_genericOutput(method, obj1, obj2, args, algo, ple) % <SyntaxDescription> % % Call the method with a list of output variables and with a single output % variable. Additionaly check that the rebuild method works on the output. % % </SyntaxDescription> try % <SyntaxCode> if iscell(args) [o1, o2] = feval(method, obj1, obj2, args{:}); o3 = feval(method, obj1, obj2, args{:}); else [o1, o2] = feval(method, obj1, obj2, args); o3 = feval(method, obj1, obj2, args); end mout1 = rebuild(o1); mout2 = rebuild(o2); mout3 = rebuild(o3); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the output contains the right number of objects % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the outputs t1 = algo(obj1, o1, 1, args); t2 = algo(obj2, o2, 1, args); t3 = algo(obj1, o3(1), 1, args); t4 = algo(obj2, o3(2), 1, args); atest = t1 && t2 && t3 && t4; % Check the number of outputs if numel(o1) ~=1, atest = false; end if numel(o2) ~=1, atest = false; end if numel(o3) ~=2, atest = false; end % Check the rebuilding of the object if ~eq(o1, mout1, ple), atest = false; end if ~eq(o2, mout2, ple), atest = false; end if ~eq(o3, mout3, ple), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, ['utp_' class(obj1) '_' method]); end % END UTP_10