% <TestDescription>
%
% Tests that the <METHOD> method works for a list of objects as input.
%
% </TestDescription>
function result = utp_genericList(method, obj1, obj2, obj3, args, algo)
  
  % <SyntaxDescription>
  %
  % Tests that the <METHOD> method works for a list of objects as input.
  %
  % </SyntaxDescription>
  
  try
    % <SyntaxCode>
    if isempty(args)
      out = feval(method, obj1, obj2, obj3);
    else
      if iscell(args)
        out = feval(method, obj1, obj2, obj3, args{:});
      else
        out = feval(method, obj1, obj2, obj3, args);
      end
    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 'objs'
  % 2) Check that each output object contains the correct data.
  %
  % </AlgoDescription>
  
  atest = true;
  objIn = [reshape(obj1, 1, []) reshape(obj2, 1, []) reshape(obj3, 1, [])];
  if stest
    % <AlgoCode>
    % Check we have the correct number of outputs
    if ~isequal(size(out), size(objIn)), atest = false; end
    % Check each output against the correct value
    for kk=1:numel(out)
      
      atest = algo(objIn, out, kk, args);
      if ~atest
        break;
      end
      
    end
    
    % </AlgoCode>
  else
    atest = false;
  end
  
  % Return a result structure
  stack = dbstack;
  result = utp_prepare_result(atest, stest, stack, ['utp_' class(obj1) '_' method]);
end
