Mercurial > hg > ltpda
view testing/utp_1.1/utps/ssm/utp_ssm_ssm.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_SSM_SSM a set of UTPs for the ssm/ssm method % % M Hewitson 06-08-08 % % $Id: utp_ssm_ssm.m,v 1.14 2011/09/29 13:46:19 ingo Exp $ % % <MethodDescription> % % The ssm method of the ssm class constructs SSM objects. % % </MethodDescription> function results = utp_ssm_ssm(varargin) % Check the inputs if nargin == 0 % Some keywords class = 'ssm'; mthd = 'ssm'; results = []; disp('******************************************************'); disp(['**** Running UTPs for ' class '/' mthd]); disp('******************************************************'); % Test objects [sys1, sys2] = get_test_objects_ssm; % Exception list for the UTPs: [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples(); % Run the general tests results = [results utp_01]; % getInfo call results = [results utp_02(mthd, [sys1 sys2], [], [], ple3)]; % Vector input results = [results utp_03(mthd, [sys1 sys2 sys1; sys2 sys2 sys1], [], [], ple3)]; % Matrix input results = [results utp_04(mthd, sys1, sys2, sys1, [], [], ple3)]; % List input results = [results utp_05(mthd, sys1, [sys1 sys2], [sys1 sys2 sys1; sys2 sys2 sys1], [], [], ple3)]; % Test with mixed input results = [results utp_06(mthd, sys1, [], ple1)]; % Test history is working % constructor specific tests results = [results utp_60(class, sys1, ple1)]; % Test history is properly handled with MAT file constructor results = [results utp_61(class, sys1, ple1)]; % Test history is properly handled with XML file constructor results = [results utp_62(class, sys1, sys2, ple2)]; % Test history is working with struct constructor results = [results utp_63(class, ple1)]; % Test history is working with pzmodel-object constructor results = [results utp_64(class, sys1, ple1, ple2)]; % Test history is working with plist(filename) constructor results = [results utp_65(class, sys2, ple3)]; % Test history is working with plist(hostname) constructor results = [results utp_66(class, ple1)]; % Test history is working with plist(pzmodel) constructor results = [results utp_67(class, ple1)]; % Test history is working with pzmodel + plist constructor results = [results utp_68(class, sys1, ple3)]; % Test history is working with conn+Id constructor disp('Done.'); disp('******************************************************'); elseif nargin == 1 % Check for UTP functions if strcmp(varargin{1}, 'isutp') results = 1; elseif strcmpi(varargin{1}, 'needs repository') results = 2; else results = 0; end else error('### Incorrect inputs') 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) = eval([class '.getInfo(''' mthd ''', ''None'')']); % Call for all sets io(2) = eval([class '.getInfo(''' mthd ''')']); % Call for each set for kk=1:numel(io(2).sets) io(kk+2) = eval([class '.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 ~any(strcmpi(io(2).sets, 'From MAT File')), atest = false; end if ~any(strcmpi(io(2).sets, 'From XML File')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Repository')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Built-in Model')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Description')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Pzmodel')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Miir')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Rational')), atest = false; end if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end %%%%%%%%%% SET 'Default' pn = 3; if io(pn).plists.nparams ~= 12, atest = false; end % Check key if ~io(pn).plists.isparam('name'), atest = false; end if ~io(pn).plists.isparam('description'), atest = false; end if ~io(pn).plists.isparam('plotinfo'), atest = false; end if ~io(pn).plists.isparam('states'), atest = false; end if ~io(pn).plists.isparam('outputs'), atest = false; end if ~io(pn).plists.isparam('inputs'), atest = false; end if ~io(pn).plists.isparam('timestep'), atest = false; end if ~io(pn).plists.isparam('amats'), atest = false; end if ~io(pn).plists.isparam('bmats'), atest = false; end if ~io(pn).plists.isparam('cmats'), atest = false; end if ~io(pn).plists.isparam('dmats'), atest = false; end if ~io(pn).plists.isparam('params'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end %%%%%%%%%% SET 'From MAT File' pn = 4; if io(pn).plists.nparams ~= 4, atest = false; end % Check key if ~io(pn).plists.isparam('name'), atest = false; end if ~io(pn).plists.isparam('description'), atest = false; end if ~io(pn).plists.isparam('plotinfo'), atest = false; end if ~io(pn).plists.isparam('filename'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end %%%%%%%%%% SET 'From XML File' pn = 5; if io(pn).plists.nparams ~= 4, atest = false; end % Check key if ~io(pn).plists.isparam('name'), atest = false; end if ~io(pn).plists.isparam('description'), atest = false; end if ~io(pn).plists.isparam('plotinfo'), atest = false; end if ~io(pn).plists.isparam('filename'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end %%%%%%%%%% SET 'From Repository' pn = 6; if io(pn).plists.nparams ~= 10, atest = false; end % Check key if ~io(pn).plists.isparam('name'), atest = false; end if ~io(pn).plists.isparam('description'), atest = false; end if ~io(pn).plists.isparam('plotinfo'), atest = false; end if ~io(pn).plists.isparam('hostname'), atest = false; end if ~io(pn).plists.isparam('id'), atest = false; end if ~io(pn).plists.isparam('cid'), atest = false; end if ~io(pn).plists.isparam('database'), atest = false; end if ~io(pn).plists.isparam('binary'), atest = false; end if ~io(pn).plists.isparam('username'), atest = false; end if ~io(pn).plists.isparam('password'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('id')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('cid')), atest = false; end if ~isequal(io(pn).plists.find('binary'), 'yes'), atest = false; end %%%%%%%%%% SET 'From Built-in Model' pn = 7; if io(pn).plists.nparams ~= 4, atest = false; end % Check key if ~io(pn).plists.isparam('built-in'), atest = false; end if ~io(pn).plists.isparam('symbolic params'), atest = false; end if ~io(pn).plists.isparam('param names'), atest = false; end if ~io(pn).plists.isparam('param values'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('built-in')), atest = false; end %%%%%%%%%% SET 'From Description' pn = 8; if io(pn).plists.nparams ~= 12, atest = false; end % Check key if ~io(pn).plists.isparam('name'), atest = false; end if ~io(pn).plists.isparam('description'), atest = false; end if ~io(pn).plists.isparam('plotinfo'), atest = false; end if ~io(pn).plists.isparam('states'), atest = false; end if ~io(pn).plists.isparam('outputs'), atest = false; end if ~io(pn).plists.isparam('inputs'), atest = false; end if ~io(pn).plists.isparam('timestep'), atest = false; end if ~io(pn).plists.isparam('amats'), atest = false; end if ~io(pn).plists.isparam('bmats'), atest = false; end if ~io(pn).plists.isparam('cmats'), atest = false; end if ~io(pn).plists.isparam('dmats'), atest = false; end if ~io(pn).plists.isparam('params'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end %%%%%%%%%% SET 'From Pzmodel' pn = 9; if io(pn).plists.nparams ~= 4, atest = false; end % Check key if ~io(pn).plists.isparam('name'), atest = false; end if ~io(pn).plists.isparam('description'), atest = false; end if ~io(pn).plists.isparam('plotinfo'), atest = false; end if ~io(pn).plists.isparam('pzmodel'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end if ~eq(io(pn).plists.find('pzmodel'), pzmodel(), ple1), atest = false; end %%%%%%%%%% SET 'From MIIR' pn = 10; if io(pn).plists.nparams ~= 4, atest = false; end % Check key if ~io(pn).plists.isparam('name'), atest = false; end if ~io(pn).plists.isparam('description'), atest = false; end if ~io(pn).plists.isparam('plotinfo'), atest = false; end if ~io(pn).plists.isparam('miir'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end if ~eq(io(pn).plists.find('miir'), miir(), ple1), atest = false; end %%%%%%%%%% SET 'From rational' pn = 11; if io(pn).plists.nparams ~= 4, atest = false; end % Check key if ~io(pn).plists.isparam('name'), atest = false; end if ~io(pn).plists.isparam('description'), atest = false; end if ~io(pn).plists.isparam('plotinfo'), atest = false; end if ~io(pn).plists.isparam('rational'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end if ~eq(io(pn).plists.find('rational'), rational(), ple1), atest = false; end end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_01 end