% <TestDescription>
%
% Tests that the <METHOD> method works with a mix of different arrays of objects as input.
%
% </TestDescription>
function result = utp_05(method, obj1, obj2, obj3, algo, pli, ple3)
  
  % <SyntaxDescription>
  %
  % Tests that the <METHOD> method works with a mix of different arrays of
  % objects as input.
  %
  % </SyntaxDescription>
  
  try
    % <SyntaxCode>
    if isempty(pli)
      out = feval(method, obj1, obj2, obj3);
    else
      out = feval(method, obj1, obj2, obj3, pli);
    end
    % </SyntaxCode>
    stest = true;
  catch err
    disp(err.message)
    stest = false;
  end
  
  % <AlgoDescription>
  %
  % 1) Check that the number of elements in 'out' is the same as in 'mat'
  % 2) Check that each output object contains the correct data.
  %
  % </AlgoDescription>
  
  atest = true;
  if stest
    obj_in = [reshape(obj1, 1, []) reshape(obj2, 1, []) reshape(obj3, 1, [])];
    % <AlgoCode>
    % Check we have the correct number of outputs
    if ~isequal(size(out), size(obj_in)), atest = false; end
    % Check each output against the correct value
    for kk=1:numel(obj_in)
      
      % extra tests for constructors
      if utils.helper.ismember(method, utils.helper.ltpda_userclasses)
        
        % Check that the output is the same except the history
        if ~eq(obj_in(kk), out(kk), ple3), atest = false; end
        % Check the history
        if ~eq(obj_in(kk).hist, out(kk).hist.inhists), atest = false; end
        % Change the output to make sure that it is a 'real' copy
        out(kk).setDescription('my desc');
        if eq(obj_in(kk), out(kk), ple3), atest = false; end
        
      else
        atest = algo(obj_in(kk), out(kk), pli);
        if ~atest
          break;
        end 
      end
    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_02