%
% DESCRIPTION: Generic check for a arithmetic operator unit test which
%              checks the history for a single inputs.
%
% CALL:        atest = check_aop_history(fcn, in1, in2, out);
%
% VERSION:     $Id: check_aop_history.m,v 1.4 2010/09/24 16:18:16 ingo Exp $
%

function atest = check_aop_history(fcn, in1, in2, out)
  
  atest = true;
  % Check the last history step
  for ii = 1:numel(out)
    if ~strcmp(out(ii).hist.methodInfo.mname, func2str(fcn)), atest = false; end
  end
  
  doCheck = round(rand(1,1)*10);
  doCheck = 1;
  
  % Check the rebuild only in 10 percent of the unit test. I do this to
  % speedup the tests.
  if doCheck == 1
    try
      ple = plist('Exceptions', {'created', 'proctime', 'UUID', 'param/desc', 'name', 'methodInvars', 'version'});
      
      % Rebuild the output object
      mout = rebuild(copy(out,1));
      
      % The rebuilt object must be the same as 'out'
      for ii=1:numel(mout)
        if ~eq(mout(ii), out(ii), ple), atest = false; end
        if atest == 0
          break;
        end
      end
      
    catch
      atest = false;
    end
  end
  
end
