% <TestDescription>
%
% Tests that the model <MODEL> has a meaningful name.
%
% </TestDescription>
% 
% $Id: utp_901.m,v 1.3 2010/07/27 07:37:28 hewitson Exp $
%

function result = utp_901(cl, model_name, pl)
  
  % <SyntaxDescription>
  %
  % Test that the model <MODEL> has a meaningful name.
  %
  % </SyntaxDescription>
  
  try
    
    % <SyntaxCode>
    pl  = combine(pl, plist('built-in', model_name));
    mdl = feval(cl, pl);
    % </SyntaxCode>
    stest = true;
  catch err
    disp(err.message)
    msg = [err.message ' - ' err.stack(1).name ' - line ' num2str(err.stack(1).line)];
    stest = false;
  end
  
  % <AlgoDescription>
  %
  % 1) Check that the name of the object is not empty and not equal to 'none'
  %
  % </AlgoDescription>
  
  atest = true;
  if stest
    msg = '';
    % <AlgoCode>
    % check the model produces an object of the correct class
    if ~isa(mdl, cl)
      atest = false; 
      msg = sprintf('The model produced by %s is not a %s model', model_name, cl);
    end
    % check the name
    if strcmpi(mdl.name, 'none')
      atest = false; 
      msg = sprintf('The model %s gives an object with the name ''none''', model_name);
    end
    % check empty
    if isempty(mdl.name)
      atest = false; 
      msg = sprintf('The model %s gives an object with an empty name', model_name);
    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, msg);
end % END UTP_901