Mercurial > hg > ltpda
view testing/utp_1.1/utps/ao/utp_ao_export.m @ 49:0bcdf74587d1 database-connection-manager
Cleanup
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 07 Dec 2011 17:24:36 +0100 |
parents | 409a22968d5e |
children |
line wrap: on
line source
% UTP_AO_EXPORT a set of UTPs for the ao/export method % % M Hewitson 06-08-08 % % $Id: utp_ao_export.m,v 1.4 2011/04/18 16:57:44 ingo Exp $ % % <MethodDescription> % % The export method of the ao class export an analysis object data to a % text file. This is a very simple method which accepts only one parfrac as % input thus are the most general units test not possible. % % </MethodDescription> function results = utp_ao_export(varargin) % Check the inputs if nargin == 0 % Some keywords class = 'ao'; mthd = 'export'; results = []; disp('******************************************************'); disp(['**** Running UTPs for ' class '/' mthd]); disp('******************************************************'); % 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]; % Test with non complex data results = [results utp_03]; % Test with complex data results = [results utp_04]; % List with plist(filename) 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 %% 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 numel(io(2).plists) ~= numel(io(2).sets), atest = false; end %%%%%%%%%% SET 'Default' if io(3).plists.nparams ~= 2, atest = false; end % Check key if ~io(3).plists.isparam('filename'), atest = false; end if ~io(3).plists.isparam('complex format'), atest = false; end % Check default value if ~isEmptyChar(io(3).plists.find('filename')), atest = false; end if ~isequal(io(3).plists.find('complex format'), 'realimag'), atest = false; end % Check options if ~isequal(io(3).plists.getOptionsForParam('filename'), {''}), atest = false; end if ~isequal(io(3).plists.getOptionsForParam('complex format'), {'absdeg', 'realimag', 'absrad'}), 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 export method works with non complex data in the AO. % % </TestDescription> function result = utp_02 % <SyntaxDescription> % % Tests that the export method works with non complex data in the AO. % % </SyntaxDescription> try % <SyntaxCode> plts = plist('fs', '1', 'nsecs', 30, 'tsfcn', 'randn(size(t))'); plfs = plist('f', '1:30', 'fsfcn', 'randn(size(f))'); plxy = plist('x', '1:30', 'xyfcn', 'randn(size(x))'); fn1 = ('at1.txt'); fn2 = ('at2.txt'); fn3 = ('at3.txt'); at1 = ao(plts); at2 = ao(plfs); at3 = ao(plxy); export(at1, fn1); export(at2, fn2); export(at3, fn3); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the file exist. % 2) Check that the read data is the same as the saved data. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check that the file exist if exist(fn1, 'file') ~= 2, atest = false; end if exist(fn2, 'file') ~= 2, atest = false; end if exist(fn3, 'file') ~= 2, atest = false; end % Check that the read data is the same as the saved data a1 = ao(fn1, plist('type', 'tsdata', 'columns', [1 2])); a2 = ao(fn2, plist('type', 'fsdata', 'columns', [1 2])); a3 = ao(fn3, plist('type', 'xydata', 'columns', [1 2])); if ~isequal(at1.x, a1.x), atest = false; end if ~isequal(at1.y, a1.y), atest = false; end if ~isequal(at2.x, a2.x), atest = false; end if ~isequal(at2.y, a2.y), atest = false; end if ~isequal(at3.x, a3.x), atest = false; end if ~isequal(at3.y, a3.y), atest = false; end % </AlgoCode> delete(fn1); delete(fn2); delete(fn3); 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 export method works with complex data in the AO. % % </TestDescription> function result = utp_03 % <SyntaxDescription> % % Tests that the export method works with complex data in the AO. % % </SyntaxDescription> try % <SyntaxCode> plts = plist('fs', '1', 'nsecs', 30, 'tsfcn', 'randn(size(t)) + randn(size(t))*i'); plfs = plist('f', '1:30', 'fsfcn', 'randn(size(f)) + randn(size(f))*i'); plxy = plist('x', '1:30', 'xyfcn', 'randn(size(x)) + randn(size(x))*i'); fn1 = ('at1.txt'); fn2 = ('at2.txt'); fn3 = ('at3.txt'); at1 = ao(plts); at2 = ao(plfs); at3 = ao(plxy); export(at1, fn1); export(at2, fn2); export(at3, fn3); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the file exist. % 2) Check that the read data is the same as the saved data. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check that the file exist if exist(fn1, 'file') ~= 2, atest = false; end if exist(fn2, 'file') ~= 2, atest = false; end if exist(fn3, 'file') ~= 2, atest = false; end % Check that the read data is the same as the saved data a1r = ao(fn1, plist('type', 'tsdata', 'columns', [1 2])); a1c = ao(fn1, plist('type', 'tsdata', 'columns', [1 3])); a2r = ao(fn2, plist('type', 'fsdata', 'columns', [1 2])); a2c = ao(fn2, plist('type', 'fsdata', 'columns', [1 3])); a3r = ao(fn3, plist('type', 'xydata', 'columns', [1 2])); a3c = ao(fn3, plist('type', 'xydata', 'columns', [1 3])); a1 = complex(a1r, a1c); a2 = complex(a2r, a2c); a3 = complex(a3r, a3c); if ~isequal(at1.x, a1.x), atest = false; end if ~isequal(at1.y, a1.y), atest = false; end if ~isequal(at2.x, a2.x), atest = false; end if ~isequal(at2.y, a2.y), atest = false; end if ~isequal(at3.x, a3.x), atest = false; end if ~isequal(at3.y, a3.y), atest = false; end % </AlgoCode> delete(fn1); delete(fn2); delete(fn3); 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 export method works with a plist which contains the filename. % % </TestDescription> function result = utp_04 % <SyntaxDescription> % % Tests that the export method works with a plist which contains the % filename. % % </SyntaxDescription> try % <SyntaxCode> plts = plist('fs', '1', 'nsecs', 30, 'tsfcn', 'randn(size(t)) + randn(size(t))*i'); plfs = plist('f', '1:30', 'fsfcn', 'randn(size(f))'); fn1 = ('at1.txt'); fn2 = ('at2.txt'); at1 = ao(plts); at2 = ao(plfs); export(at1, plist('filename', fn1)); export(at2, plist('filename', fn2)); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the file exist. % 2) Check that the read data is the same as the saved data. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check that the file exist if exist(fn1, 'file') ~= 2, atest = false; end if exist(fn2, 'file') ~= 2, atest = false; end % Check that the read data is the same as the saved data a1r = ao(fn1, plist('type', 'tsdata', 'columns', [1 2])); a1c = ao(fn1, plist('type', 'tsdata', 'columns', [1 3])); a2 = ao(fn2, plist('type', 'fsdata', 'columns', [1 2])); a1 = complex(a1r, a1c); if ~isequal(at1.x, a1.x), atest = false; end if ~isequal(at1.y, a1.y), atest = false; end if ~isequal(at2.x, a2.x), atest = false; end if ~isequal(at2.y, a2.y), atest = false; end % </AlgoCode> delete(fn1); delete(fn2); else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_04 end