Mercurial > hg > ltpda
view testing/utp_1.1/utps/smodel/utp_smodel_clearAliases.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
% UTP_SMODEL_CLEARALIASES a set of UTPs for the smodel/clearAliases method % % M Hewitson 06-08-08 % % $Id: utp_smodel_clearAliases.m,v 1.1 2011/04/11 19:45:22 ingo Exp $ % % <MethodDescription> % % The clearAliases method of the smodel class clears the 'aliasNames' and % 'aliasValues' properties. % % </MethodDescription> function results = utp_smodel_clearAliases(varargin) % Check the inputs if nargin == 0 % Some keywords cl = 'smodel'; mthd = 'clearAliases'; disp('******************************************************'); disp(['**** Running UTPs for ' cl '/' mthd]); disp('******************************************************'); % Test objects s1 = smodel('a1*x1 + a2*x2 + a3*x3'); s1.setName(); s2 = smodel('a1*x1 + a2*x2'); s2.setName(); s3 = smodel('a1*x1'); s3.setName(); sv = [s1, s2, s1]; sm = [s1, s2, s1; s1, s2, s1]; % Exception list for the UTPs: [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples(); % The setter method have different possibilities to set a property % Run the general tests results(1) = utp_01(); results(2) = utp_genericAnyShape(mthd, s1, {}, @algoTests); results(3) = utp_genericAnyShape(mthd, sv, {}, @algoTests); results(4) = utp_genericAnyShape(mthd, sm, {}, @algoTests); results(5) = utp_genericList(mthd, s1, s2, s3, {}, @algoTests); results(6) = utp_genericHistory(mthd, s1, {}, ple2); results(7) = utp_genericModify(mthd, s1, {}, @algoTests, ple1); results(8) = utp_genericOutput(mthd, s1, s2, {}, @algoTests, ple2); % test the outputs disp('Done.'); disp('******************************************************'); elseif nargin == 1 % Check for UTP functions if strcmp(varargin{1}, 'isutp') results = 1; else results = 0; end else error('### Incorrect inputs') end % Check that the property have the correct value function atest = algoTests(in, out, idx, argsin) atest = true; % Check that the input and output objects are the same except the % property 'aliases' and the history ple = plist('EXCEPTIONS', {'created', 'proctime', 'UUID', 'hist', 'aliasNames', 'aliasValues'}); if ~eq(in(idx), out(idx), ple), atest = false; end if ~eq(in(idx).hist, out(idx).hist.inhists), atest = false; end % Check 'aliasNames' and 'aliasValues' if ~isequal(out(idx).aliasNames, {}), atest = false; end if ~isequal(out(idx).aliasValues, {}), atest = false; end end %% UTP_01 % <TestDescription> % % Tests that the getInfo call works for this method. % % </TestDescription> function result = utp_01 % <SyntaxDescription> % % Test that the getInfo call works for no sets, all sets, and each set % individually. % % </SyntaxDescription> try % <SyntaxCode> % Call for no sets io(1) = feval('smodel.getInfo', mthd, 'none'); % Call for all sets io(2) = feval('smodel.getInfo', mthd); % Call for each set for kk=1:numel(io(2).sets) io(kk+2) = feval('smodel.getInfo', mthd, io(2).sets{kk}); end % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that getInfo call returned an minfo object in all cases. % 2) Check that all plists have the correct parameters. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % check we have minfo objects if isa(io, 'minfo') % SET 'None' if ~isempty(io(1).sets), atest = false; end if ~isempty(io(1).plists), atest = false; end % Check all Sets if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end % SET 'Default' if io(3).plists.nparams ~= 0, atest = false; end % Check key % Check default value % Check options end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_01 end