Mercurial > hg > ltpda
view testing/utp_1.1/utps/pest/utp_pest_pest.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_PEST_PEST a set of UTPs for the pest/pest method % % M Hewitson 06-08-08 % % $Id: utp_pest_pest.m,v 1.3 2011/08/22 05:37:13 hewitson Exp $ % % <MethodDescription> % % The pest method of the pest class constructs pest objects. % % </MethodDescription> function results = utp_pest_pest(varargin) % Check the inputs if nargin == 0 % Some keywords class = 'pest'; mthd = 'pest'; results = []; disp('******************************************************'); disp(['**** Running UTPs for ' class '/' mthd]); disp('******************************************************'); % Test objects pe1 = pest([8, 9]); pe1.setName; pe2 = pest([1 2]); pe2.setName; % 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, [pe1 pe2 pe1], [], [], ple3)]; % Vector input results = [results utp_03(mthd, [pe1 pe2 pe1; pe2 pe2 pe1], [], [], ple3)]; % Matrix input results = [results utp_04(mthd, pe1, pe2, pe1, [], [], ple3)]; % List input results = [results utp_05(mthd, pe1, [pe1 pe2], [pe1 pe2 pe1; pe2 pe2 pe1], [], [], ple3)]; % Test with mixed input results = [results utp_06(mthd, pe1, [], ple2)]; % Test history is working % constructor specific tests results = [results utp_60(class, pe1, ple2)]; % Test history is properly handled with MAT file constructor results = [results utp_61(class, pe1, ple2)]; % Test history is properly handled with XML file constructor results = [results utp_62(class, pe1, pe2, ple2)]; % Test history is working with struct constructor results = [results utp_64(class, pe1, ple2, ple2)]; % Test history is working with plist(filename) constructor results = [results utp_65(class, pe2, ple3)]; % Test history is working with plist(hostname) constructor results = [results utp_68(class, pe1, 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 Values')), atest = false; end if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end %%%%%%%%%% SET 'Default' pn = 3; if io(pn).plists.nparams ~= 3, atest = false; end % Check key % Check default value % Check options %%%%%%%%%% SET 'From MAT File' pn = 4; if io(pn).plists.nparams ~= 4, atest = false; end % Check key if ~io(pn).plists.isparam('filename'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('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('filename'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('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('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 ~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 % Check options if ~isequal(io(pn).plists.getOptionsForParam('id'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('cid'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('binary'), {'yes', 'no'}), 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 % Check default value if ~isEmptyChar(io(pn).plists.find('built-in')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('built-in'), {''}), atest = false; end %%%%%%%%%% SET 'From Expression' 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('y'), atest = false; end if ~io(pn).plists.isparam('paramnames'), atest = false; end if ~io(pn).plists.isparam('dy'), atest = false; end if ~io(pn).plists.isparam('cov'), atest = false; end if ~io(pn).plists.isparam('chi2'), atest = false; end if ~io(pn).plists.isparam('dof'), atest = false; end if ~io(pn).plists.isparam('models'), atest = false; end if ~io(pn).plists.isparam('pdf'), atest = false; end % 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