view testing/utp_1.1/generic_utps/utp_07.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents 409a22968d5e
children
line wrap: on
line source

% <TestDescription>
%
% Tests that the <METHOD> method can modify the input AO.
%
% </TestDescription>
function result = utp_07(method, obj1, ipl, ple1)
  
  % <SyntaxDescription>
  %
  % Test that the <METHOD> method can modify the input object by calling with no
  % output and that the method doesn't change the input of the function
  % notation (with a equal sign).
  %
  % </SyntaxDescription>
  
  try
    % <SyntaxCode>
    obj_modi = copy(obj1,1);
    obj_eq   = copy(obj1,1);
    cmd = sprintf('out = obj_eq.%s(ipl);', method);
    eval(cmd);
    cmd = sprintf('obj_modi.%s(ipl);', method);
    eval(cmd);
    % </SyntaxCode>
    stest = true;
  catch err
    disp(err.message)
    stest = false;
  end
  
  % <AlgoDescription>
  %
  % 1) Check that 'out' and 'aeq' are now different.
  % 2) Check that 'aeq' is not changed
  % 3) Check that the modified input is the <METHOD> value of the copy
  % 4) Check that out and amodi are the same
  %
  % </AlgoDescription>
  
  atest = true;
  if stest
    % <AlgoCode>
    % Check that 'out' and 'obj_eq' are now different.
    if eq(out, obj_eq, ple1), atest = false; end
    % Check that 'obj_eq' is not changed
    if ~eq(obj_eq, obj1, ple1), atest = false; end
    
    switch class(obj1)
      case 'ao'
        if isempty(ipl) || isempty(find(ipl, 'neval'))
        % Check that the modified input is correct
        if ~isequal(feval(method, obj1.data.getY), obj_modi.data.getY), atest = false; end
        end
        % Check that out and obj_modi are the same
        if ~eq(out, obj_modi, ple1), atest = false; end
      otherwise
        warning('!!! test is undefined for class %s', class(obj_modi));
        atest = false;
    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_07