view testing/utp_1.1/generic_utps/utp_genericHistory.m @ 50:7d2e2e065cf1 database-connection-manager

Update unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:24:37 +0100
parents 409a22968d5e
children
line wrap: on
line source

% <TestDescription>
%
% Tests that the <METHOD> method properly applies history.
%
% </TestDescription>
function result = utp_genericHistory(method, obj, args, ple)
  
  % <SyntaxDescription>
  %
  % Test that the result of applying the <METHOD> method can be processed
  % back.
  %
  % </SyntaxDescription>
  
  try
    % <SyntaxCode>
    if isempty(args)
      out  = feval(method, obj);
    else
      if iscell(args)
        out  = feval(method, obj, args{:});
      else
        out  = feval(method, obj, args);
      end
    end
    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
  %    '<METHOD>'.
  % 2) Check that the re-built object is the same object as the input.
  %
  % </AlgoDescription>
  
  atest = true;
  if stest
    % <AlgoCode>
    % Check the last step in the history of 'out'
    if ~strcmp(out.hist.methodInfo.mname, method), atest = false; end
    % The rebuilt object must be the same as 'out'
    if ~eq(mout, out, ple), atest = false; end
    % </AlgoCode>
  else
    atest = false;
  end
  
  % Return a result structure
  result = utp_prepare_result(atest, stest, dbstack, ['utp_' class(obj) '_' method]);
end