view testing/utp_1.1/generic_utps/utp_12.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

% <TestDescription>
%
% Check that the errors are cleared for this method.
%
% </TestDescription>
function result = utp_12(method, obj1, ple1, varargin)
  
  % <SyntaxDescription>
  %
  % Call the method with a list of output variables and with a single output
  % variable. Additionaly check that the rebuild method works on the output.
  %
  % </SyntaxDescription>
  
  if ~isempty(varargin)
    pli = varargin{1};
  else
    pli = [];
  end
  
  try
    % <SyntaxCode>
    if isa(obj1.data, 'data2D')
      obj1 = obj1.setDx(obj1.x);
    end
    obj1 = obj1.setDy(obj1.y);
    if isempty(pli)
      o1 = feval(method, obj1);
    else
      o1 = feval(method, obj1, pli);
    end
    % </SyntaxCode>
    stest = true;
  catch err
    disp(err.message)
    stest = false;
  end
  
  % <AlgoDescription>
  %
  % 1) Check that the output has no error fields
  %
  % </AlgoDescription>
  
  atest = true;
  if stest
    % check which axis the method was applied to, if any
    ax = o1.hist.plistUsed.find('axis');
    % <AlgoCode>
    if any('X'==upper(ax)) && ~isempty(o1.dx), atest = false; end
    if any('Y'==upper(ax)) && ~isempty(o1.dy), atest = false; end
    % </AlgoCode>
  else
    atest = false;
  end
  
  % Return a result structure
  dd = dbstack;
  mfilename = dd(2).file(1:end-2);  
  result = utp_prepare_result(atest, stest, dbstack, mfilename);
end % END UTP_12