Mercurial > hg > ltpda
view testing/utp_1.1/utps/miir/utp_miir_miir.m @ 52:daf4eab1a51e database-connection-manager tip
Fix. Default password should be [] not an empty string
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 07 Dec 2011 17:29:47 +0100 |
parents | 409a22968d5e |
children |
line wrap: on
line source
% UTP_MIIR_MIIR a set of UTPs for the miir/miir method % % M Hewitson 06-08-08 % % $Id: utp_miir_miir.m,v 1.38 2011/08/22 05:37:13 hewitson Exp $ % % <MethodDescription> % % The miir method of the miir class constructs MIIR objects. % % </MethodDescription> function results = utp_miir_miir(varargin) % Check the inputs if nargin == 0 % Some keywords class = 'miir'; mthd = 'miir'; results = []; disp('******************************************************'); disp(['**** Running UTPs for ' class '/' mthd]); disp('******************************************************'); % Test objects [iirhp,iirlp,iirbp,iirbr,iirpzm,iirab,iirv,iirm] = get_test_objects_miir; % Exception list for the UTPs: [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples(); % Run the tests results = [results utp_01]; % getInfo call results = [results utp_02]; % Vector input results = [results utp_03]; % Matrix input results = [results utp_04]; % List input results = [results utp_05]; % Test with mixed input results = [results utp_06]; % Test history is working with empty constructor results = [results utp_07]; % Test history is working with copy constructor results = [results utp_08]; % Test history is working with MAT file constructor results = [results utp_09]; % Test history is working with XML file constructor results = [results utp_10]; % Test history is working with FIL file constructor results = [results utp_11]; % Test history is working with struct constructor results = [results utp_12]; % Test history is working with parfrac-object constructor results = [results utp_13]; % Test history is working with pzmodel-object constructor results = [results utp_14]; % Test history is working with plist(filename) constructor results = [results utp_15]; % Test history is working with plist(hostname) constructor results = [results utp_16]; % Test history is working with plist(type) constructor results = [results utp_17]; % Test history is working with plist(pzmodel) constructor results = [results utp_18]; % Test history is working with plist(parfrac) constructor results = [results utp_19]; % Test history is working with plist(plist) constructor results = [results utp_20]; % Test history is working with plist(a+b) constructor results = [results utp_21]; % Test history is working with pzmodel + plist constructor results = [results utp_22]; % Test history is working with parfrac + plist constructor results = [results utp_23]; % Test history is working with conn+Id constructor results = [results utp_24]; % Test history is working with a + b + fs 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') prefs = getappdata(0, 'LTPDApreferences'); %%% 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 XML File')), atest = false; end if ~any(strcmpi(io(2).sets, 'From MAT File')), atest = false; end if ~any(strcmpi(io(2).sets, 'From LISO File')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Repository')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Standard Type')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Parfrac')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Pzmodel')), atest = false; end if ~any(strcmpi(io(2).sets, 'From AB')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Built-in Model')), 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 LISO File' pn = 8; 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 Standard Type' pn = 9; if io(pn).plists.nparams ~= 11, 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('type'), atest = false; end if ~io(pn).plists.isparam('fc'), atest = false; end if ~io(pn).plists.isparam('gain'), atest = false; end if ~io(pn).plists.isparam('fs'), atest = false; end if ~io(pn).plists.isparam('order'), atest = false; end if ~io(pn).plists.isparam('ripple'), atest = false; end if ~io(pn).plists.isparam('iunits'), atest = false; end if ~io(pn).plists.isparam('ounits'), atest = false; end % Check default value if ~isequal(io(pn).plists.find('type'), 'lowpass'), atest = false; end if ~isequal(io(pn).plists.find('fc'), .1), atest = false; end if ~isequal(io(pn).plists.find('gain'), 1), atest = false; end if ~isequal(io(pn).plists.find('fs'), 1), atest = false; end if ~isequal(io(pn).plists.find('order'), 1), atest = false; end if ~isequal(io(pn).plists.find('ripple'), .5), atest = false; end if ~isEmptyChar(io(pn).plists.find('iunits')), atest = false; end if ~isEmptyChar(io(pn).plists.find('ounits')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('type'), {'highpass', 'lowpass', 'bandpass', 'bandreject'}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('fc'), {.1}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('gain'), {1}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('fs'), {1}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('order'), {1}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('ripple'), {.5}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('iunits'), {''}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('ounits'), {''}), atest = false; end %%%%%%%%%% SET 'Allpass' pn = 10; if io(pn).plists.nparams ~= 8, atest = false; end % Check key if ~io(pn).plists.isparam('delay'), atest = false; end if ~io(pn).plists.isparam('N'), atest = false; end if ~io(pn).plists.isparam('method'), atest = false; end % Check default value if ~isEmptyDouble(io(pn).plists.find('delay')), atest = false; end if ~isequal(io(pn).plists.find('N'), 1), atest = false; end if ~isequal(io(pn).plists.find('method'), 'thirlen'), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('delay'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('N'), {[1]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('method'), {'thirlen'}), atest = false; end %%%%%%%%%% SET 'From Parfrac' pn = 11; if io(pn).plists.nparams ~= 7, atest = false; end % Check key if ~io(pn).plists.isparam('parfrac'), atest = false; end if ~io(pn).plists.isparam('fs'), atest = false; end if ~io(pn).plists.isparam('iunits'), atest = false; end if ~io(pn).plists.isparam('ounits'), atest = false; end % Check default value if ~eq(io(pn).plists.find('parfrac'), parfrac(), ple1), atest = false; end if ~isEmptyDouble(io(pn).plists.find('fs')), atest = false; end if ~isEmptyChar(io(pn).plists.find('iunits')), atest = false; end if ~isEmptyChar(io(pn).plists.find('ounits')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('fs'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('iunits'), {''}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('ounits'), {''}), atest = false; end %%%%%%%%%% SET 'From Pzmodel' pn = 12; if io(pn).plists.nparams ~= 7, atest = false; end % Check key if ~io(pn).plists.isparam('pzmodel'), atest = false; end if ~io(pn).plists.isparam('fs'), atest = false; end if ~io(pn).plists.isparam('iunits'), atest = false; end if ~io(pn).plists.isparam('ounits'), atest = false; end % Check default value if ~eq(io(pn).plists.find('pzmodel'), pzmodel(), ple1), atest = false; end if ~isEmptyDouble(io(pn).plists.find('fs')), atest = false; end if ~isEmptyChar(io(pn).plists.find('iunits')), atest = false; end if ~isEmptyChar(io(pn).plists.find('ounits')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('fs'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('iunits'), {''}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('ounits'), {''}), atest = false; end %%%%%%%%%% SET 'From AB' pn = 13; if io(pn).plists.nparams ~= 8, atest = false; end % Check key if ~io(pn).plists.isparam('a'), atest = false; end if ~io(pn).plists.isparam('b'), atest = false; end if ~io(pn).plists.isparam('fs'), atest = false; end if ~io(pn).plists.isparam('name'), atest = false; end % Check default value if ~isEmptyDouble(io(pn).plists.find('a')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('b')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('fs')), atest = false; end if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('a'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('b'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('fs'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('name'), {''}), 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 %% UTP_02 % <TestDescription> % % Tests that the miir method works with a vector of MIIR objects as input. % % </TestDescription> function result = utp_02 % <SyntaxDescription> % % Test that the miir method works with a vector of MIIR objects as input. % % </SyntaxDescription> try % <SyntaxCode> out = miir(iirv); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the shape of the output MIIRs is the same as the input shape. % 2) Check that each output MIIR is a copy of the input MIIR. % 3) Check that the copy have an additional history step. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check we have the correct shape if size(out) ~= size(iirv), atest = false; end % Check that the output is a copy. for ii = 1:numel(out) % Check that the output is the same except the history if ~eq(iirv(ii), out(ii), ple3), atest = false; end % Check the history if ~eq(iirv(ii).hist, out(ii).hist.inhists), atest = false; end % Change the output to make sure that it is a 'real' copy out(ii).setDescription('my desc'); if eq(iirv(ii), out(ii), ple3), atest = false; end end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_02 %% UTP_03 % <TestDescription> % % Tests that the miir method works with a matrix of MIIR objects as input. % % </TestDescription> function result = utp_03 % <SyntaxDescription> % % Test that the miir method works with a matrix of MIIR objects as input. % % </SyntaxDescription> try % <SyntaxCode> out = miir(iirm); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the shape of the output MIIRs is the same as the input shape. % 2) Check that each output MIIR is a copy of the input MIIR. % 3) Check that the copy have an additional history step. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check we have the correct number of outputs if size(out) ~= size(iirm), atest = false; end % Check that the output is a copy. for ii = 1:numel(out) % Check that the output is the same except the history if ~eq(iirm(ii), out(ii), ple3), atest = false; end % Check the history if ~eq(iirm(ii).hist, out(ii).hist.inhists), atest = false; end % Change the output to make sure that it is a 'real' copy out(ii).setDescription('my desc'); if eq(iirm(ii), out(ii), ple3), atest = false; end end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_03 %% UTP_04 % <TestDescription> % % Tests that the miir method works with a list of MIIR objects as input. % % </TestDescription> function result = utp_04 % <SyntaxDescription> % % Test that the miir method works with a list of MIIR objects as input. % % </SyntaxDescription> try % <SyntaxCode> out = miir(iirhp, iirlp, iirbp); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the number of elements in 'out' is the same of the % number in the input. % 2) Check that each output MIIR is a copy of the input MIIR. % 3) Check that the copy have an additional history step. % % </AlgoDescription> atest = true; iirin = [iirhp, iirlp, iirbp]; if stest % <AlgoCode> % Check we have the correct number of outputs if numel(out) ~= 3, atest = false; end % Check that the output is a copy. for ii = 1:numel(out) % Check that the output is the same except the history if ~eq(iirin(ii), out(ii), ple3), atest = false; end % Check the history if ~eq(iirin(ii).hist, out(ii).hist.inhists), atest = false; end % Change the output to make sure that it is a 'real' copy out(ii).setDescription('my desc'); if eq(iirin(ii), out(ii), ple3), atest = false; end end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_04 %% UTP_05 % <TestDescription> % % Tests that the miir method works with a mix of different shaped MIIRs as % input. % % </TestDescription> function result = utp_05 % <SyntaxDescription> % % Test that the miir method works with a mix of different shaped MIIRs as % input. % % </SyntaxDescription> try % <SyntaxCode> out = miir(iirhp,iirv,iirbr,iirm,iirlp); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the number of elements in 'out' is the same of the % number in the input. % 2) Check that each output MIIR is a copy of the input MIIR. % 3) Check that the copy have an additional history step. % % </AlgoDescription> atest = true; iirin = [iirhp, reshape(iirv, 1, []), iirbr, reshape(iirm, 1, []), iirlp]; if stest % <AlgoCode> % Check we have the correct number of outputs if numel(out) ~= 3+numel(iirv)+numel(iirm), atest = false; end % Check that the output is a copy. for ii = 1:numel(out) % Check that the output is the same except the history if ~eq(iirin(ii), out(ii), ple3), atest = false; end % Check the history if ~eq(iirin(ii).hist, out(ii).hist.inhists), atest = false; end % Change the output to make sure that it is a 'real' copy out(ii).setDescription('my desc'); if eq(iirin(ii), out(ii), ple3), atest = false; end end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_05 %% UTP_06 % <TestDescription> % % Tests that the miir method properly applies history. % % </TestDescription> function result = utp_06 % <SyntaxDescription> % % Test that the result of applying the miir method can be processed back. % % </SyntaxDescription> try % <SyntaxCode> out = miir(iirlp); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'miir'. % 2) Check that the method rebuild produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'miir'), atest = false; end % Check the rebuilt object if ~eq(mout, out, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_06 %% UTP_07 % <TestDescription> % % Tests that the miir method properly applies history to the copy constructor. % % </TestDescription> function result = utp_07 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. % Test the constructor with a different number of inputs. % % </SyntaxDescription> try % <SyntaxCode> out1 = miir(iirhp); out2 = miir(iirhp, iirlp); out3 = miir(iirhp, iirlp, iirbp); out1.setName('my name'); out2(1).setName('my name'); out2(2).setName('my name'); out3(1).setName('my name'); out3(2).setName('my name'); out3(3).setName('my name'); mout = rebuild(out1); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'miir'. % 2) Check that the original objects are not changed by the setter function % 3) Check that the method rebuild produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' % It is the method 'setName' because we set it in above if ~strcmp(out1.hist.methodInfo.mname, 'setName'), atest = false; end % Check next to the last step in the history of 'out' if ~strcmp(out1.hist.inhists.methodInfo.mname, 'miir'), atest = false; end % Check the originals if strcmp(iirhp, 'my name'), atest = false; end if strcmp(iirlp, 'my name'), atest = false; end if strcmp(iirbp, 'my name'), atest = false; end % Check the rebuilt object if ~eq(mout, out1, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_07 %% UTP_08 % <TestDescription> % % Tests that the miir method properly applies history to the read % MAT-file constructor. % % </TestDescription> function result = utp_08 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. % % </SyntaxDescription> try % <SyntaxCode> filename = 'iir.mat'; iir = miir(iirlp); save(iir, filename); out = miir(filename); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the history is the same as the history of the saved % object. Because save and load shouldn't add a history step. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check that the saved and loaded objects are the same if ~eq(out, iir), atest = false; end % Check the rebuilt object if ~eq(mout, out, ple2), atest = false; end % </AlgoCode> delete(filename); else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_08 %% UTP_09 % <TestDescription> % % Tests that the miir method properly applies history to the read % XML-file constructor. % % </TestDescription> function result = utp_09 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. % % </SyntaxDescription> try % <SyntaxCode> filename = 'iir.xml'; amat = miir(iirm); save(amat, filename); out = miir(filename); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the history is the same as the history of the saved % object. Because save and load shouldn't add a history step. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~eq(out, amat), atest = false; end % Check the rebuilt object for kk = 1:numel(out) if ~eq(mout(kk), out(kk), ple2), atest = false; end end % </AlgoCode> delete(filename); else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_09 %% UTP_10 % <TestDescription> % % Tests that the miir method properly applies history to the read % FIL-file constructor. % % </TestDescription> function result = utp_10 % <SyntaxDescription> % % Read the FIL file which is created from LISO. % Test that the output can be processed back with the 'rebuild' method. % % </SyntaxDescription> try % <SyntaxCode> filename = 'test_iir.fil'; out = miir(filename); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' % corresponds to 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'miir'), atest = false; end % Reading a file adds additionally history steps if ~isa(out, 'miir'), atest = false; end % Check the rebuilt object if ~eq(mout, out, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_10 %% UTP_11 % <TestDescription> % % Tests that the miir method properly applies history to the struct constructor. % % </TestDescription> function result = utp_11 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. % % </SyntaxDescription> try % <SyntaxCode> siirhp = struct(iirhp); siirhp.iunits = struct(iirhp.iunits); siirhp.ounits = struct(iirhp.ounits); siirhp.hist = struct(iirhp.hist); out1 = miir(struct(iirpzm)); out2 = miir(siirhp); mout1 = rebuild(out1); mout2 = rebuild(out2); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' % corresponds to 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check that the output is a MIIR object if ~isa(out1,'miir'), atest = false; end if ~isa(out2,'miir'), atest = false; end % Check the last step in the history of 'out' if ~strcmp(out1.hist.methodInfo.mname, 'setName'), atest = false; end if ~strcmp(out2.hist.methodInfo.mname, 'setName'), atest = false; end % Check the rebuilt object if ~eq(mout1, out1, ple2), atest = false; end if ~eq(mout2, out2, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_11 %% UTP_12 % <TestDescription> % % Tests that the miir method properly applies history to the parfrac constructor. % % </TestDescription> function result = utp_12 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. % % </SyntaxDescription> try % <SyntaxCode> pfrac = parfrac([1 2], {4, 6+2i}, 0, 'my par frac', unit('V'), unit('Hz')); out = miir(pfrac); iir1 = out.index(1); iir2 = out.index(2); mout1 = rebuild(iir1); mout2 = rebuild(iir2); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' % corresponds to 'miir'. % 2) Check the correct number of outputs. % 3) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check that the output is a MIIR object if ~isa(out,'miir'), atest = false; end % Check number of filter objects. This parfrac objects created two filter. if numel(out) ~= 2, atest = false; end % Check the last step in the history of 'out' if ~strcmp(out(1).hist.methodInfo.mname, 'miir'), atest = false; end if ~strcmp(out(2).hist.methodInfo.mname, 'miir'), atest = false; end % Check the rebuilt object if ~eq(mout1, iir1, ple2), atest = false; end if ~eq(mout2, iir2, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_12 %% UTP_13 % <TestDescription> % % Tests that the miir method properly applies history to the pzmodel constructor. % % </TestDescription> function result = utp_13 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. % % </SyntaxDescription> try % <SyntaxCode> ps = [pz(1) pz(200)]; zs = pz(50); pzm = pzmodel(1, ps, zs, unit('Hz^2'), unit('V^2')); out = miir(pzm); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' % corresponds to 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check that the output is a MIIR object if ~isa(out,'miir'), atest = false; end % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'miir'), atest = false; end if ~strcmp(out.hist.inhists.methodInfo.mname, 'pzmodel'), atest = false; end % Check the rebuilt object if ~eq(mout, out, ple1), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_13 %% UTP_14 % <TestDescription> % % Tests that the miir method properly applies history to the % plist(filename) constructor. % % </TestDescription> function result = utp_14 % <SyntaxDescription> % % Test that the output can be processed back to an m-file. % % </SyntaxDescription> try % <SyntaxCode> filename1 = 'iir.xml'; filename2 = 'iir.mat'; filename3 = 'test_iir.fil'; f1 = miir(iirpzm); f2 = miir(iirlp); save(f1, filename1); save(f2, filename2); out1 = miir(plist('filename', filename1)); out2 = miir(plist('filename', filename2)); out3 = miir(plist('filename', filename3)); rout1 = out1.rebuild; rout2 = out2.rebuild; rout3 = out3.rebuild; % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the save method doesn't change the input object % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % The load doesn't have two additionally history steps (save + load) if ~eq(out1, f1, ple1), atest = false; end if ~eq(out2, f2, ple1), atest = false; end % Rebuild object and check the result if ~eq(rout1, out1, ple2), atest = false; end if ~eq(rout2, out2, ple2), atest = false; end if ~eq(rout3, out3, ple2), atest = false; end % </AlgoCode> % delete test file delete(filename1) delete(filename2) else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_14 %% UTP_15 % <TestDescription> % % Tests that the MIIR method properly applies history to the % plist(conn) constructor. % % </TestDescription> function result = utp_15 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> conn = utpGetConnection(); sinfo.conn = conn; sinfo.experiment_title = 'utp_miir_miir_15: submit miir vector'; sinfo.experiment_description = 'utp_miir_miir_15: &description'; sinfo.analysis_description = '<utp_miir_miir_15>'; sinfo.quantity = 'none'; sinfo.keywords = 'none'; sinfo.reference_ids = ''; sinfo.additional_comments = 'none'; sinfo.additional_authors = 'no one'; plForAutoTest = plist('no dialog', true, 'use selector', false); ids = submit(iirv, sinfo, plForAutoTest); out = miir(plist('hostname', utpGetHostname, 'database', utpGetDatabase, 'conn', conn, 'id', ids)); % </SyntaxCode> % Close connection utpCloseConnection(conn); stest = true; catch err disp(err.message) % Close connection utpCloseConnection(conn); stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' for kk = 1:numel(out) if ~strcmp(out(kk).hist.methodInfo.mname, 'miir'), atest = false; end end % Check data values if ~eq(out, iirv, ple3), atest = false; end % Rebuild object and check the result % % This test is in an automatic test not possible because the repository % asks for username and password. % % Manually tested by: Ingo Diepholz % Test date: 01.12.2008 % Status: success % % rout = rebuild(out); % if ~eq(rout, out, ple3), atest = false; end % % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_15 %% UTP_16 % <TestDescription> % % Tests that the MIIR method properly applies history to the % plist(type) constructor. % % </TestDescription> function result = utp_16 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> pl1 = plist('type', 'lowpass'); pl2 = plist('type', 'highpass'); pl3 = plist('type', 'bandpass'); pl4 = plist('type', 'bandreject'); plerr = plist('type', 'wrong name'); % Use different values to the default values fs = 1000; fc = 60; fcb = [50 100]; order = 3; pl = plist('fs', fs, 'fc', fc, 'order', order); plb = plist('fs', fs, 'fc', fcb, 'order', order); out1 = miir(combine(pl1, pl)); out2 = miir(combine(pl2, pl)); out3 = miir(combine(pl3, plb)); out4 = miir(combine(pl4, plb)); rout1 = rebuild(out1); rout2 = rebuild(out2); rout3 = rebuild(out3); rout4 = rebuild(out4); try % Negative test: Should throw an error miir(plerr); stest = false; catch stest = true; end % </SyntaxCode> catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out1.hist.methodInfo.mname, 'miir'), atest = false; end if ~strcmp(out2.hist.methodInfo.mname, 'miir'), atest = false; end if ~strcmp(out3.hist.methodInfo.mname, 'miir'), atest = false; end if ~strcmp(out4.hist.methodInfo.mname, 'miir'), atest = false; end % Check 'lowpass' filter [a, b] = butter(order, 2*fc/fs); if ~isequal(out1.a, a), atest = false; end if ~isequal(out1.b, b), atest = false; end if ~isequal(out1.fs, fs), atest = false; end if ~strcmp(out1.name, 'lowpass'), atest = false; end % Check 'highpass' filter [a, b] = butter(order, 2*fc/fs, 'high'); if ~isequal(out2.a, a), atest = false; end if ~isequal(out2.b, b), atest = false; end if ~isequal(out2.fs, fs), atest = false; end if ~strcmp(out2.name, 'highpass'), atest = false; end % Check 'bandpass' filter [a, b] = cheby1(order, .5, 2.*fcb./fs); if ~isequal(out3.a, a), atest = false; end if ~isequal(out3.b, b), atest = false; end if ~isequal(out3.fs, fs), atest = false; end if ~strcmp(out3.name, 'bandpass'), atest = false; end % Check 'bandpass' filter [a, b] = cheby1(order, .5, 2.*fcb./fs, 'stop'); if ~isequal(out4.a, a), atest = false; end if ~isequal(out4.b, b), atest = false; end if ~isequal(out4.fs, fs), atest = false; end if ~strcmp(out4.name, 'bandreject'), atest = false; end % Rebuild object and check the result if ~eq(rout1, out1, ple1), atest = false; end if ~eq(rout2, out2, ple1), atest = false; end if ~eq(rout3, out3, ple1), atest = false; end if ~eq(rout4, out4, ple1), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_16 %% UTP_17 % <TestDescription> % % Tests that the MIIR method properly applies history to the % plist(pzmodel) constructor. % % </TestDescription> function result = utp_17 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> ps = [pz(1) pz(200)]; zs = pz(50); pzm = pzmodel(1, ps, zs, unit('Hz'), unit('V')); pl = plist('pzmodel', pzm, 'fs', 1000); out = miir(pl); rout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'miir'), atest = false; end % Check the next to the last step in the history. % It must be the history of the pole/zero model (here 'pzmodel') % Since we changed the constructors, the history no longer contains the pzmodel % since we put the pzmodel in the plist. % if ~strcmp(out.hist.inhists.methodInfo.mname, 'pzmodel'), atest = false; end % Check values if ~isequal(out.fs, 1000), atest = false; end if ~eq(out.iunits, unit('Hz')), atest = false; end if ~eq(out.ounits, unit('V')), atest = false; end % Rebuild object and check the result if ~eq(rout, out, ple1), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_17 %% UTP_18 % <TestDescription> % % Tests that the MIIR method properly applies history to the % plist(parfrac) constructor. % % </TestDescription> function result = utp_18 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> pfrac = parfrac([1 2], {4, 6}, 8, 'my par frac', unit('V'), unit('Hz')); pl = plist('parfrac', pfrac, 'fs', 1000); out = miir(pl); iir1 = out.index(1); iir2 = out.index(2); iir3 = out.index(3); rout1 = rebuild(iir1); rout2 = rebuild(iir2); rout3 = rebuild(iir3); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> for ii = 1:numel(out) % Check the last step in the history of 'out' if ~strcmp(out(ii).hist.methodInfo.mname, 'miir'), atest = false; end % Check the next to the last step in the history. % It must be the history of the partial fraction model (here 'parfrac') if ~strcmp(out(ii).hist.inhists.methodInfo.mname, 'parfrac'), atest = false; end % Check values if ~isequal(out(ii).fs, 1000), atest = false; end if ~eq(out(ii).iunits, unit('V')), atest = false; end if ~eq(out(ii).ounits, unit('Hz')), atest = false; end end % Rebuild object and check the result if ~eq(rout1, iir1, ple2), atest = false; end if ~eq(rout2, iir2, ple2), atest = false; end if ~eq(rout3, iir3, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_18 %% UTP_19 % <TestDescription> % % Tests that the MIIR method properly applies history to the % plist(<plist-object>) constructor. % % </TestDescription> function result = utp_19 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> pfrac = parfrac([1 2], {4, 6}, 8, 'my par frac', unit('V'), unit('Hz')); pl = plist('parfrac', pfrac, 'fs', 1000); out1 = miir(plist('plist', pl)); out2 = miir(plist('plist', plist())); % empty plist iir1 = out1.index(1); iir2 = out1.index(2); iir3 = out1.index(3); rout1 = rebuild(iir1); rout2 = rebuild(iir2); rout3 = rebuild(iir3); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> for ii = 1:numel(out1) % Check the last step in the history of 'out1' if ~strcmp(out1(ii).hist.methodInfo.mname, 'miir'), atest = false; end % Check the next to the last step in the history. % It must be the history of the partial fraction model (here 'parfrac') if ~strcmp(out1(ii).hist.inhists.methodInfo.mname, 'parfrac'), atest = false; end % Check values if ~isequal(out1(ii).fs, 1000), atest = false; end if ~eq(out1(ii).iunits, unit('V')), atest = false; end if ~eq(out1(ii).ounits, unit('Hz')), atest = false; end end % Check the last step in the history of 'out2' if ~strcmp(out2.hist.methodInfo.mname, 'miir'), atest = false; end % Check the next to the last step in the history. if ~isempty(out2.hist.inhists), atest = false; end % Rebuild object and check the result if ~eq(rout1, iir1, ple2), atest = false; end if ~eq(rout2, iir2, ple2), atest = false; end if ~eq(rout3, iir3, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_19 %% UTP_20 % <TestDescription> % % Tests that the MIIR method properly applies history to the a,b constructor. % % </TestDescription> function result = utp_20 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> pl = plist('a', [1 2 3], 'b', [4 5 6], 'fs', 123); out = miir(pl); rout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'miir'), atest = false; end % Check values if ~isequal(out.fs, 123), atest = false; end if ~isequal(out.a, [1 2 3]), atest = false; end if ~isequal(out.b, [4 5 6]), atest = false; end % Rebuild object and check the result if ~eq(rout, out, ple1), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_20 %% UTP_21 % <TestDescription> % % Tests that the MIIR method properly applies history to the % pole/zero model + plist object constructor. % % </TestDescription> function result = utp_21 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> ps = [pz(1) pz(200)]; zs = pz(50); pzm = pzmodel(1, ps, zs, unit('Hz'), unit('V')); pl = plist('fs', 123); out = miir(pzm, pl); rout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'miir'), atest = false; end % Check values if ~isequal(out.fs, 123), atest = false; end if ~eq(out.iunits, unit('Hz')), atest = false; end if ~eq(out.ounits, unit('V')), atest = false; end % Rebuild object and check the result if ~eq(rout, out, ple1), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_21 %% UTP_22 % <TestDescription> % % Tests that the MIIR method properly applies history to the % partial fraction model + plist object constructor. % % </TestDescription> function result = utp_22 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> pfrac = parfrac(1, 4, 0, 'my par frac', unit('V'), unit('Hz')); pl = plist('fs', 123); out = miir(pfrac, pl); rout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'miir'), atest = false; end % Check values if ~isequal(out.fs, 123), atest = false; end if ~eq(out.iunits, unit('V')), atest = false; end if ~eq(out.ounits, unit('Hz')), atest = false; end % Rebuild object and check the result if ~eq(rout, out, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_22 %% UTP_23 % <TestDescription> % % Tests that the MIIR method properly applies history to the conn+Id constructor. % % </TestDescription> function result = utp_23 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> conn = utpGetConnection(); sinfo.conn = conn; sinfo.experiment_title = 'utp_miir_miir_23: submit miir'; sinfo.experiment_description = 'utp_miir_miir_23: description'; sinfo.analysis_description = 'utp_miir_miir_23'; sinfo.quantity = 'none'; sinfo.keywords = 'none'; sinfo.reference_ids = ''; sinfo.additional_comments = 'none'; sinfo.additional_authors = 'no one'; plForAutoTest = plist('no dialog', true, 'use selector', false); [ids] = submit(iirab, sinfo, plForAutoTest); out = miir(conn, ids); % </SyntaxCode> % Close connection utpCloseConnection(conn); stest = true; catch err disp(err.message) % Close connection utpCloseConnection(conn); stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'miir'), atest = false; end % Check data values if ~eq(out,iirab, ple3), atest = false; end % Check the history except the additional 'submit' + 'retrieve' steps if ~eq(out.hist.inhists, iirab.hist), atest = false; end % % This test is in an automatic test not possible because the repository % asks for username and password % % Manual test by: Ingo Diepholz % Test date: 01.12.2008 % Status: success % % rout = rebuild(out); % if ~eq(mout, out, ple3), atest = false; end % % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_23 %% UTP_24 % <TestDescription> % % Tests that the MIIR method properly applies history to the % a + b + fs object constructor. % % </TestDescription> function result = utp_24 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> a = [1 2 3]; b = [5 6 7]; fs = 123.123; out = miir(a,b,fs); rout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'miir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'miir'), atest = false; end % Check values if ~isequal(out.fs, 123.123), atest = false; end if ~isequal(out.a, [1 2 3]), atest = false; end if ~isequal(out.b, [5 6 7]), atest = false; end % Rebuild object and check the result if ~eq(rout, out, ple1), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_24 end