Mercurial > hg > ltpda
view testing/utp_1.1/utps/ao/utp_ao_gt.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_AO_GT a set of UTPs for the ao/gt method % % M Hewitson 06-08-08 % % $Id: utp_ao_gt.m,v 1.2 2009/07/20 16:50:09 ingo Exp $ % % <MethodDescription> % % The lt() function of the ao class ao1 > ao2 compares the y-axis values of % ao1 with y-axis values of ao2 and returns an array with elements set to % logical 1 (true) where the relation is true and elements set to logical 0 % where it is not. % % </MethodDescription> function results = utp_ao_gt(varargin) % Check the inputs if nargin == 0 % Some keywords class = 'ao'; mthd = 'gt'; results = []; disp('******************************************************'); disp(['**** Running UTPs for ' class '/' mthd]); disp('******************************************************'); % Test AOs [at1,at2,at3,at4,at5,at6,atvec,atmat] = eval(['get_test_objects_' class]); % Run the tests results = [results utp_01]; % getInfo call results = [results utp_02]; % Compare against scalar results = [results utp_03]; % Compare against AO 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 ~= 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 %% UTP_02 % <TestDescription> % % Tests that the gt method compare an AO with scalar value % % </TestDescription> function result = utp_02 % <SyntaxDescription> % % Test that the gt method works with relational operators and the function % command. Use for this AOs with different data objects. % % </SyntaxDescription> try % <SyntaxCode> scalar = 0.2; out11 = at1 > scalar; out12 = gt(at1,scalar); out21 = at2 > scalar; out22 = gt(at2,scalar); out31 = at3 > scalar; out32 = gt(at3,scalar); out41 = at4 > scalar; out42 = gt(at4,scalar); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the result of the 'relational operator' and the 'function' % command are the same. % 2) Check that each output AO contains the correct data. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the different commands if ~isequal(out11, out12), atest = false; end if ~isequal(out21, out22), atest = false; end if ~isequal(out31, out32), atest = false; end if ~isequal(out41, out42), atest = false; end % Check the output data y1 = at1.y; y2 = at2.y; y3 = at3.y; y4 = at4.y; if ~isequal(out11, y1>scalar), atest = false; end if ~isequal(out21, y2>scalar), atest = false; end if ~isequal(out31, y3>scalar), atest = false; end if ~isequal(out41, y4>scalar), atest = false; 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 gt method compare an AO with one other AO % % </TestDescription> function result = utp_03 % <SyntaxDescription> % % Test that the gt method works with relational operators and the function % command. Use for this AOs with different data objects. % Remark that both AOs must have the same size. % % </SyntaxDescription> try % <SyntaxCode> out11 = at1 > ao(1:300, zeros(300,1)); out12 = gt(at1,ao(1:300, zeros(300,1))); out21 = at2 > ao(1:151, zeros(151,1)); out22 = gt(at2,ao(1:151, zeros(151,1))); out31 = at3 > ao(1:100, zeros(100,1)); out32 = gt(at3,ao(1:100, zeros(100,1))); out41 = at4 > ao(zeros(3,3)); out42 = gt(at4,ao(zeros(3,3))); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the result of the 'relational operator' and the 'function' % command are the same. % 2) Check that each output AO contains the correct data. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the different commands if ~isequal(out11, out12), atest = false; end if ~isequal(out21, out22), atest = false; end if ~isequal(out31, out32), atest = false; end if ~isequal(out41, out42), atest = false; end % Check the output data y1 = at1.y; y2 = at2.y; y3 = at3.y; y4 = at4.y; if ~isequal(out11, y1>0), atest = false; end if ~isequal(out21, y2>0), atest = false; end if ~isequal(out31, y3>0), atest = false; end if ~isequal(out41, y4>0), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_03 end