% <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




